]> git.mxchange.org Git - friendica.git/commitdiff
Fix PConfiguration tests
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 16 Jul 2019 04:19:04 +0000 (00:19 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 16 Jul 2019 04:19:04 +0000 (00:19 -0400)
- Replace uid = 0 (invalid uid) with 42
- Remove isConnected mocked calls for invalid uid test

tests/src/Core/Config/JitPConfigurationTest.php
tests/src/Core/Config/PConfigurationTest.php
tests/src/Core/Config/PreloadPConfigurationTest.php

index 4eafb43b3ddcacf22476d2616bb9d7cafe7f0d71..8ceea93ff46dfc94b950b247b94b3983c23675d3 100644 (file)
@@ -116,15 +116,6 @@ class JitPConfigurationTest extends PConfigurationTest
                parent::testGetWithRefresh($uid, $data);
        }
 
-       public function testGetWrongWithoutDB()
-       {
-               $this->configModel->shouldReceive('isConnected')
-                                 ->andReturn(false)
-                                 ->times(3);
-
-               parent::testGetWrongWithoutDB();
-       }
-
        /**
         * @dataProvider dataTests
         */
@@ -145,7 +136,7 @@ class JitPConfigurationTest extends PConfigurationTest
 
                // mocking one get without result
                $this->configModel->shouldReceive('get')
-                                 ->with(0, 'test', 'it')
+                                 ->with(42, 'test', 'it')
                                  ->andReturn(null)
                                  ->once();
 
index 5554731bfd9b95bf50be5d7e6a69c01658cdcfed..40c6970a5cb9bc261e3b1ffff7a1bf089e853ade 100644 (file)
@@ -365,22 +365,24 @@ abstract class PConfigurationTest extends MockedTest
         */
        public function testDeleteWithDB()
        {
-               $this->configCache->load(0, ['test' => ['it' => 'now', 'quarter' => 'true']]);
+               $uid = 42;
+
+               $this->configCache->load($uid, ['test' => ['it' => 'now', 'quarter' => 'true']]);
 
                $this->configModel->shouldReceive('delete')
-                                 ->with(0, 'test', 'it')
+                                 ->with($uid, 'test', 'it')
                                  ->andReturn(false)
                                  ->once();
                $this->configModel->shouldReceive('delete')
-                                 ->with(0, 'test', 'second')
+                                 ->with($uid, 'test', 'second')
                                  ->andReturn(true)
                                  ->once();
                $this->configModel->shouldReceive('delete')
-                                 ->with(0, 'test', 'third')
+                                 ->with($uid, 'test', 'third')
                                  ->andReturn(false)
                                  ->once();
                $this->configModel->shouldReceive('delete')
-                                 ->with(0, 'test', 'quarter')
+                                 ->with($uid, 'test', 'quarter')
                                  ->andReturn(true)
                                  ->once();
 
@@ -388,19 +390,19 @@ abstract class PConfigurationTest extends MockedTest
                $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache());
 
                // directly set the value to the cache
-               $this->testedConfig->getCache()->set(0, 'test', 'it', 'now');
+               $this->testedConfig->getCache()->set($uid, 'test', 'it', 'now');
 
-               $this->assertEquals('now', $this->testedConfig->get(0, 'test', 'it'));
-               $this->assertEquals('now', $this->testedConfig->getCache()->get(0, 'test', 'it'));
+               $this->assertEquals('now', $this->testedConfig->get($uid, 'test', 'it'));
+               $this->assertEquals('now', $this->testedConfig->getCache()->get($uid, 'test', 'it'));
 
                // delete from cache only
-               $this->assertTrue($this->testedConfig->delete(0, 'test', 'it'));
+               $this->assertTrue($this->testedConfig->delete($uid, 'test', 'it'));
                // delete from db only
-               $this->assertTrue($this->testedConfig->delete(0, 'test', 'second'));
+               $this->assertTrue($this->testedConfig->delete($uid, 'test', 'second'));
                // no delete
-               $this->assertFalse($this->testedConfig->delete(0, 'test', 'third'));
+               $this->assertFalse($this->testedConfig->delete($uid, 'test', 'third'));
                // delete both
-               $this->assertTrue($this->testedConfig->delete(0, 'test', 'quarter'));
+               $this->assertTrue($this->testedConfig->delete($uid, 'test', 'quarter'));
 
                $this->assertEmpty($this->testedConfig->getCache()->getAll());
        }
index ca916d4404099e94aaa39779dc6288fb4b060be1..270a7a2e0bf4af79712fb0254840c9e1292f94c8 100644 (file)
@@ -108,16 +108,6 @@ class PreloadPConfigurationTest extends PConfigurationTest
                parent::testGetWithRefresh($uid, $data);
        }
 
-
-       public function testGetWrongWithoutDB()
-       {
-               $this->configModel->shouldReceive('isConnected')
-                                 ->andReturn(false)
-                                 ->times(3);
-
-               parent::testGetWrongWithoutDB();
-       }
-
        /**
         * @dataProvider dataTests
         */
@@ -138,7 +128,7 @@ class PreloadPConfigurationTest extends PConfigurationTest
 
                // constructor loading
                $this->configModel->shouldReceive('load')
-                                 ->with(0)
+                                 ->with(42)
                                  ->andReturn(['config' => []])
                                  ->once();