Passed
Push — master ( 4bb49a...f178ad )
by Radosław
04:16 queued 01:34
created

MTGAuctionDecoratorTest::testFromArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace Radowoj\Yaah\Decorators;
4
5
use PHPUnit\Framework\TestCase;
6
use Radowoj\Yaah\Auction;
7
use Radowoj\Yaah\Decorators\MTGAuctionDecorator;
8
use Radowoj\Yaah\Constants\AuctionTimespans;
9
use Radowoj\Yaah\Constants\Conditions;
10
use Radowoj\Yaah\Constants\SaleFormats;
11
use Radowoj\Yaah\Constants\ShippingPaidBy;
12
13
class MTGAuctionDecoratorTest extends TestCase
14
{
15
16
17
    protected function getTestPhotoArray()
18
    {
19
        return [
20
            __DIR__ . '/i.am.a.photo.file.txt'
21
        ];
22
    }
23
24
25
    protected function getTestArray()
26
    {
27
        return [
28
            'title' => 'Allegro test auction',
29
            'description' => 'Test auction description',
30
            'category' => 6092,
31
            'timespan' => AuctionTimespans::TIMESPAN_3_DAYS,
32
            'quantity' => 100,
33
            'country' => 1,
34
            'region' => 15,
35
            'city' => 'SomeCity',
36
            'postcode' => '12-345',
37
            'condition' => Conditions::CONDITION_NEW,
38
            'sale_format' => SaleFormats::SALE_FORMAT_SHOP,
39
            'buy_now_price' => 43,
40
            'shipping_paid_by' => ShippingPaidBy::SHIPPING_PAID_BY_BUYER,
41
            'post_package_priority_price' => 12,
42
        ];
43
    }
44
45
46
    protected function getTestFidArray()
47
    {
48
        return [
49
            1 => 'Allegro test auction',
50
            24 => 'Test auction description',
51
            2 => 6092,
52
            4 => 0,
53
            5 => 100,
54
            9 => 1,
55
            10 => 15,
56
            11 => 'SomeCity',
57
            32 => '12-345',
58
            20626 => 1,
59
            29 => 1,
60
            8 => 43,
61
            12 => 1,
62
            38 => 12,
63
        ];
64
65
    }
66
67
68 View Code Duplication
    public function testFromArray()
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...
69
    {
70
        $auction = $this->getMockBuilder(Auction::class)
71
            ->setMethods(['fromArray'])
72
            ->getMock();
73
74
        $auction->expects($this->once())
75
            ->method('fromArray')
76
            ->with($this->getTestFidArray())
77
            ->willReturn(null);
78
        $decorator = new MTGAuctionDecorator($auction);
79
80
        $decorator->fromArray($this->getTestArray());
81
    }
82
83
84 View Code Duplication
    public function testToArray()
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...
85
    {
86
        $auction = $this->getMockBuilder(Auction::class)
87
            ->setMethods(['toArray'])
88
            ->getMock();
89
90
        $auction->expects($this->once())
91
            ->method('toArray')
92
            ->willReturn($this->getTestFidArray());
93
        $decorator = new MTGAuctionDecorator($auction);
94
95
        $this->assertSame($this->getTestArray(), $decorator->toArray());
96
    }
97
98
99 View Code Duplication
    public function testSetPhotos()
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...
100
    {
101
        $auction = $this->getMockBuilder(Auction::class)
102
            ->setMethods(['setPhotos'])
103
            ->getMock();
104
105
        $auction->expects($this->once())
106
            ->method('setPhotos')
107
            ->with($this->getTestPhotoArray())
108
            ->willReturn(null);
109
110
        $decorator = new MTGAuctionDecorator($auction);
111
        $decorator->setPhotos($this->getTestPhotoArray());
112
    }
113
114
115
}
116