Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | namespace OAuth2\Storage; |
| 4 | |
| 5 | class PdoTest extends BaseTest |
| 6 | { |
| 7 | public function testCreatePdoStorageUsingPdoClass() |
| 8 | { |
| 9 | $dsn = sprintf('sqlite:%s', Bootstrap::getInstance()->getSqliteDir()); |
| 10 | $pdo = new \PDO($dsn); |
| 11 | $storage = new Pdo($pdo); |
| 12 | |
| 13 | $this->assertNotNull($storage->getClientDetails('oauth_test_client')); |
| 14 | } |
| 15 | |
| 16 | public function testCreatePdoStorageUsingDSN() |
| 17 | { |
| 18 | $dsn = sprintf('sqlite:%s', Bootstrap::getInstance()->getSqliteDir()); |
| 19 | $storage = new Pdo($dsn); |
| 20 | |
| 21 | $this->assertNotNull($storage->getClientDetails('oauth_test_client')); |
| 22 | } |
| 23 | |
| 24 | public function testCreatePdoStorageUsingConfig() |
| 25 | { |
| 26 | $dsn = sprintf('sqlite:%s', Bootstrap::getInstance()->getSqliteDir()); |
| 27 | $config = array('dsn' => $dsn); |
| 28 | $storage = new Pdo($config); |
| 29 | |
| 30 | $this->assertNotNull($storage->getClientDetails('oauth_test_client')); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * @expectedException InvalidArgumentException dsn |
| 35 | */ |
| 36 | public function testCreatePdoStorageWithoutDSNThrowsException() |
| 37 | { |
| 38 | $config = array('username' => 'brent', 'password' => 'brentisaballer'); |
| 39 | $storage = new Pdo($config); |
| 40 | } |
| 41 | } |