Test Failed
Push — feature/families ( a480a1...94ad9a )
by Yuji
11:24
created

GetItemStockInfoRequestTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 149
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 149
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_cannot_set_seller_id_more_than_once() 0 7 1
A it_cannot_set_item_code_more_than_1000() 0 11 2
A it_cannot_set_item_code_duplicately() 0 10 1
A it_cannot_set_an_item_code_of_empty_character() 0 7 1
A it_cannot_set_an_item_code_of_100_characters_or_more() 0 7 1
1
<?php
2
3
namespace Shippinno\YahooShoppingJp\Request;
4
5
use PHPUnit\Framework\TestCase;
6
7
class GetItemStockInfoRequestTest extends TestCase
8
{
9
    /**
10
     * @test
11
     * @expectedException \LogicException
12
     * @expectedExceptionMessage seller_id is already set.
13
     */
14
    public function it_cannot_set_seller_id_more_than_once()
15
    {
16
        $request = new GetItemStockInfoRequest;
17
        $this->assertSame($request, $request->setSellerId('SELLER_ID_1'));
18
19
        $request->setSellerId('SELLER_ID_2');
20
    }
21
22
    /**
23
     * @test
24
     * @expectedException \LogicException
25
     * @expectedExceptionMessage The number of the item_code must be less than 1000.
26
     */
27
    public function it_cannot_set_item_code_more_than_1000()
28
    {
29
        $request = new GetItemStockInfoRequest;
30
        $this->assertSame($request, $request->setSellerId('VALID_SELLER_ID'));
31
32
        for ($i = 1; $i <= 1001; $i++) {
33
            $request->addItemCode('AN_ITEM_CODE_' . $i);
34
        }
35
36
        $request->getParams();
37
    }
38
39
    /**
40
     * @test
41
     * @expectedException \LogicException
42
     * @expectedExceptionMessage Some of item_code are duplicated.
43
     */
44
    public function it_cannot_set_item_code_duplicately()
45
    {
46
        $request = new GetItemStockInfoRequest;
47
        $this->assertSame($request, $request->setSellerId('VALID_SELLER_ID'));
48
49
        $request->addItemCode('AN_ITEM_CODE');
50
        $request->addItemCode('AN_ITEM_CODE');
51
52
        $request->getParams();
53
    }
54
55
    /**
56
     * @test
57
     * @expectedException \InvalidArgumentException
58
     * @expectedExceptionMessage The item_code cannot be empty.
59
     */
60
    public function it_cannot_set_an_item_code_of_empty_character()
61
    {
62
        $request = new GetItemStockInfoRequest;
63
        $this->assertSame($request, $request->setSellerId('VALID_SELLER_ID'));
64
65
        $request->addItemCode('');
66
    }
67
68
    /**
69
     * @test
70
     * @expectedException \InvalidArgumentException
71
     * @expectedExceptionMessage The item_code must be less than 99 characters.
72
     */
73
    public function it_cannot_set_an_item_code_of_100_characters_or_more()
74
    {
75
        $request = new GetItemStockInfoRequest;
76
        $this->assertSame($request, $request->setSellerId('VALID_SELLER_ID'));
77
78
        $request->addItemCode(str_repeat('a', 100));
79
    }
80
81
//    /**
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
82
//     * @test
83
//     */
84
//    public function seller_id_is_number_or_alphabet_lowercase_or_dash_set()
85
//    {
86
//        $request = new UpdateItemStockInfoRequest;
87
//        $this->assertSame($request, $request->setSellerId('valid-seller-id'));
88
//    }
89
90
//    /**
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
91
//     * @test
92
//     */
93
//    public function item_code_and_sub_code_is_number_or_alphabet_upper_or_lowercase_or_dash_set()
94
//    {
95
//        $request = new UpdateItemStockInfoRequest;
96
//        $this->assertSame($request, $request->setItemCode('VALID-ITEM-CODE', 'SUB-CODE'));
97
//    }
98
99
//    /**
100
//     * @test
101
//     * @expectedException \Shippinno\YahooShoppingJp\Exception\InvalidRequestException
102
//     * @expectedExceptionMessage item_code error.
103
//     */
104
//    public function item_code_is_only_number_or_alphabet_upper_or_lowercase_or_dash_set()
105
//    {
106
//        $request = new UpdateItemStockInfoRequest;
107
//        $this->assertSame($request, $request->setItemCode('VALID_ITEM_CODE'));
108
//    }
109
110
//    /**
111
//     * @test
112
//     * @expectedException \Shippinno\YahooShoppingJp\Exception\InvalidRequestException
113
//     * @expectedExceptionMessage sub_code error.
114
//     */
115
//    public function sub_code_is_only_number_or_alphabet_upper_or_lowercase_or_dash_set()
116
//    {
117
//        $request = new UpdateItemStockInfoRequest;
118
//        $this->assertSame($request, $request->setItemCode('VALID-ITEM-CODE', 'SUB_CODE'));
119
//    }
120
121
//    /**
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
122
//     * @test
123
//     * @expectedException \Shippinno\YahooShoppingJp\Exception\InvalidRequestException
124
//     * @expectedExceptionMessage Only number or INI can be set.
125
//     */
126
//    public function quantity_is_only_number_or_string_ini_set()
127
//    {
128
//        $request = new UpdateItemStockInfoRequest;
129
//        $this->assertSame($request, $request->setQuantity('INT'));
130
//    }
131
//    /**
132
//     * @test
133
//     */
134
//    public function allow_overdraft_is_boolean_set()
135
//    {
136
//        $request = new UpdateItemStockInfoRequest;
137
//        $this->assertSame($request, $request->setAllowOverdraft(true));
138
//    }
139
//    /**
140
//     * @test
141
//     */
142
//    public function get_params_is_set()
143
//    {
144
//        $request = new UpdateItemStockInfoRequest;
145
//        $this->assertSame($request, $request->setSellerId('valid-seller-id'));
146
//        $this->assertSame($request, $request->setItemCode('VALID-ITEM-CODE', 'SUB-CODE'));
147
//        $this->assertSame($request, $request->setQuantity(999999999));
148
//        $this->assertSame($request, $request->setAllowOverdraft(true));
149
//        $params = $request->getParams();
150
//        $this->assertSame('valid-seller-id', $params['seller_id']);
151
//        $this->assertSame('VALID-ITEM-CODE:SUB-CODE', $params['item_code']);
152
//        $this->assertSame('999999999', $params['quantity']);
153
//        $this->assertSame(1, $params['allow_overdraft']);
154
//    }
155
}
156