1 | <?php |
---|
2 | |
---|
3 | /* |
---|
4 | * This file is part of EC-CUBE |
---|
5 | * |
---|
6 | * Copyright(c) 2000-2012 LOCKON CO.,LTD. All Rights Reserved. |
---|
7 | * |
---|
8 | * http://www.lockon.co.jp/ |
---|
9 | * |
---|
10 | * This program is free software; you can redistribute it and/or |
---|
11 | * modify it under the terms of the GNU General Public License |
---|
12 | * as published by the Free Software Foundation; either version 2 |
---|
13 | * of the License, or (at your option) any later version. |
---|
14 | * |
---|
15 | * This program is distributed in the hope that it will be useful, |
---|
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | * GNU General Public License for more details. |
---|
19 | * |
---|
20 | * You should have received a copy of the GNU General Public License |
---|
21 | * along with this program; if not, write to the Free Software |
---|
22 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
23 | */ |
---|
24 | |
---|
25 | /** |
---|
26 | * テストケースで使う一般的なユーティリティを持つクラス. |
---|
27 | * |
---|
28 | * @author Hiroko Tamagawa |
---|
29 | * @version $Id$ |
---|
30 | */ |
---|
31 | class Test_Utils { |
---|
32 | |
---|
33 | /** |
---|
34 | * 連想配列から指定されたキーだけを抜き出したものを返します. |
---|
35 | * 入力の連想配列には変更を加えません. |
---|
36 | * |
---|
37 | * @static |
---|
38 | * @param input_array 入力の連想配列 |
---|
39 | * @param map_keys 出力結果に入れたいキーを配列で指定します |
---|
40 | * @return 指定したキーのみを持つ連想配列 |
---|
41 | */ |
---|
42 | public static function mapArray($input_array, $map_keys) { |
---|
43 | $output_array = array(); |
---|
44 | foreach ($map_keys as $index => $map_key) { |
---|
45 | $output_array[$map_key] = $input_array[$map_key]; |
---|
46 | } |
---|
47 | |
---|
48 | return $output_array; |
---|
49 | } |
---|
50 | |
---|
51 | /** |
---|
52 | * 配列の各要素(連想配列)から特定のキーだけを抜き出した配列を返します. |
---|
53 | * 入力の連想配列には変更を加えません. |
---|
54 | * |
---|
55 | * @static |
---|
56 | * @param input_array 入力の配列 |
---|
57 | * @param key 抽出対象のキー |
---|
58 | * @return 指定のキーだけを抜き出した配列 |
---|
59 | */ |
---|
60 | public static function mapCols($input_array, $key) { |
---|
61 | $output_array = array(); |
---|
62 | foreach ($input_array as $data) { |
---|
63 | $output_array[] = $data[$key]; |
---|
64 | } |
---|
65 | |
---|
66 | return $output_array; |
---|
67 | } |
---|
68 | } |
---|
69 | |
---|