Definition at line 8 of file MongoDbTest.php.
◆ _prepareCollection()
Fill the collection with data
Definition at line 266 of file MongoDbTest.php.
268 $this->_model->save(
'test data 1',
'test1', [
'tag1',
'tag2',
'tag3']);
269 $this->_model->save(
'test data 2',
'test2', [
'tag1',
'tag3']);
270 $this->_model->save(
'test data 3',
'test3', [
'tag2',
'tag1']);
271 $this->_model->save(
'test data 4',
'test4', [
'tag4',
'tag5']);
272 $this->_model->save(
'test data 5',
'test5', []);
◆ cleanDataProvider()
Definition at line 230 of file MongoDbTest.php.
234 'clean cache matching all tags' => [
237 [
'test2',
'test4',
'test5'],
239 'clean cache not matching tags' => [
242 [
'test1',
'test2',
'test3'],
244 'clean cache matching any tags' => [
const CLEANING_MODE_NOT_MATCHING_TAG
const CLEANING_MODE_MATCHING_ANY_TAG
const CLEANING_MODE_MATCHING_TAG
◆ getIdsMatchingAnyTagsDataProvider()
getIdsMatchingAnyTagsDataProvider |
( |
| ) |
|
Definition at line 119 of file MongoDbTest.php.
122 'no tags' => [[], []],
123 'one tag' => [[
'tag2'], [
'test1',
'test3']],
124 'multiple tags' => [[
'tag1',
'tag2'], [
'test1',
'test2',
'test3']]
◆ getIdsMatchingTagsDataProvider()
getIdsMatchingTagsDataProvider |
( |
| ) |
|
Definition at line 83 of file MongoDbTest.php.
86 'one tag' => [[
'tag1'], [
'test1',
'test2',
'test3']],
87 'multiple tags' => [[
'tag1',
'tag2'], [
'test1',
'test3']]
◆ getIdsNotMatchingTagsDataProvider()
getIdsNotMatchingTagsDataProvider |
( |
| ) |
|
Definition at line 101 of file MongoDbTest.php.
104 'one tag' => [[
'tag2'], [
'test2',
'test4',
'test5']],
105 'multiple tags' => [[
'tag1',
'tag2'], [
'test4',
'test5']]
◆ loadDataProvider()
Definition at line 178 of file MongoDbTest.php.
181 'infinite lifetime with validity' => [
'test data',
null,
false,
'test data'],
182 'infinite lifetime without validity' => [
'test data',
null,
true,
'test data'],
183 'zero lifetime with validity' => [
'test data', 0,
false,
false],
184 'zero lifetime without validity' => [
'test data', 0,
true,
'test data']
◆ setUp()
Definition at line 19 of file MongoDbTest.php.
21 if (defined(
'MONGODB_CONNECTION_STRING')) {
22 $this->_connectionString = MONGODB_CONNECTION_STRING;
24 if (empty($this->_connectionString) || !extension_loaded(
'mongo')) {
25 $this->markTestSkipped(
26 "Either 'mongo' extension is not loaded or 'MONGODB_CONNECTION_STRING' constant is not defined" 29 if (defined(
'MONGODB_DATABASE_NAME')) {
30 $this->_dbName = MONGODB_DATABASE_NAME;
32 $this->_model = new \Magento\Framework\Cache\Backend\MongoDb(
33 [
'connection_string' => $this->_connectionString,
'db' => $this->_dbName]
◆ tearDown()
Definition at line 37 of file MongoDbTest.php.
39 if (!empty($this->_connectionString) && extension_loaded(
'mongo')) {
◆ testClean()
testClean |
( |
|
$mode, |
|
|
|
$tags, |
|
|
|
$expectedIds |
|
) |
| |
@dataProvider cleanDataProvider
Definition at line 221 of file MongoDbTest.php.
225 $this->_model->clean(
$mode, $tags);
226 $actualIds = $this->_model->getIds();
227 $this->assertEquals($expectedIds, $actualIds);
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
◆ testCleanOld()
Definition at line 252 of file MongoDbTest.php.
254 $this->_model->save(
'long-living entity',
'long', [], 1000);
255 $this->_model->save(
'infinite-living entity',
'infinite', [],
null);
256 $this->_model->save(
'short-living entity',
'short', [], 0);
258 $expectedIds = [
'long',
'infinite'];
259 $actualIds = $this->_model->getIds();
260 $this->assertSame($expectedIds, $actualIds);
◆ testConstructorException()
testConstructorException |
( |
| ) |
|
@expectedException \Zend_Cache_Exception @expectedExceptionMessage 'db' option is not specified
Definition at line 50 of file MongoDbTest.php.
52 new \Magento\Framework\Cache\Backend\MongoDb();
◆ testGetIds()
Definition at line 55 of file MongoDbTest.php.
57 $this->assertEmpty($this->_model->getIds());
58 $this->_model->save(
'test data 1',
'test1');
59 $this->_model->save(
'test data 2',
'test2');
60 $this->assertEquals([
'test1',
'test2'], $this->_model->getIds());
◆ testGetIdsMatchingAnyTags()
testGetIdsMatchingAnyTags |
( |
|
$searchTags, |
|
|
|
$expectedIds |
|
) |
| |
@dataProvider getIdsMatchingAnyTagsDataProvider
Definition at line 112 of file MongoDbTest.php.
115 $actualIds = $this->_model->getIdsMatchingAnyTags($searchTags);
116 $this->assertEquals($expectedIds, $actualIds);
◆ testGetIdsMatchingTags()
testGetIdsMatchingTags |
( |
|
$searchTags, |
|
|
|
$expectedIds |
|
) |
| |
@dataProvider getIdsMatchingTagsDataProvider
Definition at line 76 of file MongoDbTest.php.
79 $actualIds = $this->_model->getIdsMatchingTags($searchTags);
80 $this->assertEquals($expectedIds, $actualIds);
◆ testGetIdsNotMatchingTags()
testGetIdsNotMatchingTags |
( |
|
$searchTags, |
|
|
|
$expectedIds |
|
) |
| |
@dataProvider getIdsNotMatchingTagsDataProvider
Definition at line 94 of file MongoDbTest.php.
97 $actualIds = $this->_model->getIdsNotMatchingTags($searchTags);
98 $this->assertEquals($expectedIds, $actualIds);
◆ testGetMetadatas()
Definition at line 128 of file MongoDbTest.php.
131 $tags = [
'tag_1',
'tag_2'];
132 $this->_model->save(
'test data', $cacheId, $tags, 100);
133 $actualResult = $this->_model->getMetadatas($cacheId);
134 $this->assertArrayHasKey(
'expire', $actualResult);
135 $this->assertArrayHasKey(
'tags', $actualResult);
136 $this->assertArrayHasKey(
'mtime', $actualResult);
137 $this->assertSame($tags, $actualResult[
'tags']);
◆ testGetTags()
Definition at line 63 of file MongoDbTest.php.
65 $this->assertEmpty($this->_model->getTags());
66 $this->_model->save(
'test data 1',
'test1', [
'tag1',
'tag2']);
67 $this->_model->save(
'test data 2',
'test2', [
'tag1',
'tag3']);
68 $actual = $this->_model->getTags();
69 $expected = [
'tag1',
'tag2',
'tag3'];
70 $this->assertEquals($expected, $actual);
◆ testLoad()
testLoad |
( |
|
$data, |
|
|
|
$lifetime, |
|
|
|
$doNotTestValidity, |
|
|
|
$expected |
|
) |
| |
- Parameters
-
string | $data | |
int | bool | null | $lifetime | |
bool | $doNotTestValidity | |
string | bool | $expected | @dataProvider loadDataProvider |
Definition at line 170 of file MongoDbTest.php.
173 $this->_model->save(
$data, $cacheId, [], $lifetime);
174 $actualData = $this->_model->load($cacheId, $doNotTestValidity);
175 $this->assertSame($expected, $actualData);
◆ testRemove()
Definition at line 209 of file MongoDbTest.php.
212 $this->_model->save(
'test data', $cacheId);
213 $this->assertGreaterThan(0, $this->_model->test($cacheId),
"Cache with id '{$cacheId}' has not been found");
214 $this->_model->remove($cacheId);
215 $this->assertFalse($this->_model->test($cacheId),
"Cache with id '{$cacheId}' has not been removed");
◆ testSave()
Definition at line 195 of file MongoDbTest.php.
197 $cacheId =
'test_id';
199 $tags = [
'tag1',
'tag2'];
201 $this->assertTrue($this->_model->save(
$data, $cacheId, $tags));
202 $actualData = $this->_model->load($cacheId);
203 $this->assertEquals(
$data, $actualData);
204 $actualMetadata = $this->_model->getMetadatas($cacheId);
205 $this->arrayHasKey(
'tags', $actualMetadata);
206 $this->assertEquals($tags, $actualMetadata[
'tags']);
◆ testTest()
Definition at line 188 of file MongoDbTest.php.
190 $this->assertFalse($this->_model->test(
'test'));
191 $this->_model->save(
'test data',
'test');
192 $this->assertNotEmpty($this->_model->test(
'test'),
"Cache with id 'test' has not been saved");
◆ testTouch()
testTouch |
( |
|
$extraLifeTime, |
|
|
\PHPUnit\Framework\Constraint\Constraint |
$constraint |
|
) |
| |
- Parameters
-
int | $extraLifeTime | |
\PHPUnit\Framework\Constraint\Constraint | $constraint | @dataProvider touchDataProvider |
Definition at line 145 of file MongoDbTest.php.
148 $this->_model->save(
'test data', $cacheId, [], 2);
149 $this->assertGreaterThan(0, $this->_model->test($cacheId),
"Cache with id '{$cacheId}' has not been saved");
150 $this->_model->touch($cacheId, $extraLifeTime);
152 $this->assertThat($this->_model->test($cacheId),
$constraint);
◆ touchDataProvider()
Definition at line 155 of file MongoDbTest.php.
158 'not enough extra lifetime' => [0, $this->isFalse()],
159 'enough extra lifetime' => [1000, $this->logicalNot($this->isFalse())]
◆ $_connectionString
◆ $_dbName
$_dbName = 'magento_integration_test' |
|
protected |
◆ $_model
The documentation for this class was generated from the following file:
- vendor/magento/magento2-base/dev/tests/integration/testsuite/Magento/Framework/Cache/Backend/MongoDbTest.php