Fixed tests

This commit is contained in:
Dmitry Khomutov 2017-01-04 15:16:20 +07:00
commit a10f760122
6 changed files with 31 additions and 12 deletions

View file

@ -23,23 +23,32 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
],
]);
}
public function testGetReadConnection()
{
$connection = Database::getConnection('read');
$this->assertInstanceOf('\b8\Database', $connection);
protected function checkDatabaseConnection()
{
try {
$connection = Database::getConnection('read');
} catch (\Exception $e) {
if ('Could not connect to any read servers.' === $e->getMessage()) {
$this->markTestSkipped('Test skipped because test database doesn`t exist.');
} else {
throw $e;
}
}
}
public function testGetWriteConnection()
{
$connection = Database::getConnection('write');
$this->checkDatabaseConnection();
$connection = Database::getConnection('write');
$this->assertInstanceOf('\b8\Database', $connection);
}
public function testGetDetails()
{
$this->checkDatabaseConnection();
$details = Database::getConnection('read')->getDetails();
$this->assertTrue(is_array($details));
$this->assertTrue(($details['db'] == 'b8_test'));
@ -52,6 +61,8 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
*/
public function testConnectionFailure()
{
$this->checkDatabaseConnection();
Database::reset();
$config = new Config([
@ -70,4 +81,4 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
Database::getConnection('read');
}
}
}

View file

@ -11,7 +11,7 @@ class HttpClientTest extends \PHPUnit_Framework_TestCase
$http = new HttpClient();
$html = $http->request('GET', 'https://www.cloudflare.com/');
$this->assertContains('CloudFlare', $html['body']);
$this->assertContains('Cloudflare', $html['body']);
}
public function testBaseUrl()
@ -19,7 +19,7 @@ class HttpClientTest extends \PHPUnit_Framework_TestCase
$http = new HttpClient('https://www.cloudflare.com');
$html = $http->request('GET', '/');
$this->assertContains('CloudFlare', $html['body']);
$this->assertContains('Cloudflare', $html['body']);
}
public function testGet()
@ -27,7 +27,7 @@ class HttpClientTest extends \PHPUnit_Framework_TestCase
$http = new HttpClient('https://www.cloudflare.com');
$html = $http->get('overview', ['x' => 1]);
$this->assertContains('CloudFlare', $html['body']);
$this->assertContains('Cloudflare', $html['body']);
}
public function testGetJson()

View file

@ -86,7 +86,7 @@ class PharTest extends \PHPUnit_Framework_TestCase
protected function checkReadonly()
{
if (ini_get('phar.readonly')) {
$this->markTestSkipped('phar writing disabled in php.ini.');
$this->markTestSkipped('Test skipped because phar writing disabled in php.ini.');
}
}