Code Duplication    Length = 43-45 lines in 2 locations

tests/PaymentTest.php 1 location

@@ 14-58 (lines=45) @@
11
 * @author Dariusz Korsak <[email protected]>
12
 * @package Plane\Shop
13
 */
14
class PaymentTest extends \PHPUnit\Framework\TestCase
15
{
16
    protected $paymentInput = [
17
       'id'             => 1,
18
       'name'           => 'PayPal',
19
       'description'    => 'Payment with Paypal',
20
       'fee'            => 0.2
21
    ];
22
23
    public function testCreateObject()
24
    {
25
        $payment = new Payment($this->paymentInput);
26
        $payment->setFixed();
27
28
        $this->assertSame($this->paymentInput, [
29
            'id'                => $payment->getId(),
30
            'name'              => $payment->getName(),
31
            'description'       => $payment->getDescription(),
32
            'fee'               => $payment->getFee(10),
33
        ]);
34
    }
35
36
    public function testPercentageFee()
37
    {
38
        $payment = new Payment($this->paymentInput);
39
        $payment->setPercentage();
40
41
        $this->assertSame(2.0, $payment->getFee(10));
42
    }
43
44
    public function testSetPriceFormat()
45
    {
46
        $priceFormat = $this->getMockBuilder(PriceFormat::class)
47
            ->getMock();
48
        
49
        $priceFormat->expects($this->any())
50
            ->method('formatPrice')
51
            ->willReturn(2.00);
52
        
53
        $payment = new Payment($this->paymentInput);
54
        $payment->setPriceFormat($priceFormat);
55
        
56
        $this->assertSame(2.00, $payment->getFee(10));
57
    }
58
}
59

tests/ShippingTest.php 1 location

@@ 14-56 (lines=43) @@
11
 * @author Dariusz Korsak <[email protected]>
12
 * @package Plane\Shop
13
 */
14
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