Test Failed
Push — develop ( 931179...6ca68b )
by Aya
02:37
created

GetOrderInfoRequestTest::seller_id_is_not_set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Shippinno\YahooShoppingJp\Request;
4
5
use DateTimeImmutable;
6
use PHPUnit\Framework\TestCase;
7
use Shippinno\YahooShoppingJp\Enum\ShipMethod;
8
use Shippinno\YahooShoppingJp\Enum\ShipStatus;
9
10
class GetOrderInfoRequestTest extends TestCase
11
{
12
    /**
13
     * @test
14
     */
15 View Code Duplication
    public function it_sets_seller_id_and_returns_itself()
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...
16
    {
17
        $request = new GetOrderInfoRequest();
18
19
        $this->assertSame($request,
20
                        $request->setSellerId('SELLER_ID')
21
                                ->setOrderId('ORDER_ID'));
22
        $simpleXml = simplexml_load_string($request->getParams());
23
24
        $this->assertEquals('SELLER_ID', $simpleXml->SellerId->__toString());
25
    }
26
27
    /**
28
     * @test
29
     * @expectedException \LogicException
30
     */
31
    public function it_cannot_set_seller_id_more_than_once()
32
    {
33
        $request = new GetOrderInfoRequest;
34
        $this->assertSame($request, $request->setSellerId('SELLER_ID_1'));
35
36
        $request->setSellerId('SELLER_ID_2');
37
    }
38
39
    /**
40
     * @test
41
     */
42 View Code Duplication
    public function it_sets_order_id_and_returns_itself()
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...
43
    {
44
        $request = new GetOrderInfoRequest;
45
46
        $this->assertSame($request,
47
            $request->setSellerId('SELLER_ID')
48
                ->setOrderId('ORDER_ID'));
49
        $simpleXml = simplexml_load_string($request->getParams());
50
51
        $this->assertEquals('ORDER_ID', $simpleXml->Target->OrderId->__toString());
52
    }
53
54
    /**
55
     * @test
56
     * @expectedException \LogicException
57
     */
58
    public function it_cannot_set_order_id_more_than_once()
59
    {
60
        $request = new GetOrderInfoRequest;
61
        $this->assertSame($request, $request->setOrderId('ORDER_ID_1'));
62
63
        $request->setOrderId('ORDER_ID_2');
64
    }
65
66
    /**
67
     * @test
68
     * @expectedException \Shippinno\YahooShoppingJp\Exception\InvalidRequestException
69
     * @expectedExceptionMessage SellerId is required.
70
     */
71
    public function seller_id_is_not_set()
72
    {
73
        $request = new GetOrderInfoRequest;
74
75
        $this->assertSame($request, $request->setOrderId('ORDER_ID_1'));
76
        $request->getParams();
77
    }
78
79
    /**
80
     * @test
81
     * @expectedException \Shippinno\YahooShoppingJp\Exception\InvalidRequestException
82
     * @expectedExceptionMessage OrderId is required.
83
     */
84
    public function order_id_is_not_set()
85
    {
86
        $request = new GetOrderInfoRequest;
87
88
        $this->assertSame($request, $request->setSellerId('valid-seller-id'));
89
        $request->getParams();
90
    }
91
}
92