lithium\tests\integration\data\source\database\adapter\MySqlTest::testDatabaseConnection PHP Method

testDatabaseConnection() public method

Tests that this adapter can connect to the database, and that the status is properly persisted.
    public function testDatabaseConnection()
    {
        $db = new MySql(array('autoConnect' => false) + $this->_dbConfig);
        $this->assertTrue($db->connect());
        $this->assertTrue($db->isConnected());
        $this->assertTrue($db->disconnect());
        $this->assertFalse($db->isConnected());
        $db = new MySQL(array('autoConnect' => false, 'encoding' => null, 'persistent' => false, 'host' => 'localhost:3306', 'login' => 'garbage', 'password' => '', 'database' => 'garbage', 'init' => true) + $this->_dbConfig);
        $this->assertException('/.*/', function () use($db) {
            $db->connect();
        });
        $this->assertFalse($db->isConnected());
        $this->assertTrue($db->disconnect());
        $this->assertFalse($db->isConnected());
    }