4
4
5
5
class TableColumnLinkTest extends \atk4 \core \PHPUnit_AgileTestCase
6
6
{
7
+ use Concerns \HandlesTable;
8
+
7
9
public $ db ;
8
10
public $ table ;
9
11
public $ column ;
@@ -27,7 +29,7 @@ public function testgetDataRowHTML()
27
29
28
30
$ this ->assertEquals (
29
31
'<tr data-id="1"><td>bar</td><td>ref123</td></tr> ' ,
30
- $ this ->extract ($ this ->table -> render () )
32
+ $ this ->extractTableRow ($ this ->table )
31
33
);
32
34
}
33
35
@@ -39,7 +41,7 @@ public function testMultipleFormatters()
39
41
40
42
$ this ->assertEquals (
41
43
'<tr data-id="1"><td><b>bar</b></td><td>ref123</td></tr> ' ,
42
- $ this ->extract ($ this ->table -> render () )
44
+ $ this ->extractTableRow ($ this ->table )
43
45
);
44
46
}
45
47
@@ -54,7 +56,7 @@ public function testTDLast()
54
56
55
57
$ this ->assertEquals (
56
58
'<tr data-id="1"><td>bar</td><td>ref123</td><td class="negative right aligned single line">-123</td></tr> ' ,
57
- $ this ->extract ($ this ->table -> render () )
59
+ $ this ->extractTableRow ($ this ->table )
58
60
);
59
61
}
60
62
@@ -70,7 +72,7 @@ public function testTDNotLast()
70
72
71
73
$ this ->assertEquals (
72
74
'<tr data-id="1"><td>bar</td><td>ref123</td><td class="negative right aligned single line"><b>-123</b></td></tr> ' ,
73
- $ this ->extract ($ this ->table -> render () )
75
+ $ this ->extractTableRow ($ this ->table )
74
76
);
75
77
}
76
78
@@ -87,7 +89,7 @@ public function testTwoMoneys()
87
89
88
90
$ this ->assertEquals (
89
91
'<tr data-id="1"><td class=" right aligned single line">bar</td><td>ref123</td><td class="negative right aligned single line"><b>-123</b></td></tr> ' ,
90
- $ this ->extract ($ this ->table -> render () )
92
+ $ this ->extractTableRow ($ this ->table )
91
93
);
92
94
}
93
95
@@ -105,18 +107,10 @@ public function testTemplateStacking()
105
107
106
108
$ this ->assertEquals (
107
109
'<tr data-id="1"><td><u><b>bar</b></u></td><td>ref123</td></tr> ' ,
108
- $ this ->extract ($ this ->table -> render () )
110
+ $ this ->extractTableRow ($ this ->table )
109
111
);
110
112
}
111
113
112
- public function extract ($ val )
113
- {
114
- // extract only <tr> out
115
- preg_match ('/<.*data-id="1".*/m ' , $ val , $ matches );
116
-
117
- return $ matches [0 ];
118
- }
119
-
120
114
public function testRender1 ()
121
115
{
122
116
@@ -126,7 +120,7 @@ public function testRender1()
126
120
127
121
$ this ->assertEquals (
128
122
'<tr data-id="1"><td><u><b>bar</b></u></td><td>ref123</td></tr> ' ,
129
- $ this ->extract ($ this ->table -> render () )
123
+ $ this ->extractTableRow ($ this ->table )
130
124
);
131
125
}
132
126
@@ -143,7 +137,7 @@ public function testRender1a()
143
137
144
138
$ this ->assertEquals (
145
139
'<tr data-id="1"><td>bar</td><td>ref123</td><td>hello<b>world</b></td></tr> ' ,
146
- $ this ->extract ($ this ->table -> render () )
140
+ $ this ->extractTableRow ($ this ->table )
147
141
);
148
142
}
149
143
@@ -158,7 +152,7 @@ public function testLink1()
158
152
159
153
$ this ->assertEquals (
160
154
'<tr data-id="1"><td><a href="example.php?id=1">bar</a></td><td>ref123</td></tr> ' ,
161
- $ this ->extract ($ this ->table -> render () )
155
+ $ this ->extractTableRow ($ this ->table )
162
156
);
163
157
}
164
158
@@ -173,7 +167,7 @@ public function testLink1a()
173
167
174
168
$ this ->assertEquals (
175
169
'<tr data-id="1"><td><a href="example.php?id=1">bar</a></td><td>ref123</td></tr> ' ,
176
- $ this ->extract ($ this ->table -> render () )
170
+ $ this ->extractTableRow ($ this ->table )
177
171
);
178
172
}
179
173
@@ -185,7 +179,7 @@ public function testLink2()
185
179
186
180
$ this ->assertEquals (
187
181
'<tr data-id="1"><td><a href="example.php?id=%7B%24id%7D">bar</a></td><td>ref123</td></tr> ' ,
188
- $ this ->extract ($ this ->table -> render () )
182
+ $ this ->extractTableRow ($ this ->table )
189
183
);
190
184
}
191
185
@@ -195,7 +189,7 @@ public function testLink3()
195
189
196
190
$ this ->assertEquals (
197
191
'<tr data-id="1"><td><a href="example.php?id=1">bar</a></td><td>ref123</td></tr> ' ,
198
- $ this ->extract ($ this ->table -> render () )
192
+ $ this ->extractTableRow ($ this ->table )
199
193
);
200
194
}
201
195
@@ -205,7 +199,7 @@ public function testLink4()
205
199
206
200
$ this ->assertEquals (
207
201
'<tr data-id="1"><td><a href="example.php?test=1">bar</a></td><td>ref123</td></tr> ' ,
208
- $ this ->extract ($ this ->table -> render () )
202
+ $ this ->extractTableRow ($ this ->table )
209
203
);
210
204
}
211
205
@@ -215,7 +209,7 @@ public function testLink5()
215
209
216
210
$ this ->assertEquals (
217
211
'<tr data-id="1"><td><a href="example.php?test=1">bar</a></td><td>ref123</td></tr> ' ,
218
- $ this ->extract ($ this ->table -> render () )
212
+ $ this ->extractTableRow ($ this ->table )
219
213
);
220
214
}
221
215
@@ -225,7 +219,7 @@ public function testLink6()
225
219
226
220
$ this ->assertEquals (
227
221
'<tr data-id="1"><td><a href="example.php?test=1" download="true" >bar</a></td><td>ref123</td></tr> ' ,
228
- $ this ->extract ($ this ->table -> render () )
222
+ $ this ->extractTableRow ($ this ->table )
229
223
);
230
224
}
231
225
@@ -235,7 +229,7 @@ public function testLink7()
235
229
236
230
$ this ->assertEquals (
237
231
'<tr data-id="1"><td><a href="example.php?test=1" target="_blank" >bar</a></td><td>ref123</td></tr> ' ,
238
- $ this ->extract ($ this ->table -> render () )
232
+ $ this ->extractTableRow ($ this ->table )
239
233
);
240
234
}
241
235
@@ -245,7 +239,7 @@ public function testLink8()
245
239
246
240
$ this ->assertEquals (
247
241
'<tr data-id="1"><td><a href="example.php?test=1"><i class="icon info"></i>bar</a></td><td>ref123</td></tr> ' ,
248
- $ this ->extract ($ this ->table -> render () )
242
+ $ this ->extractTableRow ($ this ->table )
249
243
);
250
244
}
251
245
@@ -255,7 +249,7 @@ public function testLink9()
255
249
256
250
$ this ->assertEquals (
257
251
'<tr data-id="1"><td><a href="example.php?test=1"></a></td><td>ref123</td></tr> ' ,
258
- $ this ->extract ($ this ->table -> render () )
252
+ $ this ->extractTableRow ($ this ->table )
259
253
);
260
254
}
261
255
@@ -276,7 +270,7 @@ public function testLink10()
276
270
277
271
$ this ->assertEquals (
278
272
'<tr data-id="1"><td> --- </td><td>ref123</td></tr> ' ,
279
- $ this ->extract ($ this ->table -> render () )
273
+ $ this ->extractTableRow ($ this ->table )
280
274
);
281
275
}
282
276
@@ -286,7 +280,7 @@ public function testLink11()
286
280
287
281
$ this ->assertEquals (
288
282
'<tr data-id="1"><td class=""> bar<span class="ui icon link " data-tooltip="ref123"><i class="ui icon info circle"></span></td><td>ref123</td></tr> ' ,
289
- $ this ->extract ($ this ->table -> render () )
283
+ $ this ->extractTableRow ($ this ->table )
290
284
);
291
285
}
292
286
0 commit comments