Fix PConfiguration tests

- Replace uid = 0 (invalid uid) with 42
- Remove isConnected mocked calls for invalid uid test
This commit is contained in:
Hypolite Petovan 2019-07-16 00:19:04 -04:00
parent cf70d0beb4
commit ea6b02a1f5
3 changed files with 16 additions and 33 deletions

View file

@ -116,15 +116,6 @@ class JitPConfigurationTest extends PConfigurationTest
parent::testGetWithRefresh($uid, $data); parent::testGetWithRefresh($uid, $data);
} }
public function testGetWrongWithoutDB()
{
$this->configModel->shouldReceive('isConnected')
->andReturn(false)
->times(3);
parent::testGetWrongWithoutDB();
}
/** /**
* @dataProvider dataTests * @dataProvider dataTests
*/ */
@ -145,7 +136,7 @@ class JitPConfigurationTest extends PConfigurationTest
// mocking one get without result // mocking one get without result
$this->configModel->shouldReceive('get') $this->configModel->shouldReceive('get')
->with(0, 'test', 'it') ->with(42, 'test', 'it')
->andReturn(null) ->andReturn(null)
->once(); ->once();

View file

@ -365,22 +365,24 @@ abstract class PConfigurationTest extends MockedTest
*/ */
public function testDeleteWithDB() 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') $this->configModel->shouldReceive('delete')
->with(0, 'test', 'it') ->with($uid, 'test', 'it')
->andReturn(false) ->andReturn(false)
->once(); ->once();
$this->configModel->shouldReceive('delete') $this->configModel->shouldReceive('delete')
->with(0, 'test', 'second') ->with($uid, 'test', 'second')
->andReturn(true) ->andReturn(true)
->once(); ->once();
$this->configModel->shouldReceive('delete') $this->configModel->shouldReceive('delete')
->with(0, 'test', 'third') ->with($uid, 'test', 'third')
->andReturn(false) ->andReturn(false)
->once(); ->once();
$this->configModel->shouldReceive('delete') $this->configModel->shouldReceive('delete')
->with(0, 'test', 'quarter') ->with($uid, 'test', 'quarter')
->andReturn(true) ->andReturn(true)
->once(); ->once();
@ -388,19 +390,19 @@ abstract class PConfigurationTest extends MockedTest
$this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache()); $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache());
// directly set the value to the cache // 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->get($uid, 'test', 'it'));
$this->assertEquals('now', $this->testedConfig->getCache()->get(0, 'test', 'it')); $this->assertEquals('now', $this->testedConfig->getCache()->get($uid, 'test', 'it'));
// delete from cache only // delete from cache only
$this->assertTrue($this->testedConfig->delete(0, 'test', 'it')); $this->assertTrue($this->testedConfig->delete($uid, 'test', 'it'));
// delete from db only // delete from db only
$this->assertTrue($this->testedConfig->delete(0, 'test', 'second')); $this->assertTrue($this->testedConfig->delete($uid, 'test', 'second'));
// no delete // no delete
$this->assertFalse($this->testedConfig->delete(0, 'test', 'third')); $this->assertFalse($this->testedConfig->delete($uid, 'test', 'third'));
// delete both // delete both
$this->assertTrue($this->testedConfig->delete(0, 'test', 'quarter')); $this->assertTrue($this->testedConfig->delete($uid, 'test', 'quarter'));
$this->assertEmpty($this->testedConfig->getCache()->getAll()); $this->assertEmpty($this->testedConfig->getCache()->getAll());
} }

View file

@ -108,16 +108,6 @@ class PreloadPConfigurationTest extends PConfigurationTest
parent::testGetWithRefresh($uid, $data); parent::testGetWithRefresh($uid, $data);
} }
public function testGetWrongWithoutDB()
{
$this->configModel->shouldReceive('isConnected')
->andReturn(false)
->times(3);
parent::testGetWrongWithoutDB();
}
/** /**
* @dataProvider dataTests * @dataProvider dataTests
*/ */
@ -138,7 +128,7 @@ class PreloadPConfigurationTest extends PConfigurationTest
// constructor loading // constructor loading
$this->configModel->shouldReceive('load') $this->configModel->shouldReceive('load')
->with(0) ->with(42)
->andReturn(['config' => []]) ->andReturn(['config' => []])
->once(); ->once();