Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php namespace Limoncello\Tests\Auth\Authorization\PolicyDecision; |
||
| 26 | class AlgorithmFactoryTest extends TestCase |
||
| 27 | { |
||
| 28 | /** |
||
| 29 | * Test algorithm creation. |
||
| 30 | */ |
||
| 31 | public function testPolicyAlgorithms() |
||
| 32 | { |
||
| 33 | $this->assertNotNull(PolicyAlgorithm::denyOverrides()); |
||
| 34 | $this->assertNotNull(PolicyAlgorithm::denyUnlessPermit()); |
||
| 35 | $this->assertNotNull(PolicyAlgorithm::permitOverrides()); |
||
| 36 | $this->assertNotNull(PolicyAlgorithm::permitUnlessDeny()); |
||
| 37 | $this->assertNotNull(PolicyAlgorithm::firstApplicable()); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Test algorithm creation. |
||
| 42 | */ |
||
| 43 | public function testRuleAlgorithms() |
||
| 44 | { |
||
| 45 | $this->assertNotNull(RuleAlgorithm::denyOverrides()); |
||
| 46 | $this->assertNotNull(RuleAlgorithm::denyUnlessPermit()); |
||
| 47 | $this->assertNotNull(RuleAlgorithm::permitOverrides()); |
||
| 48 | $this->assertNotNull(RuleAlgorithm::permitUnlessDeny()); |
||
| 49 | $this->assertNotNull(RuleAlgorithm::firstApplicable()); |
||
| 50 | } |
||
| 51 | } |
||
| 52 |