From 17907235acece13a202071cd43a4991fc1ed3cb7 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Fri, 2 Jan 2015 15:28:13 +0100 Subject: [PATCH 1/4] test added for VersionCommand --- .../Command/BuildIn/VersionCommandTest.php | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/MageTest/Command/BuildIn/VersionCommandTest.php diff --git a/tests/MageTest/Command/BuildIn/VersionCommandTest.php b/tests/MageTest/Command/BuildIn/VersionCommandTest.php new file mode 100644 index 0000000..4b3f1bf --- /dev/null +++ b/tests/MageTest/Command/BuildIn/VersionCommandTest.php @@ -0,0 +1,44 @@ +workAroundStatic(); + $command = new VersionCommand(); + $command->run(); + + $this->expectOutputString('Running Magallanes version ' . MAGALLANES_VERSION . str_repeat(PHP_EOL, 2)); + } + + /** + * This is only needed as long as Console-class has static methods and properties + */ + private function workAroundStatic() + { + $refClass = new \ReflectionClass('Mage\Console'); + + $refProperty = $refClass->getProperty('logEnabled'); + $refProperty->setAccessible(true); + $refProperty->setValue(false); + + $config = $this->getMock('Mage\Config'); + $config->expects($this->once()) + ->method('getParameter') + ->will($this->returnValue(true)); + + $refProperty = $refClass->getProperty('config'); + $refProperty->setAccessible(true); + $refProperty->setValue($config); + } +} From ee6c3858ac3033aa59f376ff2e1de4a7b630e7f8 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Fri, 2 Jan 2015 16:24:25 +0100 Subject: [PATCH 2/4] setting constant in phpunit config --- phpunit.xml.dist | 4 ++++ tests/MageTest/Command/BuildIn/VersionCommandTest.php | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a5e1c3b..3825b11 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,5 +15,9 @@ src + + + + diff --git a/tests/MageTest/Command/BuildIn/VersionCommandTest.php b/tests/MageTest/Command/BuildIn/VersionCommandTest.php index 4b3f1bf..6002d5a 100644 --- a/tests/MageTest/Command/BuildIn/VersionCommandTest.php +++ b/tests/MageTest/Command/BuildIn/VersionCommandTest.php @@ -13,7 +13,6 @@ class VersionCommandTest extends PHPUnit_Framework_TestCase { public function testRun() { - define('MAGALLANES_VERSION', '1'); $this->workAroundStatic(); $command = new VersionCommand(); $command->run(); From b1c8cdd3c9c0db2af54965fa18a3e9f53fad122e Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Mon, 5 Jan 2015 10:28:38 +0100 Subject: [PATCH 3/4] constant usage removed in VersionCommandTest --- tests/MageTest/Command/BuildIn/VersionCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/MageTest/Command/BuildIn/VersionCommandTest.php b/tests/MageTest/Command/BuildIn/VersionCommandTest.php index 6002d5a..a607cae 100644 --- a/tests/MageTest/Command/BuildIn/VersionCommandTest.php +++ b/tests/MageTest/Command/BuildIn/VersionCommandTest.php @@ -17,7 +17,7 @@ class VersionCommandTest extends PHPUnit_Framework_TestCase $command = new VersionCommand(); $command->run(); - $this->expectOutputString('Running Magallanes version ' . MAGALLANES_VERSION . str_repeat(PHP_EOL, 2)); + $this->expectOutputString('Running Magallanes version 2' . str_repeat(PHP_EOL, 2)); } /** From 728f37254350f7a53003f2cef88080077025d9c9 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Mon, 5 Jan 2015 13:36:19 +0100 Subject: [PATCH 4/4] namespace fix for BuiltIn --- .../Command/{BuildIn => BuiltIn}/VersionCommandTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) rename tests/MageTest/Command/{BuildIn => BuiltIn}/VersionCommandTest.php (94%) diff --git a/tests/MageTest/Command/BuildIn/VersionCommandTest.php b/tests/MageTest/Command/BuiltIn/VersionCommandTest.php similarity index 94% rename from tests/MageTest/Command/BuildIn/VersionCommandTest.php rename to tests/MageTest/Command/BuiltIn/VersionCommandTest.php index a607cae..efeaa08 100644 --- a/tests/MageTest/Command/BuildIn/VersionCommandTest.php +++ b/tests/MageTest/Command/BuiltIn/VersionCommandTest.php @@ -1,6 +1,6 @@ workAroundStatic();