Commit b12db241 authored by till's avatar till

Enhancement: small test case

 * test case to assert the connection timeout is set
 * test case to assert on exceptions thrown
   * wip, as it seems impossible to trigger 'false' from mysqli_options
parent ae971994
<?php
namespace Doctrine\Tests\DBAL\Functional\Mysqli;
require_once __DIR__ . '/../../../TestInit.php';
class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
{
public function setUp()
{
if (!extension_loaded('mysqli')) {
$this->markTestSkipped('mysqli is not installed.');
}
$this->resetSharedConn();
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
$this->resetSharedConn();
}
public function testDriverOptions()
{
$driverOptions = array(
\MYSQLI_OPT_CONNECT_TIMEOUT => 1,
);
$connection = $this->getConnection($driverOptions);
$this->assertInstanceOf("\Doctrine\DBAL\Driver\Mysqli\MysqliConnection", $connection);
}
/**
* @expectedException \Doctrine\DBAL\Driver\Mysqli\MysqliException
*/
public function testUnsupportedDriverOption()
{
$this->getConnection(array('hello' => 'world')); // use local infile
}
private function getConnection(array $driverOptions)
{
return new \Doctrine\DBAL\Driver\Mysqli\MysqliConnection(
array(
'host' => $GLOBALS['db_host'],
'dbname' => $GLOBALS['db_name'],
),
$GLOBALS['db_username'],
$GLOBALS['db_password'],
$driverOptions
);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment