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

Revision 22128, 2.1 KB checked in by shift_hiroko.tamagawa, 9 years ago (diff)

単体テスト用基盤クラスと一部テストコードを追加

Line 
1<?php
2
3$HOME = realpath(dirname(__FILE__)) . "/../../../..";
4require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_BaseTest.php");
5/**
6 *
7 */
8class SC_Helper_Purchase_saveShippingTempTest extends SC_Helper_Purchase_BaseTest {
9
10  protected function setUp() {
11    parent::setUp();
12  }
13
14  protected function tearDown() {
15    parent::tearDown();
16  }
17
18  /////////////////////////////////////////
19  public function testSaveShippingTemp_元々存在しない配送先IDの場合_新規に配列が作られる() {
20    $this->setUpShipping($this->getMultipleShipping());
21
22    SC_Helper_Purchase::saveShippingTemp(
23      array('shipment_item' => '商品4', 'shipping_pref' => '大阪府')
24    );
25
26    $this->expected = array(
27      'count'=>4,                // 配送情報全体の件数
28      'shipping_id'=>0,
29      'shipment_item'=>null,
30      'shipping_pref'=>'大阪府'
31    );
32    $this->actual['count'] = count($_SESSION['shipping']);
33    $this->actual['shipping_id'] = $_SESSION['shipping']['0']['shipping_id'];
34    $this->actual['shipment_item'] = $_SESSION['shipping']['0']['shipment_item'];
35    $this->actual['shipping_pref'] = $_SESSION['shipping']['0']['shipping_pref'];
36
37    $this->verify('登録した配送情報');
38  }
39
40  public function testSaveShippingTemp_元々存在する配送先IDの場合_情報がマージされる() {
41    $this->setUpShipping($this->getMultipleShipping());
42
43    SC_Helper_Purchase::saveShippingTemp(
44      array('shipment_item' => '商品4', 'shipping_pref' => '大阪府'),
45      '00001'
46    );
47
48    $this->expected = array(
49      'count'=>3,                // 配送情報全体の件数
50      'shipping_id'=>'00001',
51      'shipment_item'=>array('商品1'),
52      'shipping_pref'=>'大阪府'
53    );
54    $this->actual['count'] = count($_SESSION['shipping']);
55    $this->actual['shipping_id'] = $_SESSION['shipping']['00001']['shipping_id'];
56    $this->actual['shipment_item'] = $_SESSION['shipping']['00001']['shipment_item'];
57    $this->actual['shipping_pref'] = $_SESSION['shipping']['00001']['shipping_pref'];
58   
59    $this->verify('更新した配送情報');
60  }
61
62}
63
Note: See TracBrowser for help on using the repository browser.