source: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_clearShipmentItemTempTest.php @ 22135

Revision 22135, 3.0 KB checked in by shift_hiroko.tamagawa, 9 years ago (diff)

DB操作の例を追加

Line 
1<?php
2
3$HOME = realpath(dirname(__FILE__)) . "/../../../..";
4require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php");
5/**
6 *
7 */
8class SC_Helper_Purchase_clearShipmentItemTempTest extends SC_Helper_Purchase_TestBase {
9
10  protected function setUp() {
11    parent::setUp();
12  }
13
14  protected function tearDown() {
15    parent::tearDown();
16  }
17
18  /////////////////////////////////////////
19  public function testClearShipmentItem_配送先ID未指定の場合_全ての配送商品がクリアされる() {
20    $this->setUpShipping($this->getMultipleShipping());
21
22    $helper = new SC_Helper_Purchase();
23    $helper->clearShipmentItemTemp(); // default:null
24
25    $this->expected = array('00001'=>null, '00002'=>null, '00003'=>null);
26    $this->actual['00001'] = $_SESSION['shipping']['00001']['shipment_item'];
27    $this->actual['00002'] = $_SESSION['shipping']['00002']['shipment_item'];
28    $this->actual['00003'] = $_SESSION['shipping']['00003']['shipment_item'];
29
30    $this->verify('配送商品');
31  }
32
33  public function testClearShipmentItem_配送先ID指定の場合_指定したIDの配送商品がクリアされる() {
34    $this->setUpShipping($this->getMultipleShipping());
35
36    $helper = new SC_Helper_Purchase();
37    $helper->clearShipmentItemTemp('00001');
38
39    $this->expected = array('00001'=>null, '00002'=>array('商品2'), '00003'=>array());
40    $this->actual['00001'] = $_SESSION['shipping']['00001']['shipment_item'];
41    $this->actual['00002'] = $_SESSION['shipping']['00002']['shipment_item'];
42    $this->actual['00003'] = $_SESSION['shipping']['00003']['shipment_item'];
43
44    $this->verify('配送商品');
45  }
46
47  public function testClearShipmentItem_存在しないIDを指定した場合_何も変更されない() {
48    $this->setUpShipping($this->getMultipleShipping());
49
50    $helper = new SC_Helper_Purchase();
51    $helper->clearShipmentItemTemp('00004');
52
53    $this->expected = array('00001'=>array('商品1'), '00002'=>array('商品2'), '00003'=>array());
54    $this->actual['00001'] = $_SESSION['shipping']['00001']['shipment_item'];
55    $this->actual['00002'] = $_SESSION['shipping']['00002']['shipment_item'];
56    $this->actual['00003'] = $_SESSION['shipping']['00003']['shipment_item'];
57
58    $this->verify('配送商品');
59  }
60
61  public function testClearShipmentItem_商品情報が配列でない場合_何も変更されない() {
62    $this->setUpShipping($this->getMultipleShipping());
63    // 内容を配列でないように変更
64    $_SESSION['shipping']['00001'] = 'temp';
65
66    $helper = new SC_Helper_Purchase();
67    $helper->clearShipmentItemTemp('00001');
68
69    // '00001'は配列でないので全体を取得
70    $this->expected = array('00001'=>'temp', '00002'=>array('商品2'), '00003'=>array());
71    $this->actual['00001'] = $_SESSION['shipping']['00001'];
72    $this->actual['00002'] = $_SESSION['shipping']['00002']['shipment_item'];
73    $this->actual['00003'] = $_SESSION['shipping']['00003']['shipment_item'];
74
75    $this->verify('配送商品');
76  }
77
78}
79
Note: See TracBrowser for help on using the repository browser.