| @@ 56-78 (lines=23) @@ | ||
| 53 | $this->assertTrue($this->adapter->getConnection() instanceof \PDO); |
|
| 54 | } |
|
| 55 | ||
| 56 | public function testConnectionWithInvalidCredentials() |
|
| 57 | { |
|
| 58 | $options = array( |
|
| 59 | 'host' => TESTS_PHINX_DB_ADAPTER_MYSQL_HOST, |
|
| 60 | 'name' => TESTS_PHINX_DB_ADAPTER_MYSQL_DATABASE, |
|
| 61 | 'port' => TESTS_PHINX_DB_ADAPTER_MYSQL_PORT, |
|
| 62 | 'user' => 'invaliduser', |
|
| 63 | 'pass' => 'invalidpass' |
|
| 64 | ); |
|
| 65 | ||
| 66 | try { |
|
| 67 | $adapter = new MysqlAdapter($options, new NullOutput()); |
|
| 68 | $adapter->connect(); |
|
| 69 | $this->fail('Expected the adapter to throw an exception'); |
|
| 70 | } catch (\InvalidArgumentException $e) { |
|
| 71 | $this->assertInstanceOf( |
|
| 72 | 'InvalidArgumentException', |
|
| 73 | $e, |
|
| 74 | 'Expected exception of type InvalidArgumentException, got ' . get_class($e) |
|
| 75 | ); |
|
| 76 | $this->assertRegExp('/There was a problem connecting to the database/', $e->getMessage()); |
|
| 77 | } |
|
| 78 | } |
|
| 79 | ||
| 80 | public function testConnectionWithSocketConnection() |
|
| 81 | { |
|
| @@ 56-78 (lines=23) @@ | ||
| 53 | $this->assertTrue($this->adapter->getConnection() instanceof \PDO); |
|
| 54 | } |
|
| 55 | ||
| 56 | public function testConnectionWithInvalidCredentials() |
|
| 57 | { |
|
| 58 | $options = array( |
|
| 59 | 'host' => TESTS_PHINX_DB_ADAPTER_SQLSRV_HOST, |
|
| 60 | 'name' => TESTS_PHINX_DB_ADAPTER_SQLSRV_DATABASE, |
|
| 61 | 'port' => TESTS_PHINX_DB_ADAPTER_SQLSRV_PORT, |
|
| 62 | 'user' => 'invaliduser', |
|
| 63 | 'pass' => 'invalidpass' |
|
| 64 | ); |
|
| 65 | ||
| 66 | try { |
|
| 67 | $adapter = new SqlServerAdapter($options, new NullOutput()); |
|
| 68 | $adapter->connect(); |
|
| 69 | $this->fail('Expected the adapter to throw an exception'); |
|
| 70 | } catch (\InvalidArgumentException $e) { |
|
| 71 | $this->assertInstanceOf( |
|
| 72 | 'InvalidArgumentException', |
|
| 73 | $e, |
|
| 74 | 'Expected exception of type InvalidArgumentException, got ' . get_class($e) |
|
| 75 | ); |
|
| 76 | $this->assertRegExp('/There was a problem connecting to the database/', $e->getMessage()); |
|
| 77 | } |
|
| 78 | } |
|
| 79 | ||
| 80 | public function testCreatingTheSchemaTableOnConnect() |
|
| 81 | { |
|
| @@ 79-101 (lines=23) @@ | ||
| 76 | $this->assertTrue($this->adapter->getConnection() instanceof \PDO); |
|
| 77 | } |
|
| 78 | ||
| 79 | public function testConnectionWithInvalidCredentials() |
|
| 80 | { |
|
| 81 | $options = array( |
|
| 82 | 'host' => TESTS_PHINX_DB_ADAPTER_POSTGRES_HOST, |
|
| 83 | 'name' => TESTS_PHINX_DB_ADAPTER_POSTGRES_DATABASE, |
|
| 84 | 'port' => TESTS_PHINX_DB_ADAPTER_POSTGRES_PORT, |
|
| 85 | 'user' => 'invaliduser', |
|
| 86 | 'pass' => 'invalidpass' |
|
| 87 | ); |
|
| 88 | ||
| 89 | try { |
|
| 90 | $adapter = new PostgresAdapter($options, new NullOutput()); |
|
| 91 | $adapter->connect(); |
|
| 92 | $this->fail('Expected the adapter to throw an exception'); |
|
| 93 | } catch (\InvalidArgumentException $e) { |
|
| 94 | $this->assertInstanceOf( |
|
| 95 | 'InvalidArgumentException', |
|
| 96 | $e, |
|
| 97 | 'Expected exception of type InvalidArgumentException, got ' . get_class($e) |
|
| 98 | ); |
|
| 99 | $this->assertRegExp('/There was a problem connecting to the database/', $e->getMessage()); |
|
| 100 | } |
|
| 101 | } |
|
| 102 | ||
| 103 | public function testCreatingTheSchemaTableOnConnect() |
|
| 104 | { |
|