11
11
12
12
use Lunr \Halo \LunrBaseTest ;
13
13
use PHPDraft \Model \Elements \ArrayStructureElement ;
14
+ use PHPDraft \Model \Elements \ElementStructureElement ;
14
15
15
16
/**
16
17
* Class ArrayStructureTest
@@ -58,7 +59,13 @@ public function parseObjectProvider(): array
58
59
$ return = [];
59
60
$ base1 = new ArrayStructureElement ();
60
61
$ base1 ->key = null ;
61
- $ base1 ->value = [['Swift ' => 'string ' ], ['Objective-C ' => 'string ' ]];
62
+ $ val1 = new ElementStructureElement ();
63
+ $ val1 ->value = 'Swift ' ;
64
+ $ val1 ->type = 'string ' ;
65
+ $ val2 = new ElementStructureElement ();
66
+ $ val2 ->value = 'Objective-C ' ;
67
+ $ val2 ->type = 'string ' ;
68
+ $ base1 ->value = [$ val1 , $ val2 ];
62
69
$ base1 ->status = null ;
63
70
$ base1 ->element = 'array ' ;
64
71
$ base1 ->type = null ;
@@ -68,7 +75,13 @@ public function parseObjectProvider(): array
68
75
69
76
$ base2 = new ArrayStructureElement ();
70
77
$ base2 ->key = null ;
71
- $ base2 ->value = [['item ' => 'string ' ], ['another item ' => 'string ' ]];
78
+ $ val1 = new ElementStructureElement ();
79
+ $ val1 ->value = 'item ' ;
80
+ $ val1 ->type = 'string ' ;
81
+ $ val2 = new ElementStructureElement ();
82
+ $ val2 ->value = 'another item ' ;
83
+ $ val2 ->type = 'string ' ;
84
+ $ base2 ->value = [$ val1 , $ val2 ];
72
85
$ base2 ->status = null ;
73
86
$ base2 ->element = 'array ' ;
74
87
$ base2 ->type = 'Some simple array ' ;
@@ -77,8 +90,16 @@ public function parseObjectProvider(): array
77
90
$ base2 ->deps = ['Some simple array ' ];
78
91
79
92
$ base3 = new ArrayStructureElement ();
80
- $ base3 ->key = 'car_id_list ' ;
81
- $ base3 ->value = [['car_id_list ' => 'string ' ], ['' => 'array ' ]];
93
+ $ base3 ->key = new ElementStructureElement ();
94
+ $ base3 ->key ->value = 'car_id_list ' ;
95
+ $ base3 ->key ->type = 'string ' ;
96
+ $ val1 = new ElementStructureElement ();
97
+ $ val1 ->value = 'car_id_list ' ;
98
+ $ val1 ->type = 'string ' ;
99
+ $ val2 = new ElementStructureElement ();
100
+ $ val2 ->value = null ;
101
+ $ val2 ->type = 'array ' ;
102
+ $ base3 ->value = [$ val1 , $ val2 ];
82
103
$ base3 ->status = 'optional ' ;
83
104
$ base3 ->element = 'member ' ;
84
105
$ base3 ->type = 'array ' ;
@@ -167,18 +188,32 @@ public function testNewInstance(): void
167
188
*/
168
189
public function testToStringWithArray (): void
169
190
{
170
- $ this ->class ->value = [['string ' => 'stuff ' ], ['int ' => 'class ' ]];
191
+ $ val1 = new ElementStructureElement ();
192
+ $ val1 ->type = 'string ' ;
193
+ $ val1 ->value = 'stuff ' ;
194
+ $ val2 = new ElementStructureElement ();
195
+ $ val2 ->type = 'int ' ;
196
+ $ val2 ->value = 'class ' ;
197
+ $ val2 ->description = 'Description ' ;
198
+ $ this ->class ->value = [$ val1 , $ val2 ];
171
199
$ return = $ this ->class ->__toString ();
172
- $ this ->assertSame ('<ul class="list-group mdl-list"><li class="list-group-item mdl-list__item"><a class=" code" title="stuff" href="#object-stuff">stuff</a > - <span class="example-value pull-right">string </span></li><li class="list-group-item mdl-list__item"><a class="code" title="class " href="#object-class">class </a> - <span class="example-value pull-right">int </span></li></ul> ' , $ return );
200
+ $ this ->assertSame ('<ul class="list-group mdl-list"><li class="list-group-item mdl-list__item"><code>string</code > - <span class="example-value pull-right">stuff </span></li><li class="list-group-item mdl-list__item"><a class="code" title="int " href="#object-int">int </a> - <span class="description">Description</span> - <span class=" example-value pull-right">class </span></li></ul> ' , $ return );
173
201
}
174
202
175
203
/**
176
204
* Test setup of new instances
177
205
*/
178
206
public function testToStringWithComplexArray (): void
179
207
{
180
- $ this ->class ->value = [['type ' => 'Bike ' ], ['stuff ' => 'car ' ]];
208
+ $ val1 = new ElementStructureElement ();
209
+ $ val1 ->type = 'Bike ' ;
210
+ $ val1 ->value = 'type ' ;
211
+ $ val2 = new ElementStructureElement ();
212
+ $ val2 ->type = 'car ' ;
213
+ $ val2 ->value = 'stuff ' ;
214
+ $ val2 ->description = 'Description ' ;
215
+ $ this ->class ->value = [$ val1 , $ val2 ];
181
216
$ return = $ this ->class ->__toString ();
182
- $ this ->assertSame ('<ul class="list-group mdl-list"><li class="list-group-item mdl-list__item"><a class="code" title="Bike" href="#object-bike">Bike</a> - <span class="example-value pull-right">type</span></li><li class="list-group-item mdl-list__item"><a class="code" title="car" href="#object-car">car</a> - <span class="example-value pull-right">stuff</span></li></ul> ' , $ return );
217
+ $ this ->assertSame ('<ul class="list-group mdl-list"><li class="list-group-item mdl-list__item"><a class="code" title="Bike" href="#object-bike">Bike</a> - <span class="example-value pull-right">type</span></li><li class="list-group-item mdl-list__item"><a class="code" title="car" href="#object-car">car</a> - <span class="description">Description</span> - <span class=" example-value pull-right">stuff</span></li></ul> ' , $ return );
183
218
}
184
219
}
0 commit comments