+ /**
+ * Test the configuration get() method with different isLoaded settings
+ * @dataProvider dataTests
+ */
+ public function testGetWithoutLoaded($data)
+ {
+ $uid = 234;
+ $configCache = new PConfigCache();
+ $configAdapter = \Mockery::mock(IPConfigAdapter::class);
+ $configAdapter->shouldReceive('isConnected')->andReturn(true)->times(3);
+
+ $configAdapter->shouldReceive('isLoaded')->with($uid, 'test', 'it')->andReturn(false)->once();
+ $configAdapter->shouldReceive('get')->with($uid, 'test', 'it')->andReturn(null)->once();
+
+ $configAdapter->shouldReceive('isLoaded')->with($uid, 'test', 'it')->andReturn(false)->once();
+ $configAdapter->shouldReceive('get')->with($uid, 'test', 'it')->andReturn($data)->once();
+
+ $configAdapter->shouldReceive('isLoaded')->with($uid, 'test', 'it')->andReturn(true)->once();
+
+ $configuration = new PConfiguration($configCache, $configAdapter);
+
+ // first run is not loaded and no data is found in the DB
+ $this->assertNull($configuration->get($uid, 'test', 'it'));
+
+ // second run is not loaded, but now data is found in the db (overwrote cache)
+ $this->assertEquals($data, $configuration->get($uid,'test', 'it'));
+
+ // third run is loaded and therefore cache is used
+ $this->assertEquals($data, $configuration->get($uid,'test', 'it'));
+ }
+