Completed
Branch master (91621e)
by Neomerx
01:35
created

AlgorithmFactoryTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 61.54 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 16
loc 26
rs 10
c 0
b 0
f 0

How to fix   Duplicated Code   

Duplicated Code

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;
2
3
/**
4
 * Copyright 2015-2017 [email protected]
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use Limoncello\Auth\Authorization\PolicyDecision\PolicyAlgorithm;
20
use Limoncello\Auth\Authorization\PolicyDecision\RuleAlgorithm;
21
use PHPUnit\Framework\TestCase;
22
23
/**
24
 * @package Limoncello\Tests\Auth
25
 */
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