You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.0 KiB
42 lines
1.0 KiB
11 years ago
|
<?php
|
||
|
|
||
|
namespace yiiunit\extensions\sphinx;
|
||
|
|
||
|
use yii\sphinx\Connection;
|
||
|
|
||
|
/**
|
||
|
* @group sphinx
|
||
|
*/
|
||
|
class ConnectionTest extends SphinxTestCase
|
||
|
{
|
||
|
public function testConstruct()
|
||
|
{
|
||
|
$connection = $this->getConnection(false);
|
||
|
$params = $this->sphinxConfig;
|
||
|
|
||
|
$this->assertEquals($params['dsn'], $connection->dsn);
|
||
|
$this->assertEquals($params['username'], $connection->username);
|
||
|
$this->assertEquals($params['password'], $connection->password);
|
||
|
}
|
||
|
|
||
|
public function testOpenClose()
|
||
|
{
|
||
|
$connection = $this->getConnection(false, false);
|
||
|
|
||
|
$this->assertFalse($connection->isActive);
|
||
|
$this->assertEquals(null, $connection->pdo);
|
||
|
|
||
|
$connection->open();
|
||
|
$this->assertTrue($connection->isActive);
|
||
|
$this->assertTrue($connection->pdo instanceof \PDO);
|
||
|
|
||
|
$connection->close();
|
||
|
$this->assertFalse($connection->isActive);
|
||
|
$this->assertEquals(null, $connection->pdo);
|
||
|
|
||
|
$connection = new Connection;
|
||
|
$connection->dsn = 'unknown::memory:';
|
||
|
$this->setExpectedException('yii\db\Exception');
|
||
|
$connection->open();
|
||
|
}
|
||
|
}
|