-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathAngularParserTest.php
More file actions
134 lines (126 loc) · 2.73 KB
/
AngularParserTest.php
File metadata and controls
134 lines (126 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* Current::read()のテスト
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('AngularParser', 'NetCommons.Lib');
/**
* AngularParser::parse()のテスト
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @package NetCommons\NetCommons\Test\Case\Lib\Current
*/
class AngularParserTest extends CakeTestCase {
/**
* DataProvider
*
* @return array テストデータ
*/
public function dataProvider() {
$results = [];
$results['test_case_0'] = [
'input' => [
'{{0_root}}',
'1_root',
'Test1_1' => '{{Test1_1}}',
'Test1_2' => 'Test1_2',
'Test2' => [
'{{Test2_0}}',
'Test2_1'
],
'Test3' => [
'id' => '{{Test3_id}}'
],
'Test4' => [
'id' => '{{Test3_id}}',
'Test4_1' => [
'{{Test4_0_0}}',
'Test4_1_1',
'id' => '{{Test4_1_id}}',
'Test4_1_1' => [
'{{Test4_1_1_0}}',
'Test4_1_1_1',
'id' => '{{Test4_1_1_id}}',
],
],
],
],
'expect' => [
'{ { 0_root } }',
'1_root',
'Test1_1' => '{ { Test1_1 } }',
'Test1_2' => 'Test1_2',
'Test2' => [
'{ { Test2_0 } }',
'Test2_1'
],
'Test3' => [
'id' => '{ { Test3_id } }'
],
'Test4' => [
'id' => '{ { Test3_id } }',
'Test4_1' => [
'{ { Test4_0_0 } }',
'Test4_1_1',
'id' => '{ { Test4_1_id } }',
'Test4_1_1' => [
'{ { Test4_1_1_0 } }',
'Test4_1_1_1',
'id' => '{ { Test4_1_1_id } }',
],
],
],
],
];
$results['test_case_1'] = [
'input' => [
'{{{root_1}}}',
'{{{{{root_1}}}}}',
'{ {{root_2}} }',
'{{ {root_3} }}',
'{{{{root_4}}}}',
],
'expect' => [
'{ { {root_1 } } }',
'{ { { { {root_1 } } } } }',
'{ { { root_2 } } }',
'{ { {root_3} } }',
'{ { { { root_4 } } } }',
],
];
return $results;
}
/**
* AngularParser::parse()のテスト
*
* @param array $input 入力値
* @param array $expect 期待値
* @dataProvider dataProvider
* @return void
*/
public function testParser($input, $expect) {
//テスト実施
AngularParser::parse($input);
//debug($input);
$this->assertEquals($input, $expect);
}
/**
* AngularParser::convertText()のテスト
*
* @param array $input 入力値
* @param array $expect 期待値
* @dataProvider dataProvider
* @return void
*/
public function testConvertText($input, $expect) {
//テスト実施
$input[0] = AngularParser::convertText($input[0]);
//debug($input);
$this->assertEquals($input[0], $expect[0]);
}
}