source: branches/version-2_12-multilang/tests/class/util/SC_Utils/SC_Utils_sfArrKeyValueTest.php @ 22278

Revision 22278, 2.9 KB checked in by m_uehara, 11 years ago (diff)

#1955 r22097 - r22098 , r22104 - r22107 , r22111 - r22120 , r22123 - r22129 , r22133 , r22135 - r22143 , r22145 - r22146 , r22158 , r22164 - r22165 , r22167 - r22169 , r22187 - r22196 , r22199 - r22204, r22219 - r22261 間のコミットをマージします。

  • Property svn:keywords set to Id Rev Date
Line 
1<?php
2
3$HOME = realpath(dirname(__FILE__)) . "/../../../..";
4require_once($HOME . "/tests/class/Common_TestCase.php");
5/*
6 * This file is part of EC-CUBE
7 *
8 * Copyright(c) 2000-2012 LOCKON CO.,LTD. All Rights Reserved.
9 *
10 * http://www.lockon.co.jp/
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 */
26
27/**
28 * SC_Utils::sfArrKeyValue()のテストクラス.
29 *
30 *
31 * @author Hiroko Tamagawa
32 * @version $Id$
33 */
34class SC_Utils_sfArrKeyValueTest extends Common_TestCase {
35
36  var $arrList;
37  var $keyname;
38  var $valuename;
39
40  protected function setUp() {
41    // parent::setUp();
42
43    $this->arrList = array(
44      array('testkey' => '1011', 'testvalue' => '2001', 'key' => '3001'),
45      array('testkey' => '2022', 'testvalue' => '2002', 'key' => '3002'),
46      array('testkey' => '3033', 'testvalue' => '2003', 'key' => '3003'),
47      array('testkey' => '4044', 'testvalue' => '2004', 'key' => '3004')
48    );
49    $this->keyname = 'testkey';
50    $this->valuename = 'testvalue';
51  }
52
53  protected function tearDown() {
54    // parent::tearDown();
55  }
56
57  /////////////////////////////////////////
58  public function testSfArrKeyValue_最大長が配列より短い場合_最大長でカットされる() {
59    $len_max = 3;
60
61    $this->expected = array(
62      '1011' => '2001',
63      '2022' => '2002',
64      '3033' => '2003'
65    );
66    $this->actual = SC_Utils::sfArrKeyValue($this->arrList, $this->keyname, $this->valuename, $len_max);
67
68    $this->verify();
69  }
70
71  public function testSfArrKeyValue_最大長が指定されていない場合_全要素が出力される() {
72    $this->expected = array(
73      '1011' => '2001',
74      '2022' => '2002',
75      '3033' => '2003',
76      '4044' => '2004'
77    );
78    $this->actual = SC_Utils::sfArrKeyValue($this->arrList, $this->keyname, $this->valuename, $len_max);
79
80    $this->verify();
81  }
82
83  public function testSfArrKeyValue_キーサイズが短い場合_キーサイズでカットされる() {
84    $len_max = 5;
85    $keysize = 1;
86
87    $this->expected = array(
88      '1...' => '2001',
89      '2...' => '2002',
90      '3...' => '2003',
91      '4...' => '2004'
92    );
93    $this->actual = SC_Utils::sfArrKeyValue($this->arrList, $this->keyname, $this->valuename, $len_max, $keysize);
94
95    $this->verify();
96  }
97
98  //////////////////////////////////////////
99
100}
101
Note: See TracBrowser for help on using the repository browser.