Skip to content

Commit

Permalink
Merge pull request #39 from kschroeder/develop
Browse files Browse the repository at this point in the history
Some fixes
  • Loading branch information
kschroeder authored Feb 22, 2017
2 parents 3fb2d35 + abe9af8 commit 3b751d3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Config/Storage/RelationalDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
AbstractContextConfigurationFile $context
)
{
$adapter->driver->getConnection()->connect(); // Force a consistent connect point
$adapter->getDriver()->getConnection()->connect(); // Force a consistent connect point
$this->adapter = $adapter;
$this->configurationFile = $context;

Expand Down
8 changes: 4 additions & 4 deletions tests/Manager/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public function testStoreCacheWorksAsExpected()

$expectedKey = hash_hmac('sha1', $xml, '');
$cache->expects(self::never())->method('removeItem');
$cache->expects(self::exactly(1))->method('addItem')->with(self::equalTo($expectedKey));
$cache->expects(self::exactly(1))->method('setItem')->with(self::equalTo($expectedCacheKey), self::equalTo($xml));
$cache->expects(self::exactly(1))->method('addItem')->with(self::equalTo($expectedKey), self::equalTo($xml));
$cache->expects(self::exactly(1))->method('setItem')->with(self::equalTo($expectedCacheKey), self::equalTo($expectedKey));
$manager->storeConfigurationObject(new Config('<config />'), 'test');
}

Expand All @@ -83,8 +83,8 @@ public function testObsoleteCachedItemIsRemoved()

$expectedKey = hash_hmac('sha1', $xml, '');
$cache->expects(self::exactly(1))->method('removeItem')->with(self::equalTo('delete-me'));
$cache->expects(self::exactly(1))->method('addItem')->with(self::equalTo($expectedKey));
$cache->expects(self::exactly(1))->method('setItem')->with(self::equalTo($expectedCacheKey), self::equalTo($xml));
$cache->expects(self::exactly(1))->method('addItem')->with(self::equalTo($expectedKey), self::equalTo($xml));
$cache->expects(self::exactly(1))->method('setItem')->with(self::equalTo($expectedCacheKey), self::equalTo($expectedKey));
$manager->storeConfigurationObject(new Config('<config />'), 'test');
}

Expand Down
9 changes: 9 additions & 0 deletions tests/Storage/CrudTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Magium\Configuration\File\Context\XmlFile;
use PHPUnit\Framework\TestCase;
use Zend\Db\Adapter\Adapter;
use Zend\Db\Adapter\Driver\ConnectionInterface;
use Zend\Db\Adapter\Driver\DriverInterface;
use Zend\Db\Adapter\Driver\ResultInterface;
use Zend\Db\Adapter\Driver\StatementInterface;
use Zend\Db\Adapter\Platform\Sqlite;
Expand Down Expand Up @@ -45,6 +47,13 @@ public function testMakeSureUpdateAndInsertAreCalledAppropriately()
$adapter->expects(self::any())->method('getPlatform')->willReturn(
new Sqlite(new \PDO('sqlite::memory:'))
);

$connection = $this->createMock(ConnectionInterface::class);

$driver = $this->createMock(DriverInterface::class);
$driver->expects(self::once())->method('getConnection')->willReturn($connection);

$adapter->expects(self::once())->method('getDriver')->willReturn($driver);
$me = $this;
$adapter->expects(self::exactly(4))->method('query')->willReturnCallback(function($param) use ($me) {
static $state = -1;
Expand Down

0 comments on commit 3b751d3

Please sign in to comment.