@@ -46,8 +46,8 @@ public function setUp()
46
46
public function it_can_create_a_copy_with_a_new_item_for_a_specific_key ()
47
47
{
48
48
$ collection = (new FooCollection ())
49
- ->with ( $ this ->foo1 , ' foo1 ' )
50
- ->with ( $ this ->foo2 , ' foo2 ' );
49
+ ->withKey ( ' foo1 ' , $ this ->foo1 )
50
+ ->withKey ( ' foo2 ' , $ this ->foo2 );
51
51
52
52
$ expected = [
53
53
'foo1 ' => $ this ->foo1 ,
@@ -110,7 +110,7 @@ public function it_guards_the_object_type_of_items_when_initializing_from_array(
110
110
public function it_allows_sub_classes_when_guarding_the_object_type_of_new_items ()
111
111
{
112
112
$ collection = (new FooCollection ())
113
- ->with ( $ this ->fooExtended , ' fooExtended ' );
113
+ ->withKey ( ' fooExtended ' , $ this ->fooExtended );
114
114
115
115
$ expected = [
116
116
'fooExtended ' => $ this ->fooExtended ,
@@ -143,7 +143,7 @@ public function it_can_remove_an_item()
143
143
public function it_throws_an_exception_when_removing_an_unknown_item ()
144
144
{
145
145
$ collection = (new FooCollection ())
146
- ->with ( $ this ->foo1 , ' foo1 ' );
146
+ ->withKey ( ' foo1 ' , $ this ->foo1 );
147
147
148
148
$ this ->setExpectedException (CollectionItemNotFoundException::class);
149
149
$ collection ->without ($ this ->foo2 );
@@ -155,8 +155,8 @@ public function it_throws_an_exception_when_removing_an_unknown_item()
155
155
public function it_can_remove_an_item_by_key ()
156
156
{
157
157
$ collection = (new FooCollection ())
158
- ->with ( $ this ->foo1 , ' foo1 ' )
159
- ->with ( $ this ->foo2 , ' foo2 ' );
158
+ ->withKey ( ' foo1 ' , $ this ->foo1 )
159
+ ->withKey ( ' foo2 ' , $ this ->foo2 );
160
160
161
161
$ collection = $ collection ->withoutKey ('foo1 ' );
162
162
@@ -173,8 +173,8 @@ public function it_can_remove_an_item_by_key()
173
173
public function it_throws_an_exception_when_removing_by_unknown_key ()
174
174
{
175
175
$ collection = (new FooCollection ())
176
- ->with ( $ this ->foo1 , ' foo1 ' )
177
- ->with ( $ this ->foo2 , ' foo2 ' );
176
+ ->withKey ( ' foo1 ' , $ this ->foo1 )
177
+ ->withKey ( ' foo2 ' , $ this ->foo2 );
178
178
179
179
$ this ->setExpectedException (CollectionKeyNotFoundException::class);
180
180
$ collection ->withoutKey ('foo3 ' );
@@ -186,8 +186,8 @@ public function it_throws_an_exception_when_removing_by_unknown_key()
186
186
public function it_can_return_an_item_by_key ()
187
187
{
188
188
$ collection = (new FooCollection ())
189
- ->with ( $ this ->foo1 , ' foo1 ' )
190
- ->with ( $ this ->foo2 , ' foo2 ' );
189
+ ->withKey ( ' foo1 ' , $ this ->foo1 )
190
+ ->withKey ( ' foo2 ' , $ this ->foo2 );
191
191
192
192
$ this ->assertEquals (
193
193
$ this ->foo1 ,
@@ -206,7 +206,7 @@ public function it_can_return_an_item_by_key()
206
206
public function it_throws_an_exception_when_looking_for_an_item_with_an_unknown_key ()
207
207
{
208
208
$ collection = (new FooCollection ())
209
- ->with ( $ this ->foo1 , ' foo1 ' );
209
+ ->withKey ( ' foo1 ' , $ this ->foo1 );
210
210
211
211
$ this ->setExpectedException (CollectionKeyNotFoundException::class);
212
212
$ collection ->getByKey ('foo2 ' );
@@ -218,8 +218,8 @@ public function it_throws_an_exception_when_looking_for_an_item_with_an_unknown_
218
218
public function it_can_return_the_key_for_an_item ()
219
219
{
220
220
$ collection = (new FooCollection ())
221
- ->with ( $ this ->foo1 , ' foo1 ' )
222
- ->with ( $ this ->foo2 , ' foo2 ' );
221
+ ->withKey ( ' foo1 ' , $ this ->foo1 )
222
+ ->withKey ( ' foo2 ' , $ this ->foo2 );
223
223
224
224
$ this ->assertEquals (
225
225
'foo1 ' ,
@@ -238,7 +238,7 @@ public function it_can_return_the_key_for_an_item()
238
238
public function it_throws_an_exception_when_looking_for_the_key_of_an_unknown_item ()
239
239
{
240
240
$ collection = (new FooCollection ())
241
- ->with ( $ this ->foo1 , ' foo1 ' );
241
+ ->withKey ( ' foo1 ' , $ this ->foo1 );
242
242
243
243
$ this ->setExpectedException (CollectionItemNotFoundException::class);
244
244
$ collection ->getKeyFor ($ this ->foo2 );
@@ -250,8 +250,8 @@ public function it_throws_an_exception_when_looking_for_the_key_of_an_unknown_it
250
250
public function it_can_return_a_list_of_keys ()
251
251
{
252
252
$ collection = (new FooCollection ())
253
- ->with ( $ this ->foo1 , ' foo1 ' )
254
- ->with ( $ this ->foo2 , ' foo2 ' );
253
+ ->withKey ( ' foo1 ' , $ this ->foo1 )
254
+ ->withKey ( ' foo2 ' , $ this ->foo2 );
255
255
256
256
$ expected = [
257
257
'foo1 ' ,
@@ -297,9 +297,9 @@ public function it_can_be_converted_from_and_to_an_array()
297
297
public function it_can_be_looped_over_like_an_array ()
298
298
{
299
299
$ collection = (new FooCollection ())
300
- ->with ( $ this ->foo1 , ' foo1 ' )
301
- ->with ( $ this ->foo2 , ' foo2 ' )
302
- ->with ( $ this ->fooExtended , ' fooExtended ' );
300
+ ->withKey ( ' foo1 ' , $ this ->foo1 )
301
+ ->withKey ( ' foo2 ' , $ this ->foo2 )
302
+ ->withKey ( ' fooExtended ' , $ this ->fooExtended );
303
303
304
304
$ expected = [
305
305
'foo1 ' => $ this ->foo1 ,
0 commit comments