blob: 4599f69bf3a6ec6484d571ebb29cc33d1a7ad4c1 [file] [log] [blame]
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01001<?php
2
3namespace OAuth2\Storage;
4
5class 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}