Test Failed
Pull Request — feature/families (#15)
by
unknown
02:44
created

validate_OrderStatus_and_IsPointFix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Shippinno\YahooShoppingJp\Request;
4
5
use PHPUnit\Framework\TestCase;
6
use Shippinno\YahooShoppingJp\Enum\OrderStatus;
7
use Shippinno\YahooShoppingJp\Enum\CancelReason;
8
9
class UpdateOrderStatusTest extends TestCase
10
{
11
    protected $SellerId;
12
    protected $OrderId;
13
    protected $IsPointFix;
14
    protected $OrderStatus;
15
    protected $CancelReason;
16
    protected $OperationUser;
17
18
    protected function setUp()
19
    {
20
        $this->SellerId      = 'SELLER_ID';
21
        $this->OrderId       = 'ORDER_ID';
22
        $this->IsPointFix    = true;
23
        $this->OrderStatus   = OrderStatus::PROCESSED();
24
        $this->OperationUser = 'OPERATION_USER';
25
        $this->CancelReason  = CancelReason::ADDRESS_UNKNOWN();
26
    }
27
28
    /**
29
     * @test
30
     */
31
    public function create_instance()
32
    {
33
        $request = new UpdateOrderStatusRequest;
34
        $this->assertInstanceOf(UpdateOrderStatusRequest::class, $request);
35
36
        $this->assertSame($request, $request->setSellerId($this->SellerId));
37
        $this->assertSame($request, $request->setOrderId($this->OrderId));
38
        $this->assertSame($request, $request->setIsPointFix($this->IsPointFix));
39
        $this->assertSame($request, $request->setOrderStatus($this->OrderStatus));
40
        $this->assertSame($request, $request->setOperationUser($this->OperationUser));
41
        $this->assertSame($request, $request->setCancelReason($this->CancelReason));
42
43
        return $request;
44
    }
45
46
    /**
47
     * @test
48
     * @depends create_instance
49
     */
50
    public function check_SellerId_value($instance)
51
    {
52
        $simpleXml = simplexml_load_string($instance->getParams());
53
54
        $this->assertEquals($this->SellerId, $simpleXml->SellerId->__toString());
55
    }
56
57
    /**
58
     * @test
59
     * @depends create_instance
60
     * @expectedException \LogicException
61
     */
62
    public function set_SellerId_once($incetance)
63
    {
64
        $incetance->setSellerId('SELLER_ID_ONCE');
65
    }
66
67
    /**
68
     * @test
69
     * @depends create_instance
70
     */
71
    public function check_OrderId_value($instance)
72
    {
73
        $simpleXml = simplexml_load_string($instance->getParams());
74
75
        $this->assertEquals($this->OrderId, $simpleXml->Target->OrderId->__toString());
76
    }
77
78
    /**
79
     * @test
80
     * @depends create_instance
81
     * @expectedException \LogicException
82
     */
83
    public function set_OrderId_once($incetance)
84
    {
85
        $incetance->setOrderId('ORDER_ID_ONCE');
86
    }
87
88
    /**
89
     * @test
90
     * @depends create_instance
91
     */
92
    public function check_IsPointFix_value($instance)
93
    {
94
        $simpleXml = simplexml_load_string($instance->getParams());
95
96
        $this->assertEquals(var_export($this->IsPointFix, TRUE), $simpleXml->Target->IsPointFix->__toString());
97
    }
98
99
    /**
100
     * @test
101
     * @depends create_instance
102
     * @expectedException \LogicException
103
     */
104
    public function set_IsPointFix_once($incetance)
105
    {
106
        $incetance->setIsPointFix($this->IsPointFix);
107
    }
108
109
    /**
110
     * @test
111
     * @depends create_instance
112
     */
113
    public function check_OrderStatus_value($instance)
114
    {
115
        $simpleXml = simplexml_load_string($instance->getParams());
116
117
        $this->assertEquals($this->OrderStatus->getValue(), $simpleXml->Order->OrderStatus->__toString());
118
    }
119
120
    /**
121
     * @test
122
     * @depends create_instance
123
     * @expectedException \LogicException
124
     */
125
    public function set_OrderStatus_once($incetance)
126
    {
127
        $incetance->setOrderStatus($this->OrderStatus);
128
    }
129
130
    /**
131
     * @test
132
     * @depends create_instance
133
     * @expectedException \LogicException
134
     */
135
    public function set_OperationUser_once($incetance)
136
    {
137
        $incetance->setOperationUser($this->OperationUser);
138
    }
139
140
    /**
141
     * @test
142
     * @depends create_instance
143
     */
144
    public function check_OperationUser_value($instance)
145
    {
146
        $simpleXml = simplexml_load_string($instance->getParams());
147
148
        $this->assertEquals($this->OperationUser, $simpleXml->Target->OperationUser->__toString());
149
    }
150
151
    /**
152
     * @test
153
     * @depends create_instance
154
     * @expectedException \LogicException
155
     */
156
    public function set_CancelReason_once($incetance)
157
    {
158
        $incetance->setCancelReason($this->CancelReason);
159
    }
160
161
    /**
162
     * @test
163
     * @depends create_instance
164
     */
165
    public function check_CancelReason_value($instance)
166
    {
167
        $simpleXml = simplexml_load_string($instance->getParams());
168
169
        $this->assertEquals($this->CancelReason->getValue(), $simpleXml->Order->CancelReason->__toString());
170
    }
171
172
    /**
173
     * @test
174
     * @expectedException Shippinno\YahooShoppingJp\Exception\InvalidRequestException
175
     */
176
    public function validate_not_set_SellerId()
177
    {
178
        $request = (new UpdateOrderStatusRequest)
179
            ->setOrderId($this->OrderId)
180
            ->setIsPointFix($this->IsPointFix)
181
            ->setOrderStatus($this->OrderStatus);
182
183
        $request->getParams();
184
    }
185
186
    /**
187
     * @test
188
     * @expectedException Shippinno\YahooShoppingJp\Exception\InvalidRequestException
189
     */
190
    public function validate_not_set_OrderId()
191
    {
192
        $request = (new UpdateOrderStatusRequest)
193
            ->setSellerId($this->SellerId)
194
            ->setIsPointFix($this->IsPointFix)
195
            ->setOrderStatus($this->OrderStatus);
196
197
        $request->getParams();
198
    }
199
200
    /**
201
     * @test
202
     * @expectedException Shippinno\YahooShoppingJp\Exception\InvalidRequestException
203
     */
204
    public function validate_not_set_IsPointFix()
205
    {
206
        $request = (new UpdateOrderStatusRequest)
207
            ->setSellerId($this->SellerId)
208
            ->setOrderId($this->OrderId)
209
            ->setOrderStatus($this->OrderStatus);
210
211
        $request->getParams();
212
    }
213
214
    /**
215
     * @test
216
     * @expectedException Shippinno\YahooShoppingJp\Exception\InvalidRequestException
217
     */
218
    public function validate_not_set_OrderStatus()
219
    {
220
        $request = (new UpdateOrderStatusRequest)
221
            ->setSellerId($this->SellerId)
222
            ->setOrderId($this->OrderId)
223
            ->setIsPointFix($this->IsPointFix);
224
225
        $request->getParams();
226
    }
227
228
    /**
229
     * @test
230
     * @expectedException Shippinno\YahooShoppingJp\Exception\InvalidRequestException
231
     */
232
    public function validate_OrderStatus_and_IsPointFix()
233
    {
234
        $request = (new UpdateOrderStatusRequest)
235
            ->setSellerId($this->SellerId)
236
            ->setOrderId($this->OrderId);
237
238
        $request
239
            ->setIsPointFix(false)
240
            ->setOrderStatus(OrderStatus::PROCESSED());
241
242
        $request->getParams();
243
    }
244
245
}
246