Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3061bfe

Browse files
committed
minor #37874 stop using the deprecated at() PHPUnit matcher (xabbuh)
This PR was merged into the 5.1 branch. Discussion ---------- stop using the deprecated at() PHPUnit matcher | Q | A | ------------- | --- | Branch? | 5.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | Commits ------- e36e73b stop using the deprecated at() PHPUnit matcher
2 parents 509247b + e36e73b commit 3061bfe

File tree

3 files changed

+75
-132
lines changed

3 files changed

+75
-132
lines changed

src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php

Lines changed: 36 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,10 @@ public function testCreateFromChoicesSameValueClosure()
137137
$list2 = new ArrayChoiceList([]);
138138
$closure = function () {};
139139

140-
$this->decoratedFactory->expects($this->at(0))
141-
->method('createListFromChoices')
142-
->with($choices, $closure)
143-
->willReturn($list1);
144-
$this->decoratedFactory->expects($this->at(1))
140+
$this->decoratedFactory->expects($this->exactly(2))
145141
->method('createListFromChoices')
146142
->with($choices, $closure)
147-
->willReturn($list2);
143+
->willReturnOnConsecutiveCalls($list1, $list2);
148144

149145
$this->assertSame($list1, $this->factory->createListFromChoices($choices, $closure));
150146
$this->assertSame($list2, $this->factory->createListFromChoices($choices, $closure));
@@ -194,14 +190,10 @@ public function testCreateFromChoicesSameFilterClosure()
194190
$list2 = new ArrayChoiceList([]);
195191
$filter = function () {};
196192

197-
$this->decoratedFactory->expects($this->at(0))
198-
->method('createListFromChoices')
199-
->with($choices, null, $filter)
200-
->willReturn($list1);
201-
$this->decoratedFactory->expects($this->at(1))
193+
$this->decoratedFactory->expects($this->exactly(2))
202194
->method('createListFromChoices')
203195
->with($choices, null, $filter)
204-
->willReturn($list2);
196+
->willReturnOnConsecutiveCalls($list1, $list2);
205197

206198
$this->assertSame($list1, $this->factory->createListFromChoices($choices, null, $filter));
207199
$this->assertSame($list2, $this->factory->createListFromChoices($choices, null, $filter));
@@ -232,14 +224,13 @@ public function testCreateFromChoicesDifferentFilterClosure()
232224
$closure1 = function () {};
233225
$closure2 = function () {};
234226

235-
$this->decoratedFactory->expects($this->at(0))
236-
->method('createListFromChoices')
237-
->with($choices, null, $closure1)
238-
->willReturn($list1);
239-
$this->decoratedFactory->expects($this->at(1))
227+
$this->decoratedFactory->expects($this->exactly(2))
240228
->method('createListFromChoices')
241-
->with($choices, null, $closure2)
242-
->willReturn($list2);
229+
->withConsecutive(
230+
[$choices, null, $closure1],
231+
[$choices, null, $closure2]
232+
)
233+
->willReturnOnConsecutiveCalls($list1, $list2);
243234

244235
$this->assertSame($list1, $this->factory->createListFromChoices($choices, null, $closure1));
245236
$this->assertSame($list2, $this->factory->createListFromChoices($choices, null, $closure2));
@@ -251,16 +242,10 @@ public function testCreateFromLoaderSameLoader()
251242
$list = new ArrayChoiceList([]);
252243
$list2 = new ArrayChoiceList([]);
253244

254-
$this->decoratedFactory->expects($this->at(0))
255-
->method('createListFromLoader')
256-
->with($loader)
257-
->willReturn($list)
258-
;
259-
$this->decoratedFactory->expects($this->at(1))
245+
$this->decoratedFactory->expects($this->exactly(2))
260246
->method('createListFromLoader')
261247
->with($loader)
262-
->willReturn($list2)
263-
;
248+
->willReturnOnConsecutiveCalls($list, $list2);
264249

265250
$this->assertSame($list, $this->factory->createListFromLoader($loader));
266251
$this->assertSame($list2, $this->factory->createListFromLoader($loader));
@@ -309,16 +294,10 @@ public function testCreateFromLoaderSameValueClosure()
309294
$list2 = new ArrayChoiceList([]);
310295
$closure = function () {};
311296

