From ac091ac1ed61443c59f71ca121c95f481fb423cc Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Tue, 10 Jul 2012 19:38:10 +0400 Subject: [PATCH] Add CliControllerTest (not working with RuntimeException). --- tests/app/CliControllerTest.php | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/app/CliControllerTest.php diff --git a/tests/app/CliControllerTest.php b/tests/app/CliControllerTest.php new file mode 100644 index 0000000..da4ff64 --- /dev/null +++ b/tests/app/CliControllerTest.php @@ -0,0 +1,50 @@ + + * @link http://netmonsters.ru + * @package Majestic + * @subpackage Tests app + * @since 10.07.12 + * + */ + +require_once __DIR__ . '/../../util/profiler/Profiler.php'; +require_once __DIR__ . '/../../exception/GeneralException.php'; +require_once __DIR__ . '/../../exception/Error404Exception.php'; +require_once __DIR__ . '/../../exception/ErrorHandler.php'; +require_once __DIR__ . '/../../app/CliController.php'; +require_once __DIR__ . '/../../Registry.php'; +require_once __DIR__ . '/../../Config.php'; +require_once __DIR__ . '/../../app/iCli.php'; + +/** + * @desc CliController tests + * @author Aleksandr Demidov + */ +class CliControllerTest extends PHPUnit_Framework_TestCase +{ + public function _testGetInstance() + { + $instance = CliController::getInstance(); + $this->assertInstanceOf('CliController', $instance); + } + + public function _testExecute() + { + $cli_class = $this->getMockForAbstractClass('iCli', array(), '', '', '', '', array('run')); + $cli_class->expects($this->once()) + ->method('run') + ->with(); + CliController::getInstance()->execute($cli_class); + } + + /** + * @runInSeparateProcess + */ + public function testExecuteImplementError() + { + $cli_class = new StdClass(); + $this->setExpectedException('ErrorException', 'Runner "' . get_class($cli_class) . '" need implement of "iCli" interface.'); + CliController::getInstance()->execute($cli_class); + } +} \ No newline at end of file