public function testCreatingTheSchemaTableOnConnect()
 {
     $this->adapter->connect();
     $this->assertTrue($this->adapter->hasTable($this->adapter->getSchemaTableName()));
     $this->adapter->dropTable($this->adapter->getSchemaTableName());
     $this->assertFalse($this->adapter->hasTable($this->adapter->getSchemaTableName()));
     $this->adapter->disconnect();
     $this->adapter->connect();
     $this->assertTrue($this->adapter->hasTable($this->adapter->getSchemaTableName()));
 }
示例#2
0
 public function testConnectionWithInvalidCredentials()
 {
     $options = array('host' => TESTS_PHINX_DB_ADAPTER_SQLSRV_HOST, 'name' => TESTS_PHINX_DB_ADAPTER_SQLSRV_DATABASE, 'port' => TESTS_PHINX_DB_ADAPTER_SQLSRV_PORT, 'user' => 'invaliduser', 'pass' => 'invalidpass');
     try {
         $adapter = new SqlServerAdapter($options, new NullOutput());
         $adapter->connect();
         $this->fail('Expected the adapter to throw an exception');
     } catch (\InvalidArgumentException $e) {
         $this->assertInstanceOf('InvalidArgumentException', $e, 'Expected exception of type InvalidArgumentException, got ' . get_class($e));
         $this->assertRegExp('/There was a problem connecting to the database/', $e->getMessage());
     }
 }
示例#3
0
 public function testSchemaTableIsCreatedWithPrimaryKey()
 {
     $this->adapter->connect();
     $table = new \Phinx\Db\Table($this->adapter->getSchemaTableName(), array(), $this->adapter);
     $this->assertTrue($this->adapter->hasIndex($this->adapter->getSchemaTableName(), array('version')));
 }