312-
$this->decoratedFactory->expects($this->at(0))
313-
->method('createListFromLoader')
314-
->with($loader, $closure)
315-
->willReturn($list)
316-
;
317-
$this->decoratedFactory->expects($this->at(1))
297+
$this->decoratedFactory->expects($this->exactly(2))
318298
->method('createListFromLoader')
319299
->with($loader, $closure)
320-
->willReturn($list2)
321-
;
300+
->willReturnOnConsecutiveCalls($list, $list2);
322301

323302
$this->assertSame($list, $this->factory->createListFromLoader(ChoiceList::loader($type, $loader), $closure));
324303
$this->assertSame($list2, $this->factory->createListFromLoader(ChoiceList::loader($type, $this->createMock(ChoiceLoaderInterface::class)), $closure));
@@ -376,16 +355,10 @@ public function testCreateFromLoaderSameFilterClosure()
376355
$list2 = new ArrayChoiceList([]);
377356
$closure = function () {};
378357

379-
$this->decoratedFactory->expects($this->at(0))
380-
->method('createListFromLoader')
381-
->with($loader, null, $closure)
382-
->willReturn($list)
383-
;
384-
$this->decoratedFactory->expects($this->at(1))
358+
$this->decoratedFactory->expects($this->exactly(2))
385359
->method('createListFromLoader')
386360
->with($loader, null, $closure)
387-
->willReturn($list2)
388-
;
361+
->willReturnOnConsecutiveCalls($list, $list2);
389362

390363
$this->assertSame($list, $this->factory->createListFromLoader(ChoiceList::loader($type, $loader), null, $closure));
391364
$this->assertSame($list2, $this->factory->createListFromLoader(ChoiceList::loader($type, $this->createMock(ChoiceLoaderInterface::class)), null, $closure));
@@ -425,14 +398,13 @@ public function testCreateFromLoaderDifferentFilterClosure()
425398
$closure1 = function () {};
426399
$closure2 = function () {};
427400

428-
$this->decoratedFactory->expects($this->at(0))
429-
->method('createListFromLoader')
430-
->with($loader, null, $closure1)
431-
->willReturn($list1);
432-
$this->decoratedFactory->expects($this->at(1))
401+
$this->decoratedFactory->expects($this->exactly(2))
433402
->method('createListFromLoader')
434-
->with($loader, null, $closure2)
435-
->willReturn($list2);
403+
->withConsecutive(
404+
[$loader, null, $closure1],
405+
[$loader, null, $closure2]
406+
)
407+
->willReturnOnConsecutiveCalls($list1, $list2);
436408

437409
$this->assertSame($list1, $this->factory->createListFromLoader(ChoiceList::loader($type, $loader), null, $closure1));
438410
$this->assertSame($list2, $this->factory->createListFromLoader(ChoiceList::loader($type, $this->createMock(ChoiceLoaderInterface::class)), null, $closure2));
@@ -445,16 +417,10 @@ public function testCreateViewSamePreferredChoices()
445417
$view = new ChoiceListView();
446418
$view2 = new ChoiceListView();
447419

448-
$this->decoratedFactory->expects($this->at(0))
449-
->method('createView')
450-
->with($list, $preferred)
451-
->willReturn($view)
452-
;
453-
$this->decoratedFactory->expects($this->at(1))
420+
$this->decoratedFactory->expects($this->exactly(2))
454421
->method('createView')
455422
->with($list, $preferred)
456-
->willReturn($view2)
457-
;
423+
->willReturnOnConsecutiveCalls($view, $view2);
458424

459425
$this->assertSame($view, $this->factory->createView($list, $preferred));
460426
$this->assertSame($view2, $this->factory->createView($list, $preferred));
@@ -504,16 +470,10 @@ public function testCreateViewSamePreferredChoicesClosure()
504470
$view = new ChoiceListView();
505471
$view2 = new ChoiceListView();
506472

507-
$this->decoratedFactory->expects($this->at(0))
508-
->method('createView')
509-
->with($list, $preferred)
510-
->willReturn($view)
511-
;
512-
$this->decoratedFactory->expects($this->at(1))
473+
$this->decoratedFactory->expects($this->exactly(2))
513474
->method('createView')
514475
->with($list, $preferred)
515-
->willReturn($view2)
516-
;
476+
->willReturnOnConsecutiveCalls($view, $view2);
517477

