From d33b3db5b0d7589dc8a62305f3a46050914362da Mon Sep 17 00:00:00 2001 From: Andrew Roslik Date: Mon, 5 Sep 2016 12:24:48 +0300 Subject: [PATCH] Refactored #117: Make fast disabling synchronization with an issue tracker - Renamed class. --- ...ion.xml => Magento-MageExceptionThrow.xml} | 4 +- .../MageExceptionThrow.php} | 7 ++- .../Test/Processor/PreCommitTest.php | 55 ++++++++++--------- .../MageExceptionThrowTest.php} | 16 +++--- 4 files changed, 43 insertions(+), 39 deletions(-) rename src/config/validators/{Magento-Exception.xml => Magento-MageExceptionThrow.xml} (77%) rename src/lib/PreCommit/Validator/{CodingStandardMagento.php => Magento/MageExceptionThrow.php} (92%) rename src/tests/testsuite/PreCommit/Test/Validator/{CodingStandardMagentoTest.php => Magento/MageExceptionThrowTest.php} (53%) diff --git a/src/config/validators/Magento-Exception.xml b/src/config/validators/Magento-MageExceptionThrow.xml similarity index 77% rename from src/config/validators/Magento-Exception.xml rename to src/config/validators/Magento-MageExceptionThrow.xml index d7f916a..42f6db2 100644 --- a/src/config/validators/Magento-Exception.xml +++ b/src/config/validators/Magento-MageExceptionThrow.xml @@ -11,14 +11,14 @@ - 0 + 0 - 1 + 1 diff --git a/src/lib/PreCommit/Validator/CodingStandardMagento.php b/src/lib/PreCommit/Validator/Magento/MageExceptionThrow.php similarity index 92% rename from src/lib/PreCommit/Validator/CodingStandardMagento.php rename to src/lib/PreCommit/Validator/Magento/MageExceptionThrow.php index c2d910f..cfb3020 100644 --- a/src/lib/PreCommit/Validator/CodingStandardMagento.php +++ b/src/lib/PreCommit/Validator/Magento/MageExceptionThrow.php @@ -2,20 +2,21 @@ /** * @license https://raw.githubusercontent.com/andkirby/commithook/master/LICENSE.md */ -namespace PreCommit\Validator; +namespace PreCommit\Validator\Magento; + +use PreCommit\Validator\CodingStandard; /** * Class CodingStandard validator * * @package PreCommit\Validator */ -class CodingStandardMagento extends CodingStandard +class MageExceptionThrow extends CodingStandard { /**#@+ * Error codes */ const CODE_PHP_DEPRECATED_THROW_EXCEPTION = 'deprecatedUsingMageThrowException'; - /**#@-*/ /** diff --git a/src/tests/testsuite/PreCommit/Test/Processor/PreCommitTest.php b/src/tests/testsuite/PreCommit/Test/Processor/PreCommitTest.php index 48bcb2d..8fab62d 100644 --- a/src/tests/testsuite/PreCommit/Test/Processor/PreCommitTest.php +++ b/src/tests/testsuite/PreCommit/Test/Processor/PreCommitTest.php @@ -14,10 +14,10 @@ class PreCommitTest extends \PHPUnit_Framework_TestCase /** * Set up test model */ - static public function setUpBeforeClass() + public static function setUpBeforeClass() { //init config - Config::initInstance(array('file' => PROJECT_ROOT . '/config.xml')); + Config::initInstance(['file' => PROJECT_ROOT.'/config.xml']); Config::setSrcRootDir(PROJECT_ROOT); Config::mergeExtraConfig(); } @@ -29,37 +29,38 @@ static public function setUpBeforeClass() */ public function dataTestValidatorsType() { - return array( - array( + return [ + [ 'php', - array( - 'PhpClass' => 1, - 'PhpDoc' => 1, - 'CodingStandard' => 1, - 'RedundantCode' => 1, - 'CodingStandardMagento' => 1, - ) - ), - array( + [ + 'PhpClass' => 1, + 'PhpDoc' => 1, + 'CodingStandard' => 1, + 'RedundantCode' => 1, + 'Magento-MageExceptionThrow' => 1, + 'Magento-ModelEventFields' => 1, + ], + ], + [ 'phtml', - array( - 'RedundantCode' => 1, + [ + 'RedundantCode' => 1, 'CodingStandardPhtml' => 1, - ) - ), - array( + ], + ], + [ 'js', - array( + [ 'RedundantCode' => 1, - ) - ), - array( + ], + ], + [ 'xml', - array( + [ 'XmlParser' => 1, - ) - ), - ); + ], + ], + ]; } /** @@ -72,7 +73,7 @@ public function dataTestValidatorsType() public function testGetValidatorsType($type, $expected) { /** @var \PreCommit\Processor\PreCommit $test */ - $test = $this->getMock('\PreCommit\Processor\PreCommit', array('____'), array(), '', false); + $test = $this->getMock('\PreCommit\Processor\PreCommit', ['____'], [], '', false); $result = $test->getValidators($type); $this->assertEquals($expected, $result); } diff --git a/src/tests/testsuite/PreCommit/Test/Validator/CodingStandardMagentoTest.php b/src/tests/testsuite/PreCommit/Test/Validator/Magento/MageExceptionThrowTest.php similarity index 53% rename from src/tests/testsuite/PreCommit/Test/Validator/CodingStandardMagentoTest.php rename to src/tests/testsuite/PreCommit/Test/Validator/Magento/MageExceptionThrowTest.php index 777e3c5..0a3bac3 100644 --- a/src/tests/testsuite/PreCommit/Test/Validator/CodingStandardMagentoTest.php +++ b/src/tests/testsuite/PreCommit/Test/Validator/Magento/MageExceptionThrowTest.php @@ -2,26 +2,28 @@ /** * @license https://raw.githubusercontent.com/andkirby/commithook/master/LICENSE.md */ -namespace PreCommit\Test\Validator; +namespace PreCommit\Test\Validator\Magento; -use PreCommit\Validator\CodingStandardMagento; +use PreCommit\Test\Validator\CodingStandardTest; +use PreCommit\Validator\Magento\MageExceptionThrow; /** * Class test for Processor */ -class CodingStandardMagentoTest extends CodingStandardTest +class MageExceptionThrowTest extends CodingStandardTest { /** * Test CODE_PHP_SPACE_BRACKET */ public function testDeprecatedThrowException() { - $errors = $this->_getSpecificErrorsList( + $errors = $this->_getSpecificErrorsList( self::$_classTest, - CodingStandardMagento::CODE_PHP_DEPRECATED_THROW_EXCEPTION); - $expected = array ( - "Mage::throwException('text');", + MageExceptionThrow::CODE_PHP_DEPRECATED_THROW_EXCEPTION ); + $expected = [ + "Mage::throwException('text');", + ]; $this->assertEquals($expected, array_values($errors)); } }