-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added DBlibConfig class for "dblib" driver Update README.md Update README.md Added forgotten brackets Unit test case for DBlibConfig Changed wrong class name in DBlibConfigTest Update DBlibConfigTest.php Update DBlibConfigTest.php fix expected values in DBLibConfig unit test
- Loading branch information
1 parent
05fa6b4
commit 24b48d0
Showing
4 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace CSanquer\Silex\PdoServiceProvider\Config; | ||
|
||
/** | ||
* DBlibConfig | ||
* | ||
* @author Cristian Pascottini <[email protected]> | ||
*/ | ||
class DBlibConfig extends PdoConfig | ||
{ | ||
protected $driver = 'dblib'; | ||
|
||
protected $defaults = array( | ||
'host' => 'localhost', | ||
'port' => 1433, | ||
'MultipleActiveResultSets' => null, | ||
'password' => null, | ||
); | ||
|
||
protected $allowedTypes = array( | ||
'host' => array('string'), | ||
'port' => array('integer', 'null'), | ||
'dbname' => array('string'), | ||
'user' => array('string'), | ||
'password' => array('string', 'null'), | ||
'MultipleActiveResultSets' => array('boolean', 'null'), | ||
); | ||
|
||
protected function resolve(array $params) | ||
{ | ||
$params = parent::resolve($params); | ||
|
||
if (is_null($params['MultipleActiveResultSets'])){ | ||
unset($params['MultipleActiveResultSets']); | ||
} | ||
|
||
return $params; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace CSanquer\Silex\PdoServiceProvider\Tests\Config; | ||
|
||
use CSanquer\Silex\PdoServiceProvider\Config\DBlibConfig; | ||
|
||
/** | ||
* TestCase for DBlibConfig | ||
* | ||
* @author Cristian Pascottini <[email protected]> | ||
* | ||
*/ | ||
class DBlibConfigTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var DBlibConfig | ||
*/ | ||
protected $pdoConfig; | ||
|
||
public function setUp() | ||
{ | ||
$this->pdoConfig = new DBlibConfig(); | ||
} | ||
|
||
/** | ||
* @dataProvider dataProviderPrepareParameters | ||
*/ | ||
public function testPrepareParameters($params, $expected) | ||
{ | ||
$result = $this->pdoConfig->prepareParameters($params); | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
public function dataProviderPrepareParameters() | ||
{ | ||
return array( | ||
array( | ||
array( | ||
'dbname' => 'fake-db', | ||
'user' => 'fake-user', | ||
'password' => 'fake-password', | ||
), | ||
array( | ||
'dsn' => 'dblib:host=localhost;port=1433;dbname=fake-db', | ||
'user' => 'fake-user', | ||
'password' => 'fake-password', | ||
'options' => array(), | ||
'attributes' => array(), | ||
), | ||
), | ||
array( | ||
array( | ||
'host' => '127.0.0.1', | ||
'port' => null, | ||
'dbname' => 'fake-db', | ||
'user' => 'fake-user', | ||
'password' => 'fake-password', | ||
'attributes' => array(), | ||
), | ||
array( | ||
'dsn' => 'dblib:host=127.0.0.1;dbname=fake-db', | ||
'user' => 'fake-user', | ||
'password' => 'fake-password', | ||
'options' => array(), | ||
'attributes' => array(), | ||
), | ||
), | ||
); | ||
} | ||
} |