518478
$this->assertSame($view, $this->factory->createView($list, $preferred));
519479
$this->assertSame($view2, $this->factory->createView($list, $preferred));
@@ -563,16 +523,10 @@ public function testCreateViewSameLabelClosure()
563523
$view = new ChoiceListView();
564524
$view2 = new ChoiceListView();
565525

566-
$this->decoratedFactory->expects($this->at(0))
567-
->method('createView')
568-
->with($list, null, $labels)
569-
->willReturn($view)
570-
;
571-
$this->decoratedFactory->expects($this->at(1))
526+
$this->decoratedFactory->expects($this->exactly(2))
572527
->method('createView')
573528
->with($list, null, $labels)
574-
->willReturn($view2)
575-
;
529+
->willReturnOnConsecutiveCalls($view, $view2);
576530

577531
$this->assertSame($view, $this->factory->createView($list, null, $labels));
578532
$this->assertSame($view2, $this->factory->createView($list, null, $labels));
@@ -622,16 +576,10 @@ public function testCreateViewSameIndexClosure()
622576
$view = new ChoiceListView();
623577
$view2 = new ChoiceListView();
624578

625-
$this->decoratedFactory->expects($this->at(0))
626-
->method('createView')
627-
->with($list, null, null, $index)
628-
->willReturn($view)
629-
;
630-
$this->decoratedFactory->expects($this->at(1))
579+
$this->decoratedFactory->expects($this->exactly(2))
631580
->method('createView')
632581
->with($list, null, null, $index)
633-
->willReturn($view2)
634-
;
582+
->willReturnOnConsecutiveCalls($view, $view2);
635583

636584
$this->assertSame($view, $this->factory->createView($list, null, null, $index));
637585
$this->assertSame($view2, $this->factory->createView($list, null, null, $index));
@@ -681,16 +629,10 @@ public function testCreateViewSameGroupByClosure()
681629
$view = new ChoiceListView();
682630
$view2 = new ChoiceListView();
683631

684-
$this->decoratedFactory->expects($this->at(0))
685-
->method('createView')
686-
->with($list, null, null, null, $groupBy)
687-
->willReturn($view)
688-
;
689-
$this->decoratedFactory->expects($this->at(1))
632+
$this->decoratedFactory->expects($this->exactly(2))
690633
->method('createView')
691634
->with($list, null, null, null, $groupBy)
692-
->willReturn($view2)
693-
;
635+
->willReturnOnConsecutiveCalls($view, $view2);
694636

695637
$this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy));
696638
$this->assertSame($view2, $this->factory->createView($list, null, null, null, $groupBy));
@@ -740,16 +682,10 @@ public function testCreateViewSameAttributes()
740682
$view = new ChoiceListView();
741683
$view2 = new ChoiceListView();
742684

743-
$this->decoratedFactory->expects($this->at(0))
744-
->method('createView')
745-
->with($list, null, null, null, null, $attr)
746-
->willReturn($view)
747-
;
748-
$this->decoratedFactory->expects($this->at(1))
685+
$this->decoratedFactory->expects($this->exactly(2))
749686
->method('createView')
750687
->with($list, null, null, null, null, $attr)
751-
->willReturn($view2)
752-
;
688+
->willReturnOnConsecutiveCalls($view, $view2);
753689

754690
$this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr));
755691
$this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr));
@@ -798,16 +734,10 @@ public function testCreateViewSameAttributesClosure()
798734
$view = new ChoiceListView();
799735
$view2 = new ChoiceListView();
800736

801-
$this->decoratedFactory->expects($this->at(0))
802-
->method('createView')
803-
->with($list, null, null, null, null, $attr)
804-
->willReturn($view)
805-
;
806-
$this->decoratedFactory->expects($this->at(1))
737+
$this->decoratedFactory->expects($this->exactly(2))
807738
->method('createView')
808739
->with($list, null, null, null, null, $attr)
809-
->willReturn($view2)
810-
;
740+
->willReturnOnConsecutiveCalls($view, $view2);
811741

812742
$this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr));
813743
$this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr));

src/Symfony/Component/Ldap/Tests/Security/CheckLdapCredentialsListenerTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ public function testQueryForDn()
152152
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
153153
$query->expects($this->once())->method('execute')->willReturn($collection);
154154

