| @@ 28-68 (lines=41) @@ | ||
| 25 | * @link https://www.pivotaltracker.com/story/show/10474987 |
|
| 26 | * @covers \PHPMD\Rule\Design\CouplingBetweenObjects |
|
| 27 | */ |
|
| 28 | class CouplingBetweenObjectsTest extends AbstractTest |
|
| 29 | { |
|
| 30 | /** |
|
| 31 | * testRuleNotAppliesToClassWithCboLessThanThreshold |
|
| 32 | * |
|
| 33 | * @return void |
|
| 34 | */ |
|
| 35 | public function testRuleNotAppliesToClassWithCboLessThanThreshold() |
|
| 36 | { |
|
| 37 | $rule = new CouplingBetweenObjects(); |
|
| 38 | $rule->setReport($this->getReportMock(0)); |
|
| 39 | $rule->addProperty('maximum', '42'); |
|
| 40 | $rule->apply($this->getClassMock('cbo', 41)); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * testRuleAppliesToClassWithCboEqualToThreshold |
|
| 45 | * |
|
| 46 | * @return void |
|
| 47 | */ |
|
| 48 | public function testRuleAppliesToClassWithCboEqualToThreshold() |
|
| 49 | { |
|
| 50 | $rule = new CouplingBetweenObjects(); |
|
| 51 | $rule->setReport($this->getReportMock(1)); |
|
| 52 | $rule->addProperty('maximum', '42'); |
|
| 53 | $rule->apply($this->getClassMock('cbo', 42)); |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * testRuleAppliesToClassWithCboGreaterThanThreshold |
|
| 58 | * |
|
| 59 | * @return void |
|
| 60 | */ |
|
| 61 | public function testRuleAppliesToClassWithCboGreaterThanThreshold() |
|
| 62 | { |
|
| 63 | $rule = new CouplingBetweenObjects(); |
|
| 64 | $rule->setReport($this->getReportMock(1)); |
|
| 65 | $rule->addProperty('maximum', '41'); |
|
| 66 | $rule->apply($this->getClassMock('cbo', 42)); |
|
| 67 | } |
|
| 68 | } |
|
| 69 | ||
| @@ 27-67 (lines=41) @@ | ||
| 24 | * |
|
| 25 | * @covers \PHPMD\Rule\Design\DepthOfInheritance |
|
| 26 | */ |
|
| 27 | class DepthOfInheritanceTest extends AbstractTest |
|
| 28 | { |
|
| 29 | /** |
|
| 30 | * testRuleNotAppliesToClassWithNumberOfParentLessThanThreshold |
|
| 31 | * |
|
| 32 | * @return void |
|
| 33 | */ |
|
| 34 | public function testRuleNotAppliesToClassWithNumberOfParentLessThanThreshold() |
|
| 35 | { |
|
| 36 | $rule = new DepthOfInheritance(); |
|
| 37 | $rule->setReport($this->getReportMock(0)); |
|
| 38 | $rule->addProperty('minimum', '42'); |
|
| 39 | $rule->apply($this->getClassMock('dit', 41)); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * testRuleAppliesToClassWithNumberOfParentIdenticalToThreshold |
|
| 44 | * |
|
| 45 | * @return void |
|
| 46 | */ |
|
| 47 | public function testRuleAppliesToClassWithNumberOfParentIdenticalToThreshold() |
|
| 48 | { |
|
| 49 | $rule = new DepthOfInheritance(); |
|
| 50 | $rule->setReport($this->getReportMock(1)); |
|
| 51 | $rule->addProperty('minimum', '42'); |
|
| 52 | $rule->apply($this->getClassMock('dit', 42)); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * testRuleAppliesToClassWithNumberOfParentGreaterThanThreshold |
|
| 57 | * |
|
| 58 | * @return void |
|
| 59 | */ |
|
| 60 | public function testRuleAppliesToClassWithNumberOfParentGreaterThanThreshold() |
|
| 61 | { |
|
| 62 | $rule = new DepthOfInheritance(); |
|
| 63 | $rule->setReport($this->getReportMock(1)); |
|
| 64 | $rule->addProperty('minimum', '42'); |
|
| 65 | $rule->apply($this->getClassMock('dit', 43)); |
|
| 66 | } |
|
| 67 | } |
|
| 68 | ||
| @@ 27-67 (lines=41) @@ | ||
| 24 | * |
|
| 25 | * @covers \PHPMD\Rule\Design\NumberOfChildren |
|
| 26 | */ |
|
| 27 | class NumberOfChildrenTest extends AbstractTest |
|
| 28 | { |
|
| 29 | /** |
|
| 30 | * testRuleNotAppliesToClassWithChildrenLessThanThreshold |
|
| 31 | * |
|
| 32 | * @return void |
|
| 33 | */ |
|
| 34 | public function testRuleNotAppliesToClassWithChildrenLessThanThreshold() |
|
| 35 | { |
|
| 36 | $rule = new NumberOfChildren(); |
|
| 37 | $rule->setReport($this->getReportMock(0)); |
|
| 38 | $rule->addProperty('minimum', '42'); |
|
| 39 | $rule->apply($this->getClassMock('nocc', 41)); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * testRuleAppliesToClassWithChildrenIdenticalToThreshold |
|
| 44 | * |
|
| 45 | * @return void |
|
| 46 | */ |
|
| 47 | public function testRuleAppliesToClassWithChildrenIdenticalToThreshold() |
|
| 48 | { |
|
| 49 | $rule = new NumberOfChildren(); |
|
| 50 | $rule->setReport($this->getReportMock(1)); |
|
| 51 | $rule->addProperty('minimum', '42'); |
|
| 52 | $rule->apply($this->getClassMock('nocc', 42)); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * testRuleAppliesToClassWithChildrenGreaterThanThreshold |
|
| 57 | * |
|
| 58 | * @return void |
|
| 59 | */ |
|
| 60 | public function testRuleAppliesToClassWithChildrenGreaterThanThreshold() |
|
| 61 | { |
|
| 62 | $rule = new NumberOfChildren(); |
|
| 63 | $rule->setReport($this->getReportMock(1)); |
|
| 64 | $rule->addProperty('minimum', '42'); |
|
| 65 | $rule->apply($this->getClassMock('nocc', 43)); |
|
| 66 | } |
|
| 67 | } |
|
| 68 | ||
| @@ 27-67 (lines=41) @@ | ||
| 24 | * |
|
| 25 | * @covers \PHPMD\Rule\Design\TooManyFields |
|
| 26 | */ |
|
| 27 | class TooManyFieldsTest extends AbstractTest |
|
| 28 | { |
|
| 29 | /** |
|
| 30 | * testRuleDoesNotApplyToClassesWithLessFieldsThanThreshold |
|
| 31 | * |
|
| 32 | * @return void |
|
| 33 | */ |
|
| 34 | public function testRuleDoesNotApplyToClassesWithLessFieldsThanThreshold() |
|
| 35 | { |
|
| 36 | $rule = new TooManyFields(); |
|
| 37 | $rule->setReport($this->getReportMock(0)); |
|
| 38 | $rule->addProperty('maxfields', '42'); |
|
| 39 | $rule->apply($this->getClassMock('vars', 23)); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * testRuleDoesNotApplyToClassesWithSameNumberOfFieldsAsThreshold |
|
| 44 | * |
|
| 45 | * @return void |
|
| 46 | */ |
|
| 47 | public function testRuleDoesNotApplyToClassesWithSameNumberOfFieldsAsThreshold() |
|
| 48 | { |
|
| 49 | $rule = new TooManyFields(); |
|
| 50 | $rule->setReport($this->getReportMock(0)); |
|
| 51 | $rule->addProperty('maxfields', '42'); |
|
| 52 | $rule->apply($this->getClassMock('vars', 42)); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * testRuleAppliesToClassesWithMoreFieldsThanThreshold |
|
| 57 | * |
|
| 58 | * @return void |
|
| 59 | */ |
|
| 60 | public function testRuleAppliesToClassesWithMoreFieldsThanThreshold() |
|
| 61 | { |
|
| 62 | $rule = new TooManyFields(); |
|
| 63 | $rule->setReport($this->getReportMock(1)); |
|
| 64 | $rule->addProperty('maxfields', '23'); |
|
| 65 | $rule->apply($this->getClassMock('vars', 42)); |
|
| 66 | } |
|
| 67 | } |
|
| 68 | ||
| @@ 27-67 (lines=41) @@ | ||
| 24 | * |
|
| 25 | * @covers \PHPMD\Rule\ExcessivePublicCount |
|
| 26 | */ |
|
| 27 | class ExcessivePublicCountTest extends AbstractTest |
|
| 28 | { |
|
| 29 | /** |
|
| 30 | * testRuleDoesNotApplyToClassesWithLessPublicMembersThanThreshold |
|
| 31 | * |
|
| 32 | * @return void |
|
| 33 | */ |
|
| 34 | public function testRuleDoesNotApplyToClassesWithLessPublicMembersThanThreshold() |
|
| 35 | { |
|
| 36 | $rule = new ExcessivePublicCount(); |
|
| 37 | $rule->setReport($this->getReportMock(0)); |
|
| 38 | $rule->addProperty('minimum', '42'); |
|
| 39 | $rule->apply($this->getClassMock('cis', 23)); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * testRuleAppliesToClassesWithSameNumberOfPublicMembersAsThreshold |
|
| 44 | * |
|
| 45 | * @return void |
|
| 46 | */ |
|
| 47 | public function testRuleAppliesToClassesWithSameNumberOfPublicMembersAsThreshold() |
|
| 48 | { |
|
| 49 | $rule = new ExcessivePublicCount(); |
|
| 50 | $rule->setReport($this->getReportMock(1)); |
|
| 51 | $rule->addProperty('minimum', '42'); |
|
| 52 | $rule->apply($this->getClassMock('cis', 42)); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * testRuleAppliesToClassesWithMorePublicMembersThanThreshold |
|
| 57 | * |
|
| 58 | * @return void |
|
| 59 | */ |
|
| 60 | public function testRuleAppliesToClassesWithMorePublicMembersThanThreshold() |
|
| 61 | { |
|
| 62 | $rule = new ExcessivePublicCount(); |
|
| 63 | $rule->setReport($this->getReportMock(1)); |
|
| 64 | $rule->addProperty('minimum', '23'); |
|
| 65 | $rule->apply($this->getClassMock('cis', 42)); |
|
| 66 | } |
|
| 67 | } |
|
| 68 | ||