From 17907235acece13a202071cd43a4991fc1ed3cb7 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Fri, 2 Jan 2015 15:28:13 +0100 Subject: [PATCH 01/17] 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 02/17] 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 03/17] 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 04/17] 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(); From 008ef980e0118fd231786ed8dd43d95d9438cc02 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Fri, 2 Jan 2015 15:28:13 +0100 Subject: [PATCH 05/17] 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 74bb9ad5f73de5831bd191aca3d97db8c0d57e0f Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Fri, 2 Jan 2015 16:24:25 +0100 Subject: [PATCH 06/17] 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 6fbbd61..ded79b6 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 17b62084cdefbf9f92817ec18adf2f68e476200d Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Mon, 5 Jan 2015 10:28:38 +0100 Subject: [PATCH 07/17] 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 30cecd09652ec0e5ef0a2ffeca2014e41806359e Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Mon, 5 Jan 2015 13:36:19 +0100 Subject: [PATCH 08/17] 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(); From 67960ba3f468e80282c668cdce537abe7092a616 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Fri, 2 Jan 2015 15:28:13 +0100 Subject: [PATCH 09/17] 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 aff9d2f32b7307635c4c3ccf56c22215e50d76d7 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Fri, 2 Jan 2015 16:24:25 +0100 Subject: [PATCH 10/17] 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 6fbbd61..ded79b6 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 c40eb592190cbc548368c6853c559eb364f8c9e8 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Mon, 5 Jan 2015 10:28:38 +0100 Subject: [PATCH 11/17] 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 ebc90d0b2a92e74bbdc701066fb17c205f529ca8 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Mon, 5 Jan 2015 13:36:19 +0100 Subject: [PATCH 12/17] 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(); From 9711908063ecfdd3aa8ed8c13e61dfda99582c46 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Fri, 2 Jan 2015 15:28:13 +0100 Subject: [PATCH 13/17] 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 06246e380cb92da77059dee80eafda82d7204959 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Fri, 2 Jan 2015 16:24:25 +0100 Subject: [PATCH 14/17] setting constant in phpunit config --- tests/MageTest/Command/BuildIn/VersionCommandTest.php | 1 - 1 file changed, 1 deletion(-) 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 2d81e6c7eca45ad0ef4fe532e5aeffb12ae45173 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Mon, 5 Jan 2015 10:28:38 +0100 Subject: [PATCH 15/17] 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 472e5b05bf52b25c233eaf7790ad480445c44b3e Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Mon, 5 Jan 2015 13:36:19 +0100 Subject: [PATCH 16/17] namespace fix for BuiltIn --- .../Command/BuildIn/VersionCommandTest.php | 43 ------------------- 1 file changed, 43 deletions(-) delete mode 100644 tests/MageTest/Command/BuildIn/VersionCommandTest.php diff --git a/tests/MageTest/Command/BuildIn/VersionCommandTest.php b/tests/MageTest/Command/BuildIn/VersionCommandTest.php deleted file mode 100644 index a607cae..0000000 --- a/tests/MageTest/Command/BuildIn/VersionCommandTest.php +++ /dev/null @@ -1,43 +0,0 @@ -workAroundStatic(); - $command = new VersionCommand(); - $command->run(); - - $this->expectOutputString('Running Magallanes version 2' . 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 0d57e080e4ef899e9df2860956e10470f01f5b4f Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Sun, 15 Mar 2015 23:52:58 +0100 Subject: [PATCH 17/17] using BaseTest class for VersionCommand test --- .../Command/BuiltIn/VersionCommandTest.php | 30 +++++-------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/tests/MageTest/Command/BuiltIn/VersionCommandTest.php b/tests/MageTest/Command/BuiltIn/VersionCommandTest.php index efeaa08..6565510 100644 --- a/tests/MageTest/Command/BuiltIn/VersionCommandTest.php +++ b/tests/MageTest/Command/BuiltIn/VersionCommandTest.php @@ -4,43 +4,27 @@ namespace MageTest\Command\BuiltIn; use Mage\Command\BuiltIn\VersionCommand; use Mage\Console; +use MageTest\TestHelper\BaseTest; use PHPUnit_Framework_TestCase; /** + * @coversDefaultClass Mage\Command\BuiltIn\VersionCommands * @group Mage_Command_BuildIn_VersionCommand + * @uses Mage\Console + * @uses Mage\Console\Colors */ -class VersionCommandTest extends PHPUnit_Framework_TestCase +class VersionCommandTest extends BaseTest { /** * @group 175 + * @covers Mage\Command\BuiltIn\VersionCommand::run() */ public function testRun() { - $this->workAroundStatic(); + $this->setUpConsoleStatics(); $command = new VersionCommand(); $command->run(); $this->expectOutputString('Running Magallanes version 2' . 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); - } }