155-
$this->ldap->expects($this->at(0))->method('bind')->with('elsa', 'test1234A$');
155+
$this->ldap
156+
->method('bind')
157+
->withConsecutive(
158+
['elsa', 'test1234A$']
159+
);
156160
$this->ldap->expects($this->any())->method('escape')->with('Wouter', '', LdapInterface::ESCAPE_FILTER)->willReturn('wouter');
157161
$this->ldap->expects($this->once())->method('query')->with('{username}', 'wouter_test')->willReturn($query);
158162

@@ -170,7 +174,11 @@ public function testEmptyQueryResultShouldThrowAnException()
170174
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
171175
$query->expects($this->once())->method('execute')->willReturn($collection);
172176

173-
$this->ldap->expects($this->at(0))->method('bind')->with('elsa', 'test1234A$');
177+
$this->ldap
178+
->method('bind')
179+
->withConsecutive(
180+
['elsa', 'test1234A$']
181+
);
174182
$this->ldap->expects($this->once())->method('query')->willReturn($query);
175183

176184
$listener = $this->createListener();

src/Symfony/Component/Messenger/Bridge/AmazonSqs/Tests/Transport/ConnectionTest.php

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -198,31 +198,36 @@ public function testKeepGettingPendingMessages()
198198
->method('getQueueUrl')
199199
->with(['QueueName' => 'queue', 'QueueOwnerAWSAccountId' => 123])
200200
->willReturn(ResultMockFactory::create(GetQueueUrlResult::class, ['QueueUrl' => 'https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue']));
201-
$client->expects($this->at(1))
201+
$client->expects($this->exactly(2))
202202
->method('receiveMessage')
203-
->with([
204-
'QueueUrl' => 'https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue',
205-
'MaxNumberOfMessages' => 9,
206-
'WaitTimeSeconds' => 20,
207-
'MessageAttributeNames' => ['All'],
208-
'VisibilityTimeout' => null,
209-
])
210-
->willReturn(ResultMockFactory::create(ReceiveMessageResult::class, ['Messages' => [
211-
new Message(['MessageId' => 1, 'Body' => 'this is a test']),
212-
new Message(['MessageId' => 2, 'Body' => 'this is a test']),
213-
new Message(['MessageId' => 3, 'Body' => 'this is a test']),
214-
]]));
215-
$client->expects($this->at(2))
216-
->method('receiveMessage')
217-
->with([
218-
'QueueUrl' => 'https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue',
219-
'MaxNumberOfMessages' => 9,
220-
'WaitTimeSeconds' => 20,
221-
'MessageAttributeNames' => ['All'],
222-
'VisibilityTimeout' => null,
223-
])
224-
->willReturn(ResultMockFactory::create(ReceiveMessageResult::class, ['Messages' => [
225-
]]));
203+
->withConsecutive(
204+
[
205+
[
206+
'QueueUrl' => 'https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue',
207+
'MaxNumberOfMessages' => 9,
208+
'WaitTimeSeconds' => 20,
209+
'MessageAttributeNames' => ['All'],
210+
'VisibilityTimeout' => null,
211+
],
212+
],
213+
[
214+
[
215+
'QueueUrl' => 'https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue',
216+
'MaxNumberOfMessages' => 9,
217+
'WaitTimeSeconds' => 20,
218+
'MessageAttributeNames' => ['All'],
219+
'VisibilityTimeout' => null,
220+
],
221+
]
222+
)
223+
->willReturnOnConsecutiveCalls(
224+
ResultMockFactory::create(ReceiveMessageResult::class, ['Messages' => [
225+
new Message(['MessageId' => 1, 'Body' => 'this is a test']),
226+
new Message(['MessageId' => 2, 'Body' => 'this is a test']),
227+
new Message(['MessageId' => 3, 'Body' => 'this is a test']),
228+
]]),
229+
ResultMockFactory::create(ReceiveMessageResult::class, ['Messages' => []])
230+
);
226231

227232
$connection = new Connection(['queue_name' => 'queue', 'account' => 123, 'auto_setup' => false], $client);
228233
$this->assertNotNull($connection->get());

0 commit comments

Comments
 (0)