From 766cce1fbc19a74ce7841bad448e861b8c5c6809 Mon Sep 17 00:00:00 2001 From: Anton Terekhov Date: Wed, 21 Nov 2012 21:02:13 +0400 Subject: [PATCH 1/5] @codeCoverageIgnoreStart for private __clone() --- Registry.php | 14 ++++++++++++-- app/CliController.php | 5 +++++ app/FrontController.php | 8 +++++++- session/Session.php | 14 ++++++++++++-- util/profiler/Profiler.php | 5 +++++ 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/Registry.php b/Registry.php index 69727c3..89fee9f 100644 --- a/Registry.php +++ b/Registry.php @@ -32,8 +32,18 @@ class Registry extends ArrayObject { parent::__construct($array, $flags); } - - private function __clone(){} + + /** + * Refuse clone + * @codeCoverageIgnoreStart + */ + private function __clone() + { + } + + /** + * @codeCoverageIgnoreStart + */ /** * Retrieves the default registry instance. diff --git a/app/CliController.php b/app/CliController.php index 768a69e..33bd2ce 100644 --- a/app/CliController.php +++ b/app/CliController.php @@ -29,12 +29,17 @@ class CliController /** * Refuse cloning + * @codeCoverageIgnoreStart */ private function __clone() { } /** + * @codeCoverageIgnoreEnd + */ + + /** * @static * @return CliController */ diff --git a/app/FrontController.php b/app/FrontController.php index 43bbec9..2fe5889 100644 --- a/app/FrontController.php +++ b/app/FrontController.php @@ -35,12 +35,17 @@ class FrontController /** * Refuse cloning + * @codeCoverageIgnoreStart */ private function __clone() { } /** + * @codeCoverageIgnoreEnd + */ + + /** * @return FrontController */ static public function getInstance() @@ -128,7 +133,8 @@ class FrontController } } return $html; - } catch (Exception $e) { + } + catch (Exception $e) { if (Config::get('DEBUG')) { if (!headers_sent()) { if ($e instanceof ErrorHTTPException) { diff --git a/session/Session.php b/session/Session.php index 9af7724..20e286c 100644 --- a/session/Session.php +++ b/session/Session.php @@ -21,14 +21,24 @@ class Session /** * Avoid new + * @codeCoverageIgnoreStart */ private function __construct(){} - + + /** + * @codeCoverageIgnoreEnd + */ + /** * Avoid cloning + * @codeCoverageIgnoreStart */ private function __clone(){} - + + /** + * @codeCoverageIgnoreEnd + */ + /** * Retrieve a member of the $_SESSION * diff --git a/util/profiler/Profiler.php b/util/profiler/Profiler.php index e72fb8a..8f062fa 100644 --- a/util/profiler/Profiler.php +++ b/util/profiler/Profiler.php @@ -36,12 +36,17 @@ class Profiler /** * Refuse cloning + * @codeCoverageIgnoreStart */ private function __clone() { } /** + * @codeCoverageIgnoreStart + */ + + /** * @return Profiler */ static public function getInstance() From f7b6837b9105b3c009551d5adbaed8c66eab3f9e Mon Sep 17 00:00:00 2001 From: Anton Terekhov Date: Wed, 21 Nov 2012 21:18:11 +0400 Subject: [PATCH 2/5] Test logging from CliController --- tests/app/CliControllerTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/app/CliControllerTest.php b/tests/app/CliControllerTest.php index bfbabfb..07e7c6c 100644 --- a/tests/app/CliControllerTest.php +++ b/tests/app/CliControllerTest.php @@ -17,6 +17,8 @@ require_once __DIR__ . '/../../app/CliController.php'; require_once __DIR__ . '/../../Registry.php'; require_once __DIR__ . '/../../Config.php'; require_once __DIR__ . '/../../app/iCli.php'; +require_once __DIR__ . '/../../logger/Logger.php'; +require_once __DIR__ . '/../../logger/CliLogger.php'; /** * @desc CliController tests @@ -55,6 +57,22 @@ class CliControllerTest extends PHPUnit_Framework_TestCase $this->assertContains('Elapsed time:', $output); } + + public function testExecuteWithLogger() + { + ob_start(); + Config::set('PROFILER', true); + Config::set('LOGGING', true); + Config::set('Logger', array('logger' => 'CliLogger')); + $cli_class = $this->getMockForAbstractClass('iCli', array(), '', '', '', '', array('run')); + $cli_class->expects($this->once()) + ->method('run') + ->with(); + CliController::getInstance()->execute($cli_class); + $output = ob_get_clean(); + $this->assertContains('Elapsed time:', $output); + } + /** * @runInSeparateProcess */ From 2ee61dc42c030a66d794d90e63bfef855ca42cec Mon Sep 17 00:00:00 2001 From: Anton Terekhov Date: Wed, 21 Nov 2012 21:34:09 +0400 Subject: [PATCH 3/5] Small test for Load::setExclude --- tests/LoadTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/LoadTest.php b/tests/LoadTest.php index a70e8cb..c0a1d1a 100644 --- a/tests/LoadTest.php +++ b/tests/LoadTest.php @@ -170,6 +170,23 @@ class LoadTest extends PHPUnit_Framework_TestCase Load::autoload('DbDriver'); } + /** + * @runInSeparateProcess + */ + public function testSetExclude() + { + $reflection_prop = new ReflectionProperty('Load', 'exclude'); + $reflection_prop->setAccessible(true); + $this->assertCount(0, $reflection_prop->getValue('Load')); + Load::setExclude('dir1'); + $this->assertCount(1, $reflection_prop->getValue('Load')); + Load::setExclude(array('dir2')); + $this->assertCount(2, $reflection_prop->getValue('Load')); + + $this->assertSame(array('dir1', 'dir2'), $reflection_prop->getValue('Load')); + + } + protected function newCallback($className) { From b261538286f6b5d5684d54cb9b4b30c2dcbe29c9 Mon Sep 17 00:00:00 2001 From: Anton Terekhov Date: Wed, 21 Nov 2012 21:49:18 +0400 Subject: [PATCH 4/5] Removed dead code, `explode` will only return `false` if delimiter is empty string. In such a case `explode` will trigger warning --- model/SqlDbDriver.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/model/SqlDbDriver.php b/model/SqlDbDriver.php index ec62c49..1952136 100644 --- a/model/SqlDbDriver.php +++ b/model/SqlDbDriver.php @@ -109,9 +109,6 @@ abstract class SqlDbDriver extends DbDriver public function quoteIdentifier($ident) { $ident = explode('.', $ident); - if (!is_array($ident)) { - $ident = array($ident); - } foreach ($ident as &$segment) { $segment = $this->identifier_quote . $segment . $this->identifier_quote; } From 431fb8b60f75b8f16023d345f4b0ac7d1b404bfd Mon Sep 17 00:00:00 2001 From: Anton Terekhov Date: Wed, 21 Nov 2012 22:00:03 +0400 Subject: [PATCH 5/5] PHPDoc for MySQLiStatementTest --- tests/model/MySQLiStatementTest.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/model/MySQLiStatementTest.php b/tests/model/MySQLiStatementTest.php index 2a66c89..ad1f8da 100644 --- a/tests/model/MySQLiStatementTest.php +++ b/tests/model/MySQLiStatementTest.php @@ -23,9 +23,14 @@ require_once dirname(__FILE__) . '/../../exception/GeneralException.php'; class MySQLiStatementTest extends PHPUnit_Framework_TestCase { - + /** + * @var MySQLiDriver|PHPUnit_Framework_MockObject_MockObject + */ private $driver; + /** + * @var MySQLiStatement + */ private $stmt; private $sql;