Example #1
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());
     }
 }
 /**
  * @depends testAddColumnComment
  */
 public function testRemoveColumnComment()
 {
     $table = new \Phinx\Db\Table('table1', array(), $this->adapter);
     $table->addColumn('field1', 'string', array('comment' => 'Comments from column "field1"'))->save();
     $table->changeColumn('field1', 'string', array('comment' => 'null'))->save();
     $resultComment = $this->adapter->getColumnComment('table1', 'field1');
     $this->assertEmpty($resultComment, 'Dont remove column comment correctly');
 }
 public function testInsertData()
 {
     $table = new \Phinx\Db\Table('table1', array(), $this->adapter);
     $table->addColumn('column1', 'string')->addColumn('column2', 'integer')->insert(array(array('column1' => 'value1', 'column2' => 1), array('column1' => 'value2', 'column2' => 2)))->insert(array('column1' => 'value3', 'column2' => 3))->save();
     $rows = $this->adapter->fetchAll('SELECT * FROM table1');
     $this->assertEquals('value1', $rows[0]['column1']);
     $this->assertEquals('value2', $rows[1]['column1']);
     $this->assertEquals('value3', $rows[2]['column1']);
     $this->assertEquals(1, $rows[0]['column2']);
     $this->assertEquals(2, $rows[1]['column2']);
     $this->assertEquals(3, $rows[2]['column2']);
 }