| @@ 28-89 (lines=62) @@ | ||
| 25 | * @author Grégoire Paris <[email protected]> |
|
| 26 | * @author Kamil Szymanski <[email protected]> |
|
| 27 | */ |
|
| 28 | class EmptyCatchBlockTest extends AbstractTest |
|
| 29 | { |
|
| 30 | /** |
|
| 31 | * testRuleNotAppliesToMethodWithoutTryCatchBlock |
|
| 32 | * |
|
| 33 | * @return void |
|
| 34 | */ |
|
| 35 | public function testRuleNotAppliesToMethodWithoutTryCatchBlock() |
|
| 36 | { |
|
| 37 | $rule = new EmptyCatchBlock(); |
|
| 38 | $rule->setReport($this->getReportMock(0)); |
|
| 39 | $rule->apply($this->getMethod()); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * testRuleAppliesToFunctionWithEmptyCatchBlock |
|
| 44 | * |
|
| 45 | * @return void |
|
| 46 | */ |
|
| 47 | public function testRuleAppliesToFunctionWithEmptyCatchBlock() |
|
| 48 | { |
|
| 49 | $rule = new EmptyCatchBlock(); |
|
| 50 | $rule->setReport($this->getReportMock(3)); |
|
| 51 | $rule->apply($this->getFunction()); |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * testRuleNotAppliesToFunctionWithNonEmptyCatchBlock |
|
| 56 | * |
|
| 57 | * @return void |
|
| 58 | */ |
|
| 59 | public function testRuleNotAppliesToFunctionWithNonEmptyCatchBlock() |
|
| 60 | { |
|
| 61 | $rule = new EmptyCatchBlock(); |
|
| 62 | $rule->setReport($this->getReportMock(0)); |
|
| 63 | $rule->apply($this->getFunction()); |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * testRuleNotAppliesToCatchBlockWithComments |
|
| 68 | * |
|
| 69 | * @return void |
|
| 70 | */ |
|
| 71 | public function testRuleNotAppliesToCatchBlockWithComments() |
|
| 72 | { |
|
| 73 | $rule = new EmptyCatchBlock(); |
|
| 74 | $rule->setReport($this->getReportMock(0)); |
|
| 75 | $rule->apply($this->getFunction()); |
|
| 76 | } |
|
| 77 | ||
| 78 | /** |
|
| 79 | * testRuleWorksWithNestedTryCatchBlocksAndNonSPLExceptions |
|
| 80 | * |
|
| 81 | * @return void |
|
| 82 | */ |
|
| 83 | public function testRuleWorksWithNestedTryCatchBlocksAndNonSPLExceptions() |
|
| 84 | { |
|
| 85 | $rule = new EmptyCatchBlock(); |
|
| 86 | $rule->setReport($this->getReportMock(1)); |
|
| 87 | $rule->apply($this->getFunction()); |
|
| 88 | } |
|
| 89 | } |
|
| 90 | ||
| @@ 27-78 (lines=52) @@ | ||
| 24 | * |
|
| 25 | * @covers PHPMD\Rule\Naming\ConstructorWithNameAsEnclosingClass |
|
| 26 | */ |
|
| 27 | class ConstructorWithNameAsEnclosingClassTest extends AbstractTest |
|
| 28 | { |
|
| 29 | /** |
|
| 30 | * testRuleAppliesToConstructorMethodNamedAsEnclosingClass |
|
| 31 | * |
|
| 32 | * @return void |
|
| 33 | */ |
|
| 34 | public function testRuleAppliesToConstructorMethodNamedAsEnclosingClass() |
|
| 35 | { |
|
| 36 | $rule = new ConstructorWithNameAsEnclosingClass(); |
|
| 37 | $rule->setReport($this->getReportMock(1)); |
|
| 38 | $rule->apply($this->getMethod()); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * testRuleAppliesToConstructorMethodNamedAsEnclosingClassCaseInsensitive |
|
| 43 | * |
|
| 44 | * @return void |
|
| 45 | */ |
|
| 46 | public function testRuleAppliesToConstructorMethodNamedAsEnclosingClassCaseInsensitive() |
|
| 47 | { |
|
| 48 | $rule = new ConstructorWithNameAsEnclosingClass(); |
|
| 49 | $rule->setReport($this->getReportMock(1)); |
|
| 50 | $rule->apply($this->getMethod()); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * testRuleNotAppliesToMethodNamedSimilarToEnclosingClass |
|
| 55 | * |
|
| 56 | * @return void |
|
| 57 | */ |
|
| 58 | public function testRuleNotAppliesToMethodNamedSimilarToEnclosingClass() |
|
| 59 | { |
|
| 60 | $rule = new ConstructorWithNameAsEnclosingClass(); |
|
| 61 | $rule->setReport($this->getReportMock(0)); |
|
| 62 | $rule->apply($this->getMethod()); |
|
| 63 | } |
|
| 64 | ||
| 65 | public function testRuleNotAppliesToMethodNamedAsEnclosingInterface() |
|
| 66 | { |
|
| 67 | $rule = new ConstructorWithNameAsEnclosingClass(); |
|
| 68 | $rule->setReport($this->getReportMock(0)); |
|
| 69 | $rule->apply($this->getMethod()); |
|
| 70 | } |
|
| 71 | ||
| 72 | public function testRuleNotAppliesToMethodInNamespaces() |
|
| 73 | { |
|
| 74 | $rule = new ConstructorWithNameAsEnclosingClass(); |
|
| 75 | $rule->setReport($this->getReportMock(0)); |
|
| 76 | $rule->apply($this->getMethod()); |
|
| 77 | } |
|
| 78 | } |
|
| 79 | ||