예제 #1
0
 public function testSetDbConfig()
 {
     $dbConfig = array('uri' => 'file:///path/to/dsnfile');
     $expected = 'uri:file:///path/to/dsnfile';
     $actual = new Phigrate_Adapter_Mysql_Adapter($dbConfig, self::$_logger);
     $this->assertInstanceOf('Phigrate_Adapter_Mysql_Adapter', $actual);
     $this->assertEquals($expected, $actual->getDsn());
     $dbConfig = array('host' => 'testhost', 'database' => 'ruckutest', 'user' => 'toto', 'password' => 'pass');
     $expected = 'mysql:dbname=ruckutest;host=testhost';
     $actual = new Phigrate_Adapter_Mysql_Adapter($dbConfig, self::$_logger);
     $this->assertInstanceOf('Phigrate_Adapter_Mysql_Adapter', $actual);
     $this->assertEquals($expected, $actual->getDsn());
     $dbConfig = array('database' => 'ruckutest', 'socket' => '/tmp/mysqld.sock', 'user' => 'toto', 'password' => 'pass');
     $expected = 'mysql:dbname=ruckutest;unix_socket=/tmp/mysqld.sock';
     $actual = new Phigrate_Adapter_Mysql_Adapter($dbConfig, self::$_logger);
     $this->assertInstanceOf('Phigrate_Adapter_Mysql_Adapter', $actual);
     $this->assertEquals($expected, $actual->getDsn());
     $dbConfig = 'dbConfig';
     try {
         $this->object->setDbConfig($dbConfig);
         $this->fail('checkDbConfig do not accept string argument!');
     } catch (Phigrate_Exception_Argument $ex) {
         $msg = 'The argument dbConfig must be a array!';
         $this->assertEquals($msg, $ex->getMessage());
     }
 }