From ee8bb3c2f98c1cc8a7ca04302165ab013cd5a987 Mon Sep 17 00:00:00 2001 From: Jakub Turek Date: Sat, 21 Feb 2015 16:45:26 +0100 Subject: [PATCH] Move "setUpConsoleStatics" into the BaseClass --- .../Command/BuiltIn/ListCommandTest.php | 23 +------------------ tests/MageTest/TestHelper/BaseTest.php | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/tests/MageTest/Command/BuiltIn/ListCommandTest.php b/tests/MageTest/Command/BuiltIn/ListCommandTest.php index 06fc7fc..19fc78f 100644 --- a/tests/MageTest/Command/BuiltIn/ListCommandTest.php +++ b/tests/MageTest/Command/BuiltIn/ListCommandTest.php @@ -51,29 +51,8 @@ class ListCommandTest extends BaseTest ->build(); $this->scandirMock->disable(); $this->scandirMock->enable(); - } - /** - * Disable logging to log file and turn off colors - * - * @before - */ - public function setUpConsoleStatics() - { - $consoleReflection = new \ReflectionClass('Mage\Console'); - $logEnableProperty = $consoleReflection->getProperty('logEnabled'); - $logEnableProperty->setAccessible(true); - $logEnableProperty->setValue(false); - - $configMock = $this->getMock('Mage\Config'); - $configMock->expects($this->atLeastOnce()) - ->method('getParameter') - ->with('no-color') - ->willReturn(true); - - $configProperty = $consoleReflection->getProperty('config'); - $configProperty->setAccessible(true); - $configProperty->setValue($configMock); + $this->setUpConsoleStatics(); } public function listEnvironmentsProvider() diff --git a/tests/MageTest/TestHelper/BaseTest.php b/tests/MageTest/TestHelper/BaseTest.php index c0b974e..52dd372 100644 --- a/tests/MageTest/TestHelper/BaseTest.php +++ b/tests/MageTest/TestHelper/BaseTest.php @@ -42,4 +42,27 @@ abstract class BaseTest extends \PHPUnit_Framework_TestCase $configProperty->setAccessible(true); $configProperty->setValue($object, $value); } + + /** + * Disable logging to log file and turn off colors + * + * @before + */ + protected function setUpConsoleStatics() + { + $consoleReflection = new \ReflectionClass('Mage\Console'); + $logEnableProperty = $consoleReflection->getProperty('logEnabled'); + $logEnableProperty->setAccessible(true); + $logEnableProperty->setValue(false); + + $configMock = $this->getMock('Mage\Config'); + $configMock->expects($this->any()) + ->method('getParameter') + ->with('no-color') + ->willReturn(true); + + $configProperty = $consoleReflection->getProperty('config'); + $configProperty->setAccessible(true); + $configProperty->setValue($configMock); + } }