TypeSemanticsTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 26
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testDetectesMonthlyTypes() 0 3 1
A monthlyTypesProvider() 0 8 1
A setUp() 0 3 1
1
<?php
2
3
namespace hiqdev\billing\hiapi\tests\unit\type;
4
5
use hiqdev\billing\hiapi\type\TypeSemantics;
6
use hiqdev\php\billing\type\Type;
7
use hiqdev\php\billing\type\TypeInterface;
8
9
/**
10
 * @author Andrii Vasyliev <[email protected]>
11
 */
12
class TypeSemanticsTest extends \PHPUnit\Framework\TestCase
13
{
14
    /** @var TypeSemantics */
15
    protected $semantics;
16
17
    public function setUp()
18
    {
19
        $this->semantics = new TypeSemantics();
20
    }
21
22
    /**
23
     * @dataProvider monthlyTypesProvider
24
     */
25
    public function testDetectesMonthlyTypes(TypeInterface $type, bool $shouldBeMonthly)
26
    {
27
        $this->assertSame($shouldBeMonthly, $this->semantics->isMonthly($type));
28
    }
29
30
    public function monthlyTypesProvider()
31
    {
32
        return [
33
            [new Type(null, 'monthly,monthly'), true],
34
            [new Type(null, 'monthly,foo,bar'), true],
35
            [new Type(null, 'monthly'), true],
36
            [new Type(null, 'overuse'), false],
37
            [new Type(null, 'overuse,monthly'), false],
38
        ];
39
    }
40
}
41