Skip to content

Commit

Permalink
replace deprecated method
Browse files Browse the repository at this point in the history
  • Loading branch information
koriym committed Apr 27, 2018
1 parent 5789e8c commit b9ed887
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/CakeDbModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Ray\CakeDbModule;

use Cake\Database\Connection;
use Cake\Datasource\ConnectionManager;
use Ray\Di\Injector;

Expand All @@ -14,7 +15,7 @@ public function testModule()
->getInstance('Cake\Database\Connection');

$this->assertInstanceOf('Cake\Database\Connection', $instance);
$this->assertInstanceOf('Cake\Database\Driver\Sqlite', $instance->driver());
$this->assertInstanceOf('Cake\Database\Driver\Sqlite', $instance->getDriver());
}

public function testWithDsn()
Expand All @@ -28,15 +29,17 @@ public function testWithDsn()

public function testWithPreMadeConnection()
{
ConnectionManager::config('default', [
ConnectionManager::setConfig('default', [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Sqlite'
]);
$module = new CakeDbModule('default');
/** @var Connection $instance */
$instance = (new Injector($module, $_ENV['TMP_DIR']))
->getInstance('Cake\Database\Connection');

$this->assertSame(ConnectionManager::get('default'), $instance);
$expected = ConnectionManager::getConfig('default');
$actual = $instance->config();
$this->assertSame($expected['driver'], $actual['driver']);
}

public function testTransactional()
Expand Down

0 comments on commit b9ed887

Please sign in to comment.