|
|
|
@ -3,6 +3,8 @@
|
|
|
|
|
namespace yiiunit\extensions\mongo; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use yii\mongo\Connection; |
|
|
|
|
|
|
|
|
|
class ConnectionTest extends MongoTestCase |
|
|
|
|
{ |
|
|
|
|
public function testConstruct() |
|
|
|
@ -13,7 +15,28 @@ class ConnectionTest extends MongoTestCase
|
|
|
|
|
$connection->open(); |
|
|
|
|
|
|
|
|
|
$this->assertEquals($params['dsn'], $connection->dsn); |
|
|
|
|
//$this->assertEquals($params['username'], $connection->username); |
|
|
|
|
//$this->assertEquals($params['password'], $connection->password); |
|
|
|
|
$this->assertEquals($params['dbName'], $connection->dbName); |
|
|
|
|
$this->assertEquals($params['options'], $connection->options); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testOpenClose() |
|
|
|
|
{ |
|
|
|
|
$connection = $this->getConnection(false, false); |
|
|
|
|
|
|
|
|
|
$this->assertFalse($connection->isActive); |
|
|
|
|
$this->assertEquals(null, $connection->client); |
|
|
|
|
|
|
|
|
|
$connection->open(); |
|
|
|
|
$this->assertTrue($connection->isActive); |
|
|
|
|
$this->assertTrue(is_object($connection->client)); |
|
|
|
|
|
|
|
|
|
$connection->close(); |
|
|
|
|
$this->assertFalse($connection->isActive); |
|
|
|
|
$this->assertEquals(null, $connection->client); |
|
|
|
|
|
|
|
|
|
$connection = new Connection; |
|
|
|
|
$connection->dsn = 'unknown::memory:'; |
|
|
|
|
$this->setExpectedException('yii\db\Exception'); |
|
|
|
|
$connection->open(); |
|
|
|
|
} |
|
|
|
|
} |