1 | <?php |
---|
2 | |
---|
3 | $HOME = realpath(dirname(__FILE__)) . "/../../../.."; |
---|
4 | require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php"); |
---|
5 | /** |
---|
6 | * |
---|
7 | */ |
---|
8 | class SC_Helper_Purchase_registerShippingTest extends SC_Helper_Purchase_TestBase { |
---|
9 | |
---|
10 | protected function setUp() { |
---|
11 | parent::setUp(); |
---|
12 | $this->setUpShippingOnDb(); |
---|
13 | } |
---|
14 | |
---|
15 | protected function tearDown() { |
---|
16 | parent::tearDown(); |
---|
17 | } |
---|
18 | |
---|
19 | ///////////////////////////////////////// |
---|
20 | public function testRegisterShipping_元々存在しない受注IDの場合_新規にデータが作られる() { |
---|
21 | $order_id = '10'; |
---|
22 | $arrParams = array( |
---|
23 | '20' => |
---|
24 | array( |
---|
25 | 'order_id' => '10', |
---|
26 | 'shipping_id' => '20', |
---|
27 | 'shipping_name01' => '配送情報10', |
---|
28 | 'shipping_date' => '2012/01/12' |
---|
29 | ) |
---|
30 | ); |
---|
31 | |
---|
32 | $this->expected['count'] = '4'; // 1件増える |
---|
33 | $this->expected['content'] = array( |
---|
34 | 'order_id' => '10', |
---|
35 | 'shipping_id' => '20', |
---|
36 | 'shipping_name01' => '配送情報10', |
---|
37 | 'shipping_date' => '2012-01-12 00:00:00' |
---|
38 | ); |
---|
39 | |
---|
40 | SC_Helper_Purchase::registerShipping($order_id, $arrParams); |
---|
41 | |
---|
42 | $this->actual['count'] = $this->objQuery->count('dtb_shipping'); |
---|
43 | $this->result = $this->objQuery->setWhere('order_id = ?') |
---|
44 | ->select( |
---|
45 | 'order_id,shipping_id,shipping_name01,shipping_date,create_date,update_date', |
---|
46 | 'dtb_shipping', |
---|
47 | '', |
---|
48 | array($order_id)); |
---|
49 | $this->actual['content'] = $this->result[0]; |
---|
50 | unset($this->actual['content']['create_date']); |
---|
51 | unset($this->actual['content']['update_date']); |
---|
52 | $this->verify('登録した配送情報'); |
---|
53 | $this->assertNotNull($this->result[0]['create_date']); |
---|
54 | $this->assertNotNull($this->result[0]['update_date']); |
---|
55 | } |
---|
56 | |
---|
57 | public function testRegisterShipping_元々存在する受注IDの場合_既存のデータが置き換えられる() { |
---|
58 | $order_id = '2'; |
---|
59 | $arrParams = array( |
---|
60 | '30' => |
---|
61 | array( |
---|
62 | 'order_id' => '2', |
---|
63 | 'shipping_id' => '30', |
---|
64 | 'shipping_name01' => '配送情報02-update', |
---|
65 | 'shipping_date' => '2013/12/03' |
---|
66 | ) |
---|
67 | ); |
---|
68 | |
---|
69 | $this->expected['count'] = '3'; // 件数が変わらない |
---|
70 | $this->expected['content'] = array( |
---|
71 | 'order_id' => '2', |
---|
72 | 'shipping_id' => '30', |
---|
73 | 'shipping_name01' => '配送情報02-update', |
---|
74 | 'shipping_date' => '2013-12-03 00:00:00' |
---|
75 | ); |
---|
76 | |
---|
77 | SC_Helper_Purchase::registerShipping($order_id, $arrParams); |
---|
78 | |
---|
79 | $this->actual['count'] = $this->objQuery->count('dtb_shipping'); |
---|
80 | $this->result = $this->objQuery->setWhere('order_id = ?') |
---|
81 | ->select( |
---|
82 | 'order_id,shipping_id,shipping_name01,shipping_date,create_date,update_date', |
---|
83 | 'dtb_shipping', |
---|
84 | '', |
---|
85 | array($order_id)); |
---|
86 | $this->actual['content'] = $this->result[0]; |
---|
87 | unset($this->actual['content']['create_date']); |
---|
88 | unset($this->actual['content']['update_date']); |
---|
89 | $this->verify('登録した配送情報'); |
---|
90 | $this->assertNotNull($this->result[0]['create_date']); |
---|
91 | $this->assertNotNull($this->result[0]['update_date']); |
---|
92 | } |
---|
93 | |
---|
94 | public function testRegisterShipping_配送日付が空の場合_エラーが起きず変換処理がスキップされる() { |
---|
95 | $order_id = '2'; |
---|
96 | $arrParams = array( |
---|
97 | '30' => |
---|
98 | array( |
---|
99 | 'order_id' => '2', |
---|
100 | 'shipping_id' => '30', |
---|
101 | 'shipping_name01' => '配送情報02-update' |
---|
102 | // 'shipping_date' => '2013/12/03 00:00:00' |
---|
103 | ) |
---|
104 | ); |
---|
105 | |
---|
106 | $this->expected['count'] = '3'; |
---|
107 | $this->expected['content'] = array( |
---|
108 | 'order_id' => '2', |
---|
109 | 'shipping_id' => '30', |
---|
110 | 'shipping_name01' => '配送情報02-update', |
---|
111 | 'shipping_date' => NULL |
---|
112 | ); |
---|
113 | |
---|
114 | SC_Helper_Purchase::registerShipping($order_id, $arrParams); |
---|
115 | |
---|
116 | $this->actual['count'] = $this->objQuery->count('dtb_shipping'); |
---|
117 | $this->result = $this->objQuery->setWhere('order_id = ?') |
---|
118 | ->select( |
---|
119 | 'order_id,shipping_id,shipping_name01,shipping_date,create_date,update_date', |
---|
120 | 'dtb_shipping', |
---|
121 | '', |
---|
122 | array($order_id)); |
---|
123 | $this->actual['content'] = $this->result[0]; |
---|
124 | unset($this->actual['content']['create_date']); |
---|
125 | unset($this->actual['content']['update_date']); |
---|
126 | $this->verify('登録した配送情報'); |
---|
127 | $this->assertNotNull($this->result[0]['create_date']); |
---|
128 | $this->assertNotNull($this->result[0]['update_date']); |
---|
129 | } |
---|
130 | |
---|
131 | public function testRegisterShipping_非会員購入の場合_配送IDが設定される() { |
---|
132 | $order_id = '2'; |
---|
133 | $arrParams = array( |
---|
134 | '30' => |
---|
135 | array( |
---|
136 | 'order_id' => '2', |
---|
137 | // 'shipping_id' => '30', |
---|
138 | 'shipping_name01' => '配送情報02-update', |
---|
139 | 'shipping_date' => '2013/12/03 00:00:00' |
---|
140 | ) |
---|
141 | ); |
---|
142 | |
---|
143 | $this->expected['count'] = '3'; // 件数が変わらない |
---|
144 | $this->expected['content'] = array( |
---|
145 | 'order_id' => '2', |
---|
146 | 'shipping_id' => '30', |
---|
147 | 'shipping_name01' => '配送情報02-update', |
---|
148 | 'shipping_date' => '2013-12-03 00:00:00' |
---|
149 | ); |
---|
150 | |
---|
151 | SC_Helper_Purchase::registerShipping($order_id, $arrParams); |
---|
152 | |
---|
153 | $this->actual['count'] = $this->objQuery->count('dtb_shipping'); |
---|
154 | $this->result = $this->objQuery->setWhere('order_id = ?') |
---|
155 | ->select( |
---|
156 | 'order_id,shipping_id,shipping_name01,shipping_date,create_date,update_date', |
---|
157 | 'dtb_shipping', |
---|
158 | '', |
---|
159 | array($order_id)); |
---|
160 | $this->actual['content'] = $this->result[0]; |
---|
161 | unset($this->actual['content']['create_date']); |
---|
162 | unset($this->actual['content']['update_date']); |
---|
163 | $this->verify('登録した配送情報'); |
---|
164 | $this->assertNotNull($this->result[0]['create_date']); |
---|
165 | $this->assertNotNull($this->result[0]['update_date']); |
---|
166 | } |
---|
167 | |
---|
168 | ////////////////////////////////////////// |
---|
169 | |
---|
170 | } |
---|
171 | |
---|