From 55b799b88d190332deb56e9b258c72ca9bc750b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Fri, 10 Oct 2014 17:23:27 +0200 Subject: [PATCH] Added test case for the new exceptions setting in ShortMethodName --- .../PHPMD/Rule/Naming/ShortMethodNameTest.php | 20 +++++++++++++++++++ ...liesToMethodWithShortNameWhenException.php | 8 ++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/test/resources/files/Rule/Naming/ShortMethodName/testRuleNotAppliesToMethodWithShortNameWhenException.php diff --git a/src/test/php/PHPMD/Rule/Naming/ShortMethodNameTest.php b/src/test/php/PHPMD/Rule/Naming/ShortMethodNameTest.php index 159aa432c..565636eac 100644 --- a/src/test/php/PHPMD/Rule/Naming/ShortMethodNameTest.php +++ b/src/test/php/PHPMD/Rule/Naming/ShortMethodNameTest.php @@ -67,6 +67,7 @@ public function testRuleAppliesToFunctionWithNameShorterThanThreshold() { $rule = new ShortMethodName(); $rule->addProperty('minimum', 54); + $rule->addProperty('exceptions', ''); $rule->setReport($this->getReportMock(1)); $rule->apply($this->getFunction()); } @@ -80,6 +81,7 @@ public function testRuleNotAppliesToFunctionWithNameEqualToThreshold() { $rule = new ShortMethodName(); $rule->addProperty('minimum', 52); + $rule->addProperty('exceptions', ''); $rule->setReport($this->getReportMock(0)); $rule->apply($this->getFunction()); } @@ -93,6 +95,7 @@ public function testRuleNotAppliesToFunctionWithNameLongerThanThreshold() { $rule = new ShortMethodName(); $rule->addProperty('minimum', 54); + $rule->addProperty('exceptions', ''); $rule->setReport($this->getReportMock(0)); $rule->apply($this->getFunction()); } @@ -105,6 +108,7 @@ public function testRuleAppliesToMethodWithNameShorterThanThreshold() { $rule = new ShortMethodName(); $rule->addProperty('minimum', 52); + $rule->addProperty('exceptions', ''); $rule->setReport($this->getReportMock(1)); $rule->apply($this->getMethod()); } @@ -118,6 +122,7 @@ public function testRuleNotAppliesToMethodWithNameEqualToThreshold() { $rule = new ShortMethodName(); $rule->addProperty('minimum', 50); + $rule->addProperty('exceptions', ''); $rule->setReport($this->getReportMock(0)); $rule->apply($this->getMethod()); } @@ -131,6 +136,21 @@ public function testRuleNotAppliesToMethodWithNameLongerThanThreshold() { $rule = new ShortMethodName(); $rule->addProperty('minimum', 52); + $rule->addProperty('exceptions', ''); + $rule->setReport($this->getReportMock(0)); + $rule->apply($this->getMethod()); + } + + /** + * testRuleNotAppliesToMethodWithNameLongerThanThreshold + * + * @return void + */ + public function testRuleNotAppliesToMethodWithShortNameWhenException() + { + $rule = new ShortMethodName(); + $rule->addProperty('minimum', 100); + $rule->addProperty('exceptions', 'testRuleNotAppliesToMethodWithShortNameWhenException,another'); $rule->setReport($this->getReportMock(0)); $rule->apply($this->getMethod()); } diff --git a/src/test/resources/files/Rule/Naming/ShortMethodName/testRuleNotAppliesToMethodWithShortNameWhenException.php b/src/test/resources/files/Rule/Naming/ShortMethodName/testRuleNotAppliesToMethodWithShortNameWhenException.php new file mode 100644 index 000000000..f549d3d65 --- /dev/null +++ b/src/test/resources/files/Rule/Naming/ShortMethodName/testRuleNotAppliesToMethodWithShortNameWhenException.php @@ -0,0 +1,8 @@ +