@@ -17,8 +17,8 @@ final class DictionaryTest extends StructuredFieldTestCase
17
17
#[Test]
18
18
public function it_can_be_instantiated_with_an_collection_of_item_or_inner_list (): void
19
19
{
20
- $ stringItem = Item::fromAssociative ('helloWorld ' );
21
- $ booleanItem = Item::fromAssociative ( true );
20
+ $ stringItem = Item::fromString ('helloWorld ' );
21
+ $ booleanItem = Item::true ( );
22
22
$ arrayParams = ['string ' => $ stringItem , 'boolean ' => $ booleanItem ];
23
23
$ instance = Dictionary::fromAssociative ($ arrayParams );
24
24
@@ -34,8 +34,8 @@ public function it_can_be_instantiated_with_an_collection_of_item_or_inner_list(
34
34
#[Test]
35
35
public function it_can_be_instantiated_with_key_value_pairs (): void
36
36
{
37
- $ stringItem = Item::fromAssociative ('helloWorld ' );
38
- $ booleanItem = Item::fromAssociative ( true );
37
+ $ stringItem = Item::fromString ('helloWorld ' );
38
+ $ booleanItem = Item::true ( );
39
39
$ arrayParams = [['string ' , $ stringItem ], ['boolean ' , $ booleanItem ]];
40
40
$ instance = Dictionary::fromPairs ($ arrayParams );
41
41
@@ -49,8 +49,8 @@ public function it_can_be_instantiated_with_key_value_pairs(): void
49
49
#[Test]
50
50
public function it_can_add_or_remove_members (): void
51
51
{
52
- $ stringItem = Item::fromAssociative ('helloWorld ' );
53
- $ booleanItem = Item::fromAssociative ( true );
52
+ $ stringItem = Item::fromString ('helloWorld ' );
53
+ $ booleanItem = Item::true ( );
54
54
$ arrayParams = ['string ' => $ stringItem , 'boolean ' => $ booleanItem ];
55
55
$ instance = Dictionary::fromAssociative ($ arrayParams );
56
56
@@ -64,10 +64,10 @@ public function it_can_add_or_remove_members(): void
64
64
self ::assertFalse ($ deletedInstance ->has ('boolean ' ));
65
65
self ::assertFalse ($ deletedInstance ->hasPair (1 ));
66
66
67
- $ appendInstance = $ deletedInstance ->append ('foobar ' , Item::fromAssociative ('BarBaz ' ));
67
+ $ appendInstance = $ deletedInstance ->append ('foobar ' , Item::new ('BarBaz ' ));
68
68
self ::assertTrue ($ appendInstance ->hasPair (1 ));
69
69
70
- self ::assertSame ($ appendInstance , $ appendInstance ->append ('foobar ' , Item::fromAssociative ('BarBaz ' )));
70
+ self ::assertSame ($ appendInstance , $ appendInstance ->append ('foobar ' , Item::new ('BarBaz ' )));
71
71
72
72
/** @var array{0:string, 1:Item} $foundItem */
73
73
$ foundItem = $ appendInstance ->pair (1 );
@@ -126,8 +126,8 @@ public function it_fails_to_add_an_item_with_wrong_key(): void
126
126
public function it_can_prepend_a_new_member (): void
127
127
{
128
128
$ instance = Dictionary::new ()
129
- ->append ('a ' , Item::fromAssociative ( false ))
130
- ->prepend ('b ' , Item::fromAssociative ( true ));
129
+ ->append ('a ' , Item::false ( ))
130
+ ->prepend ('b ' , Item::true ( ));
131
131
132
132
self ::assertSame ('b, a=?0 ' , (string ) $ instance );
133
133
}
@@ -140,74 +140,74 @@ public function it_can_returns_the_container_member_keys(): void
140
140
self ::assertSame ([], $ instance ->keys ());
141
141
142
142
$ newInstance = $ instance
143
- ->append ('a ' , Item::fromAssociative ( false ))
144
- ->prepend ('b ' , Item::fromAssociative ( true ));
143
+ ->append ('a ' , Item::false ( ))
144
+ ->prepend ('b ' , Item::true ( ));
145
145
146
146
self ::assertSame (['b ' , 'a ' ], $ newInstance ->keys ());
147
147
}
148
148
149
149
#[Test]
150
150
public function it_can_merge_one_or_more_instances_using_associative (): void
151
151
{
152
- $ instance1 = Dictionary::fromAssociative (['a ' => Item::fromAssociative ( false )]);
153
- $ instance2 = Dictionary::fromAssociative (['b ' => Item::fromAssociative ( true )]);
154
- $ instance3 = Dictionary::fromAssociative (['a ' => Item::fromAssociative (42 )]);
152
+ $ instance1 = Dictionary::fromAssociative (['a ' => Item::false ( )]);
153
+ $ instance2 = Dictionary::fromAssociative (['b ' => Item::true ( )]);
154
+ $ instance3 = Dictionary::fromAssociative (['a ' => Item::new (42 )]);
155
155
156
156
$ instance4 = $ instance1 ->mergeAssociative ($ instance2 , $ instance3 );
157
157
158
158
self ::assertCount (2 , $ instance4 );
159
- self ::assertEquals (Item::fromAssociative (42 ), $ instance4 ->get ('a ' ));
160
- self ::assertEquals (Item::fromAssociative ( true ), $ instance4 ->get ('b ' ));
159
+ self ::assertEquals (Item::new (42 ), $ instance4 ->get ('a ' ));
160
+ self ::assertEquals (Item::true ( ), $ instance4 ->get ('b ' ));
161
161
}
162
162
163
163
#[Test]
164
164
public function it_can_merge_two_or_more_instances_to_yield_different_result (): void
165
165
{
166
- $ instance1 = Dictionary::fromAssociative (['a ' => Item::fromAssociative ( false )]);
167
- $ instance2 = Dictionary::fromAssociative (['b ' => Item::fromAssociative ( true )]);
168
- $ instance3 = Dictionary::fromAssociative (['a ' => Item::fromAssociative (42 )]);
166
+ $ instance1 = Dictionary::fromAssociative (['a ' => Item::false ( )]);
167
+ $ instance2 = Dictionary::fromAssociative (['b ' => Item::true ( )]);
168
+ $ instance3 = Dictionary::fromAssociative (['a ' => Item::new (42 )]);
169
169
170
170
$ instance4 = $ instance3 ->mergeAssociative ($ instance2 , $ instance1 );
171
171
172
172
self ::assertCount (2 , $ instance4 );
173
- self ::assertEquals (Item::fromAssociative ( false ), $ instance4 ->get ('a ' ));
174
- self ::assertEquals (Item::fromAssociative ( true ), $ instance4 ->get ('b ' ));
173
+ self ::assertEquals (Item::false ( ), $ instance4 ->get ('a ' ));
174
+ self ::assertEquals (Item::true ( ), $ instance4 ->get ('b ' ));
175
175
}
176
176
177
177
#[Test]
178
178
public function it_can_merge_without_argument_and_not_throw (): void
179
179
{
180
- self ::assertCount (1 , Dictionary::fromAssociative (['a ' => Item::fromAssociative ( false )])->mergeAssociative ());
180
+ self ::assertCount (1 , Dictionary::fromAssociative (['a ' => Item::false ( )])->mergeAssociative ());
181
181
}
182
182
183
183
#[Test]
184
184
public function it_can_merge_one_or_more_instances_using_pairs (): void
185
185
{
186
- $ instance1 = Dictionary::fromPairs ([['a ' , Item::fromAssociative ( false )]]);
187
- $ instance2 = Dictionary::fromPairs ([['b ' , Item::fromAssociative ( true )]]);
188
- $ instance3 = Dictionary::fromPairs ([['a ' , Item::fromAssociative (42 )]]);
186
+ $ instance1 = Dictionary::fromPairs ([['a ' , Item::false ( )]]);
187
+ $ instance2 = Dictionary::fromPairs ([['b ' , Item::true ( )]]);
188
+ $ instance3 = Dictionary::fromPairs ([['a ' , Item::new (42 )]]);
189
189
190
190
$ instance4 = $ instance3 ->mergePairs ($ instance2 , $ instance1 );
191
191
192
192
self ::assertCount (2 , $ instance4 );
193
193
194
- self ::assertEquals (Item::fromAssociative ( false ), $ instance4 ->get ('a ' ));
195
- self ::assertEquals (Item::fromAssociative ( true ), $ instance4 ->get ('b ' ));
194
+ self ::assertEquals (Item::false ( ), $ instance4 ->get ('a ' ));
195
+ self ::assertEquals (Item::true ( ), $ instance4 ->get ('b ' ));
196
196
}
197
197
198
198
#[Test]
199
199
public function it_can_merge_without_pairs_and_not_throw (): void
200
200
{
201
- $ instance = Dictionary::fromAssociative (['a ' => Item::fromAssociative ( false )]);
201
+ $ instance = Dictionary::fromAssociative (['a ' => Item::false ( )]);
202
202
203
203
self ::assertCount (1 , $ instance ->mergePairs ());
204
204
}
205
205
206
206
#[Test]
207
207
public function it_can_merge_dictionary_instances_via_pairs_or_associative (): void
208
208
{
209
- $ instance1 = Dictionary::fromAssociative (['a ' => Item::fromAssociative ( false )]);
210
- $ instance2 = Dictionary::fromAssociative (['b ' => Item::fromAssociative ( true )]);
209
+ $ instance1 = Dictionary::fromAssociative (['a ' => Item::false ( )]);
210
+ $ instance2 = Dictionary::fromAssociative (['b ' => Item::true ( )]);
211
211
212
212
$ instance3 = clone $ instance1 ;
213
213
$ instance4 = clone $ instance2 ;
0 commit comments