Completed
Push — master ( d02bdd...0a5fc3 )
by Andrii
02:11
created

SinglePriceTest::testCalculatePrice()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
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, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing\tests\unit\price;
12
13
use hiqdev\php\billing\price\SinglePrice;
14
use hiqdev\php\billing\target\Target;
15
use hiqdev\php\billing\type\Type;
16
use hiqdev\php\units\Quantity;
17
use Money\Money;
18
19
/**
20
 * @author Andrii Vasyliev <[email protected]>
21
 */
22
class SinglePriceTest extends \PHPUnit\Framework\TestCase
23
{
24
    /**
25
     * @var SinglePrice
26
     */
27
    protected $price;
28
29
    /**
30
     * @var SimpleAction
31
     */
32
    protected $action;
33
34
    /**
35
     * @var Money
36
     */
37
    protected $money;
38
39 View Code Duplication
    protected function setUp()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        $this->target   = new Target('server', 1);
42
        $this->type     = new Type('server_traf');
43
        $this->quantity = Quantity::gigabyte(10);
44
        $this->money    = Money::USD(15);
45
        $this->price    = new SinglePrice(null, $this->type, $this->target, $this->quantity, $this->money);
46
    }
47
48
    protected function tearDown()
49
    {
50
    }
51
52
    public function testCalculateUsage()
53
    {
54
        $this->assertNull($this->price->calculateUsage(Quantity::byte(1)));
55
        $this->assertEquals(Quantity::gigabyte(90), $this->price->calculateUsage(Quantity::gigabyte(100)));
56
    }
57
58
    public function testCalculatePrice()
59
    {
60
        $this->assertEquals($this->money, $this->price->calculatePrice(Quantity::byte(1)));
61
        $this->assertEquals($this->money, $this->price->calculatePrice(Quantity::megabyte(1)));
62
    }
63
}
64