Fixed tests
This commit is contained in:
parent
143e583be8
commit
a10f760122
6 changed files with 31 additions and 12 deletions
|
|
@ -33,7 +33,7 @@ cd /path/to/php-censor
|
|||
|
||||
For Phar plugin tests set 'phar.readonly' setting to Off (0) in `php.ini` config. Otherwise tests will be skipped.
|
||||
|
||||
For database B8Framework tests create empty 'b8_test' MySQL database on 'localhost' with user/password: `root/root`.
|
||||
For database B8Framework tests create empty 'b8_test' MySQL database on 'localhost' with user/password: `root/root`. Otherwise database tests will be skipped.
|
||||
|
||||
Migrations
|
||||
==========
|
||||
|
|
|
|||
|
|
@ -41,4 +41,9 @@
|
|||
<directory suffix="Test.php">./tests/PHPCensor/ProcessControl</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
|
|
|||
|
|
@ -109,6 +109,9 @@ class Template extends View
|
|||
$current =& $parent['children'][count($parent['children']) - 1];
|
||||
$current['parent'] =& $parent;
|
||||
} else {
|
||||
if (!is_array($parent['children'][count($parent['children']) - 1]['children'])) {
|
||||
$parent['children'][count($parent['children']) - 1]['children'] = [];
|
||||
}
|
||||
$parent['children'][count($parent['children']) - 1]['children'][] = $str;
|
||||
$current =& $parent['children'][count($parent['children']) - 1]['children'][0];
|
||||
$current['parent'] =& $parent['children'][count($parent['children']) - 1];
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue