]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Core/Cache/MemoryCacheTest.php
Refactor ConfigMockTrait to mocked ConfigCache
[friendica.git] / tests / src / Core / Cache / MemoryCacheTest.php
index 670df2fe187ee52d4d5f811226cd9276adb5fc30..3bf2966a1331e304dad7188f50815079a0b719f4 100644 (file)
@@ -11,7 +11,7 @@ abstract class MemoryCacheTest extends CacheTest
         */
        protected $instance;
 
-       function setUp()
+       protected function setUp()
        {
                parent::setUp();
                if (!($this->instance instanceof IMemoryCacheDriver)) {
@@ -19,76 +19,88 @@ abstract class MemoryCacheTest extends CacheTest
                }
        }
 
-       function testCompareSet() {
+       /**
+        * @small
+        * @dataProvider dataSimple
+        */
+       function testCompareSet($value1, $value2) {
                $this->assertNull($this->instance->get('value1'));
 
-               $value = 'foobar';
-               $this->instance->add('value1', $value);
+               $this->instance->add('value1', $value1);
                $received = $this->instance->get('value1');
-               $this->assertEquals($value, $received, 'Value received from cache not equal to the original');
+               $this->assertEquals($value1, $received, 'Value received from cache not equal to the original');
 
-               $newValue = 'ipsum lorum';
-               $this->instance->compareSet('value1', $value, $newValue);
+               $this->instance->compareSet('value1', $value1, $value2);
                $received = $this->instance->get('value1');
-               $this->assertEquals($newValue, $received, 'Value not overwritten by compareSet');
+               $this->assertEquals($value2, $received, 'Value not overwritten by compareSet');
        }
 
-       function testNegativeCompareSet() {
+       /**
+        * @small
+        * @dataProvider dataSimple
+        */
+       function testNegativeCompareSet($value1, $value2) {
                $this->assertNull($this->instance->get('value1'));
 
-               $value = 'foobar';
-               $this->instance->add('value1', $value);
+               $this->instance->add('value1', $value1);
                $received = $this->instance->get('value1');
-               $this->assertEquals($value, $received, 'Value received from cache not equal to the original');
+               $this->assertEquals($value1, $received, 'Value received from cache not equal to the original');
 
-               $newValue = 'ipsum lorum';
-               $this->instance->compareSet('value1', 'wrong', $newValue);
+               $this->instance->compareSet('value1', 'wrong', $value2);
                $received = $this->instance->get('value1');
-               $this->assertNotEquals($newValue, $received, 'Value was wrongly overwritten by compareSet');
-               $this->assertEquals($value, $received, 'Value was wrongly overwritten by any other value');
+               $this->assertNotEquals($value2, $received, 'Value was wrongly overwritten by compareSet');
+               $this->assertEquals($value1, $received, 'Value was wrongly overwritten by any other value');
        }
 
-       function testCompareDelete() {
+       /**
+        * @small
+        * @dataProvider dataSimple
+        */
+       function testCompareDelete($data) {
                $this->assertNull($this->instance->get('value1'));
 
-               $value = 'foobar';
-               $this->instance->add('value1', $value);
+               $this->instance->add('value1', $data);
                $received = $this->instance->get('value1');
-               $this->assertEquals($value, $received, 'Value received from cache not equal to the original');
-               $this->instance->compareDelete('value1', $value);
+               $this->assertEquals($data, $received, 'Value received from cache not equal to the original');
+               $this->instance->compareDelete('value1', $data);
                $this->assertNull($this->instance->get('value1'), 'Value was not deleted by compareDelete');
        }
 
-       function testNegativeCompareDelete() {
+       /**
+        * @small
+        * @dataProvider dataSimple
+        */
+       function testNegativeCompareDelete($data) {
                $this->assertNull($this->instance->get('value1'));
 
-               $value = 'foobar';
-               $this->instance->add('value1', $value);
+               $this->instance->add('value1', $data);
                $received = $this->instance->get('value1');
-               $this->assertEquals($value, $received, 'Value received from cache not equal to the original');
+               $this->assertEquals($data, $received, 'Value received from cache not equal to the original');
                $this->instance->compareDelete('value1', 'wrong');
                $this->assertNotNull($this->instance->get('value1'), 'Value was wrongly compareDeleted');
 
-               $this->instance->compareDelete('value1', $value);
+               $this->instance->compareDelete('value1', $data);
                $this->assertNull($this->instance->get('value1'), 'Value was wrongly NOT deleted by compareDelete');
        }
 
-       function testAdd() {
+       /**
+        * @small
+        * @dataProvider dataSimple
+        */
+       function testAdd($value1, $value2) {
                $this->assertNull($this->instance->get('value1'));
 
-               $value = 'foobar';
-               $this->instance->add('value1', $value);
+               $this->instance->add('value1', $value1);
 
-               $newValue = 'ipsum lorum';
-               $this->instance->add('value1', $newValue);
+               $this->instance->add('value1', $value2);
                $received = $this->instance->get('value1');
-               $this->assertNotEquals($newValue, $received, 'Value was wrongly overwritten by add');
-               $this->assertEquals($value, $received, 'Value was wrongly overwritten by any other value');
+               $this->assertNotEquals($value2, $received, 'Value was wrongly overwritten by add');
+               $this->assertEquals($value1, $received, 'Value was wrongly overwritten by any other value');
 
                $this->instance->delete('value1');
-               $this->instance->add('value1', $newValue);
+               $this->instance->add('value1', $value2);
                $received = $this->instance->get('value1');
-               $this->assertEquals($newValue, $received, 'Value was not overwritten by add');
-               $this->assertNotEquals($value, $received, 'Value was not overwritten by any other value');
+               $this->assertEquals($value2, $received, 'Value was not overwritten by add');
+               $this->assertNotEquals($value1, $received, 'Value was not overwritten by any other value');
        }
 }
\ No newline at end of file