Completed
Push — master ( 3a4c95...865c46 )
by Andrii
02:08
created

ModifierFactoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 23
rs 10
c 1
b 0
f 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testDiscount() 0 5 1
A testNewEveryTime() 0 6 1
1
<?php
2
/**
3
 * PHP Billing Library
4
 *
5
 * @link      https://github.com/hiqdev/php-billing
6
 * @package   php-billing
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing\tests\unit\charge\modifiers;
12
13
use hiqdev\php\billing\charge\modifiers\Discount;
14
use hiqdev\php\billing\charge\modifiers\ModifierFactory;
15
16
/**
17
 * @author Andrii Vasyliev <[email protected]>
18
 */
19
class ModifierFactoryTest extends \PHPUnit\Framework\TestCase
20
{
21
    protected $factory;
22
23
    protected function setUp()
24
    {
25
        parent::setUp();
26
        $this->factory = new ModifierFactory();
27
    }
28
29
    public function testDiscount()
30
    {
31
        $discount = $this->factory->discount();
0 ignored issues
show
Documentation Bug introduced by
The method discount does not exist on object<hiqdev\php\billin...ifiers\ModifierFactory>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
32
        $this->assertInstanceOf(Discount::class, $discount);
33
    }
34
35
    public function testNewEveryTime()
36
    {
37
        $one = $this->factory->reason('test');
0 ignored issues
show
Documentation Bug introduced by
The method reason does not exist on object<hiqdev\php\billin...ifiers\ModifierFactory>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
38
        $two = $this->factory->reason('test');
0 ignored issues
show
Documentation Bug introduced by
The method reason does not exist on object<hiqdev\php\billin...ifiers\ModifierFactory>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
39
        $this->assertTrue($one !== $two);
40
    }
41
}
42