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

Revision 22567, 2.9 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

  • 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-2013 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
37  var $arrList;
38  var $keyname;
39  var $valuename;
40
41  protected function setUp()
42  {
43    // parent::setUp();
44
45    $this->arrList = array(
46      array('testkey' => '1011', 'testvalue' => '2001', 'key' => '3001'),
47      array('testkey' => '2022', 'testvalue' => '2002', 'key' => '3002'),
48      array('testkey' => '3033', 'testvalue' => '2003', 'key' => '3003'),
49      array('testkey' => '4044', 'testvalue' => '2004', 'key' => '3004')
50    );
51    $this->keyname = 'testkey';
52    $this->valuename = 'testvalue';
53  }
54
55  protected function tearDown()
56  {
57    // parent::tearDown();
58  }
59
60  /////////////////////////////////////////
61  public function testSfArrKeyValue_最大長が配列より短い場合_最大長でカットされる()
62  {
63    $len_max = 3;
64
65    $this->expected = array(
66      '1011' => '2001',
67      '2022' => '2002',
68      '3033' => '2003'
69    );
70    $this->actual = SC_Utils::sfArrKeyValue($this->arrList, $this->keyname, $this->valuename, $len_max);
71
72    $this->verify();
73  }
74
75  public function testSfArrKeyValue_最大長が指定されていない場合_全要素が出力される()
76  {
77    $this->expected = array(
78      '1011' => '2001',
79      '2022' => '2002',
80      '3033' => '2003',
81      '4044' => '2004'
82    );
83    $this->actual = SC_Utils::sfArrKeyValue($this->arrList, $this->keyname, $this->valuename, $len_max);
84
85    $this->verify();
86  }
87
88  public function testSfArrKeyValue_キーサイズが短い場合_キーサイズでカットされる()
89  {
90    $len_max = 5;
91    $keysize = 1;
92
93    $this->expected = array(
94      '1...' => '2001',
95      '2...' => '2002',
96      '3...' => '2003',
97      '4...' => '2004'
98    );
99    $this->actual = SC_Utils::sfArrKeyValue($this->arrList, $this->keyname, $this->valuename, $len_max, $keysize);
100
101    $this->verify();
102  }
103
104  //////////////////////////////////////////
105
106}
107
Note: See TracBrowser for help on using the repository browser.