Completed
Push — master ( 0d684b...49516e )
by Dariusz
03:16
created

ShippingTest::testCreateObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 11
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 11
loc 11
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace Plane\Shop\Tests;
4
5
use Plane\Shop\Shipping;
6
use Plane\Shop\PriceFormat\EnglishFormat as PriceFormat;
7
8
/**
9
 * Shipping test suite
10
 *
11
 * @author Dariusz Korsak <[email protected]>
12
 * @package Plane\Shop
13
 */
14 View Code Duplication
class ShippingTest extends \PHPUnit\Framework\TestCase
15
{
16
    protected $shippingInput = [
17
       'id'             => 1,
18
       'name'           => 'National postal services',
19
       'description'    => '',
20
       'cost'           => 3.4
21
    ];
22
23
    public function testCreateObject()
24
    {
25
        $shipping = new Shipping($this->shippingInput);
26
27
        $this->assertSame($this->shippingInput, [
28
            'id'                => $shipping->getId(),
29
            'name'              => $shipping->getName(),
30
            'description'       => $shipping->getDescription(),
31
            'cost'              => $shipping->getCost(),
32
        ]);
33
    }
34
    
35
    public function testSetCost()
36
    {
37
        $shipping = new Shipping($this->shippingInput);
38
        $shipping->setCost(2);
39
        
40
        $this->assertSame(2.00, $shipping->getCost());
41
    }
42
43
    public function testSetPriceFormat()
44
    {
45
        $priceFormat = $this->getMockBuilder(PriceFormat::class)->getMock();
46
        
47
        $priceFormat->expects($this->any())
48
            ->method('formatPrice')
49
            ->willReturn(3.40);
50
        
51
        $shipping = new Shipping($this->shippingInput);
52
        $shipping->setPriceFormat($priceFormat);
53
        
54
        $this->assertSame(3.40, $shipping->getCost());
55
    }
56
}
57