Refactored structure
This commit is contained in:
parent
963225382c
commit
e5164ae1dd
329 changed files with 277 additions and 457 deletions
55
tests/B8Framework/DatabaseTest.php
Executable file
55
tests/B8Framework/DatabaseTest.php
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\b8;
|
||||
|
||||
use b8\Database;
|
||||
|
||||
class DatabaseTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $_host = 'localhost';
|
||||
protected $_user = 'b8_test';
|
||||
protected $_pass = 'b8_test';
|
||||
protected $_name = 'b8_test';
|
||||
|
||||
public function testGetReadConnection()
|
||||
{
|
||||
Database::setDetails($this->_name, $this->_user, $this->_pass);
|
||||
Database::setReadServers(array($this->_host));
|
||||
|
||||
$connection = Database::getConnection('read');
|
||||
|
||||
$this->assertInstanceOf('\b8\Database', $connection);
|
||||
}
|
||||
|
||||
public function testGetWriteConnection()
|
||||
{
|
||||
Database::setDetails($this->_name, $this->_user, $this->_pass);
|
||||
Database::setWriteServers(array($this->_host));
|
||||
|
||||
$connection = Database::getConnection('write');
|
||||
|
||||
$this->assertInstanceOf('\b8\Database', $connection);
|
||||
}
|
||||
|
||||
public function testGetDetails()
|
||||
{
|
||||
Database::setDetails($this->_name, $this->_user, $this->_pass);
|
||||
Database::setReadServers(array('localhost'));
|
||||
|
||||
$details = Database::getConnection('read')->getDetails();
|
||||
$this->assertTrue(is_array($details));
|
||||
$this->assertTrue(($details['db'] == $this->_name));
|
||||
$this->assertTrue(($details['user'] == $this->_user));
|
||||
$this->assertTrue(($details['pass'] == $this->_pass));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testConnectionFailure()
|
||||
{
|
||||
Database::setDetails('non_existant', 'invalid_user', 'incorrect_password');
|
||||
Database::setReadServers(array('localhost'));
|
||||
Database::getConnection('read');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue