diff --git a/README.md b/README.md index 237fc0ab..cfa48937 100644 --- a/README.md +++ b/README.md @@ -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 ========== diff --git a/phpunit.xml b/phpunit.xml index 44fba5e7..c2bbf131 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -41,4 +41,9 @@ ./tests/PHPCensor/ProcessControl + + + ./src + + diff --git a/src/B8Framework/View/Template.php b/src/B8Framework/View/Template.php index 80aa1465..d58957cc 100755 --- a/src/B8Framework/View/Template.php +++ b/src/B8Framework/View/Template.php @@ -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]; diff --git a/tests/B8Framework/DatabaseTest.php b/tests/B8Framework/DatabaseTest.php index a2142668..4d1ea57c 100755 --- a/tests/B8Framework/DatabaseTest.php +++ b/tests/B8Framework/DatabaseTest.php @@ -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'); } -} \ No newline at end of file +} diff --git a/tests/B8Framework/HttpClientTest.php b/tests/B8Framework/HttpClientTest.php index 8a1d4aa3..f3aadbf3 100755 --- a/tests/B8Framework/HttpClientTest.php +++ b/tests/B8Framework/HttpClientTest.php @@ -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() diff --git a/tests/PHPCensor/Plugin/PharTest.php b/tests/PHPCensor/Plugin/PharTest.php index 21fa892b..87cb1d9b 100644 --- a/tests/PHPCensor/Plugin/PharTest.php +++ b/tests/PHPCensor/Plugin/PharTest.php @@ -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.'); } }