From 338b334254f6bb1a4bd0e28c3ecad229d93f7eb8 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 27 Nov 2014 03:39:00 +0300 Subject: [PATCH] Improved console controller tests --- .../controllers/EchoMigrateController.php | 18 +++++++++++++++++ .../controllers/MigrateControllerTest.php | 3 +-- .../controllers/CacheControllerTest.php | 15 +++----------- .../controllers/EchoMigrateController.php | 18 +++++++++++++++++ .../controllers/MigrateControllerTest.php | 2 +- .../controllers/SilencedCacheController.php | 20 +++++++++++++++++++ 6 files changed, 61 insertions(+), 15 deletions(-) create mode 100644 tests/unit/extensions/mongodb/console/controllers/EchoMigrateController.php create mode 100644 tests/unit/framework/console/controllers/EchoMigrateController.php create mode 100644 tests/unit/framework/console/controllers/SilencedCacheController.php diff --git a/tests/unit/extensions/mongodb/console/controllers/EchoMigrateController.php b/tests/unit/extensions/mongodb/console/controllers/EchoMigrateController.php new file mode 100644 index 0000000000..3d5cc0c818 --- /dev/null +++ b/tests/unit/extensions/mongodb/console/controllers/EchoMigrateController.php @@ -0,0 +1,18 @@ +migrateControllerClass = MigrateController::className(); + $this->migrateControllerClass = EchoMigrateController::className(); $this->migrationBaseClass = Migration::className(); parent::setUp(); diff --git a/tests/unit/framework/console/controllers/CacheControllerTest.php b/tests/unit/framework/console/controllers/CacheControllerTest.php index 8c031cd2ef..714c6f150e 100644 --- a/tests/unit/framework/console/controllers/CacheControllerTest.php +++ b/tests/unit/framework/console/controllers/CacheControllerTest.php @@ -16,7 +16,7 @@ class CacheControllerTest extends TestCase { /** - * @var \yiiunit\framework\console\controllers\CacheConsoledController + * @var SilencedCacheController */ private $_cacheController; @@ -27,7 +27,7 @@ class CacheControllerTest extends TestCase parent::setUp(); $this->_cacheController = Yii::createObject([ - 'class' => 'yiiunit\framework\console\controllers\CacheConsoledController', + 'class' => 'yiiunit\framework\console\controllers\SilencedCacheController', 'interactive' => false, ],[null, null]); //id and module are null @@ -122,7 +122,7 @@ class CacheControllerTest extends TestCase } /** - * @expectedException yii\console\Exception + * @expectedException \yii\console\Exception */ public function testNothingToFlushException() { @@ -141,12 +141,3 @@ class CacheControllerTest extends TestCase } } - -class CacheConsoledController extends CacheController -{ - - public function stdout($string) - { - } - -} diff --git a/tests/unit/framework/console/controllers/EchoMigrateController.php b/tests/unit/framework/console/controllers/EchoMigrateController.php new file mode 100644 index 0000000000..9e362bd80b --- /dev/null +++ b/tests/unit/framework/console/controllers/EchoMigrateController.php @@ -0,0 +1,18 @@ +migrateControllerClass = MigrateController::className(); + $this->migrateControllerClass = EchoMigrateController::className(); $this->migrationBaseClass = Migration::className(); $this->mockApplication([ diff --git a/tests/unit/framework/console/controllers/SilencedCacheController.php b/tests/unit/framework/console/controllers/SilencedCacheController.php new file mode 100644 index 0000000000..40eed6ee29 --- /dev/null +++ b/tests/unit/framework/console/controllers/SilencedCacheController.php @@ -0,0 +1,20 @@ +