2016-10-07 21:11:24 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace OAuth2\Storage;
|
|
|
|
|
|
|
|
class PdoTest extends BaseTest
|
|
|
|
{
|
|
|
|
public function testCreatePdoStorageUsingPdoClass()
|
|
|
|
{
|
2019-04-09 01:35:23 +00:00
|
|
|
$dsn = sprintf('sqlite:%s', Bootstrap::getInstance()->getSqliteDir());
|
|
|
|
$pdo = new \PDO($dsn);
|
2016-10-07 21:11:24 +00:00
|
|
|
$storage = new Pdo($pdo);
|
|
|
|
|
|
|
|
$this->assertNotNull($storage->getClientDetails('oauth_test_client'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCreatePdoStorageUsingDSN()
|
|
|
|
{
|
2019-04-09 01:35:23 +00:00
|
|
|
$dsn = sprintf('sqlite:%s', Bootstrap::getInstance()->getSqliteDir());
|
2016-10-07 21:11:24 +00:00
|
|
|
$storage = new Pdo($dsn);
|
|
|
|
|
|
|
|
$this->assertNotNull($storage->getClientDetails('oauth_test_client'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCreatePdoStorageUsingConfig()
|
|
|
|
{
|
2019-04-09 01:35:23 +00:00
|
|
|
$dsn = sprintf('sqlite:%s', Bootstrap::getInstance()->getSqliteDir());
|
|
|
|
$config = array('dsn' => $dsn);
|
2016-10-07 21:11:24 +00:00
|
|
|
$storage = new Pdo($config);
|
|
|
|
|
|
|
|
$this->assertNotNull($storage->getClientDetails('oauth_test_client'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException InvalidArgumentException dsn
|
|
|
|
*/
|
|
|
|
public function testCreatePdoStorageWithoutDSNThrowsException()
|
|
|
|
{
|
|
|
|
$config = array('username' => 'brent', 'password' => 'brentisaballer');
|
|
|
|
$storage = new Pdo($config);
|
|
|
|
}
|
|
|
|
}
|