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

Skip to content

stop using the deprecated at() PHPUnit matcher #37874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,10 @@ public function testCreateFromChoicesSameValueClosure()
$list2 = new ArrayChoiceList([]);
$closure = function () {};

$this->decoratedFactory->expects($this->at(0))
->method('createListFromChoices')
->with($choices, $closure)
->willReturn($list1);
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createListFromChoices')
->with($choices, $closure)
->willReturn($list2);
->willReturnOnConsecutiveCalls($list1, $list2);

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

$this->decoratedFactory->expects($this->at(0))
->method('createListFromChoices')
->with($choices, null, $filter)
->willReturn($list1);
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createListFromChoices')
->with($choices, null, $filter)
->willReturn($list2);
->willReturnOnConsecutiveCalls($list1, $list2);

$this->assertSame($list1, $this->factory->createListFromChoices($choices, null, $filter));
$this->assertSame($list2, $this->factory->createListFromChoices($choices, null, $filter));
Expand Down Expand Up @@ -232,14 +224,13 @@ public function testCreateFromChoicesDifferentFilterClosure()
$closure1 = function () {};
$closure2 = function () {};

$this->decoratedFactory->expects($this->at(0))
->method('createListFromChoices')
->with($choices, null, $closure1)
->willReturn($list1);
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createListFromChoices')
->with($choices, null, $closure2)
->willReturn($list2);
->withConsecutive(
[$choices, null, $closure1],
[$choices, null, $closure2]
)
->willReturnOnConsecutiveCalls($list1, $list2);

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

$this->decoratedFactory->expects($this->at(0))
->method('createListFromLoader')
->with($loader)
->willReturn($list)
;
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createListFromLoader')
->with($loader)
->willReturn($list2)
;
->willReturnOnConsecutiveCalls($list, $list2);

$this->assertSame($list, $this->factory->createListFromLoader($loader));
$this->assertSame($list2, $this->factory->createListFromLoader($loader));
Expand Down Expand Up @@ -309,16 +294,10 @@ public function testCreateFromLoaderSameValueClosure()
$list2 = new ArrayChoiceList([]);
$closure = function () {};

$this->decoratedFactory->expects($this->at(0))
->method('createListFromLoader')
->with($loader, $closure)
->willReturn($list)
;
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createListFromLoader')
->with($loader, $closure)
->willReturn($list2)
;
->willReturnOnConsecutiveCalls($list, $list2);

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

$this->decoratedFactory->expects($this->at(0))
->method('createListFromLoader')
->with($loader, null, $closure)
->willReturn($list)
;
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createListFromLoader')
->with($loader, null, $closure)
->willReturn($list2)
;
->willReturnOnConsecutiveCalls($list, $list2);

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

$this->decoratedFactory->expects($this->at(0))
->method('createListFromLoader')
->with($loader, null, $closure1)
->willReturn($list1);
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createListFromLoader')
->with($loader, null, $closure2)
->willReturn($list2);
->withConsecutive(
[$loader, null, $closure1],
[$loader, null, $closure2]
)
->willReturnOnConsecutiveCalls($list1, $list2);

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

$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, $preferred)
->willReturn($view)
;
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createView')
->with($list, $preferred)
->willReturn($view2)
;
->willReturnOnConsecutiveCalls($view, $view2);

$this->assertSame($view, $this->factory->createView($list, $preferred));
$this->assertSame($view2, $this->factory->createView($list, $preferred));
Expand Down Expand Up @@ -504,16 +470,10 @@ public function testCreateViewSamePreferredChoicesClosure()
$view = new ChoiceListView();
$view2 = new ChoiceListView();

$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, $preferred)
->willReturn($view)
;
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createView')
->with($list, $preferred)
->willReturn($view2)
;
->willReturnOnConsecutiveCalls($view, $view2);

$this->assertSame($view, $this->factory->createView($list, $preferred));
$this->assertSame($view2, $this->factory->createView($list, $preferred));
Expand Down Expand Up @@ -563,16 +523,10 @@ public function testCreateViewSameLabelClosure()
$view = new ChoiceListView();
$view2 = new ChoiceListView();

$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, null, $labels)
->willReturn($view)
;
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createView')
->with($list, null, $labels)
->willReturn($view2)
;
->willReturnOnConsecutiveCalls($view, $view2);

$this->assertSame($view, $this->factory->createView($list, null, $labels));
$this->assertSame($view2, $this->factory->createView($list, null, $labels));
Expand Down Expand Up @@ -622,16 +576,10 @@ public function testCreateViewSameIndexClosure()
$view = new ChoiceListView();
$view2 = new ChoiceListView();

$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, null, null, $index)
->willReturn($view)
;
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createView')
->with($list, null, null, $index)
->willReturn($view2)
;
->willReturnOnConsecutiveCalls($view, $view2);

$this->assertSame($view, $this->factory->createView($list, null, null, $index));
$this->assertSame($view2, $this->factory->createView($list, null, null, $index));
Expand Down Expand Up @@ -681,16 +629,10 @@ public function testCreateViewSameGroupByClosure()
$view = new ChoiceListView();
$view2 = new ChoiceListView();

$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, null, null, null, $groupBy)
->willReturn($view)
;
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createView')
->with($list, null, null, null, $groupBy)
->willReturn($view2)
;
->willReturnOnConsecutiveCalls($view, $view2);

$this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy));
$this->assertSame($view2, $this->factory->createView($list, null, null, null, $groupBy));
Expand Down Expand Up @@ -740,16 +682,10 @@ public function testCreateViewSameAttributes()
$view = new ChoiceListView();
$view2 = new ChoiceListView();

$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, null, null, null, null, $attr)
->willReturn($view)
;
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createView')
->with($list, null, null, null, null, $attr)
->willReturn($view2)
;
->willReturnOnConsecutiveCalls($view, $view2);

$this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr));
$this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr));
Expand Down Expand Up @@ -798,16 +734,10 @@ public function testCreateViewSameAttributesClosure()
$view = new ChoiceListView();
$view2 = new ChoiceListView();

$this->decoratedFactory->expects($this->at(0))
->method('createView')
->with($list, null, null, null, null, $attr)
->willReturn($view)
;
$this->decoratedFactory->expects($this->at(1))
$this->decoratedFactory->expects($this->exactly(2))
->method('createView')
->with($list, null, null, null, null, $attr)
->willReturn($view2)
;
->willReturnOnConsecutiveCalls($view, $view2);

$this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr));
$this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ public function testQueryForDn()
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query->expects($this->once())->method('execute')->willReturn($collection);

$this->ldap->expects($this->at(0))->method('bind')->with('elsa', 'test1234A$');
$this->ldap
->method('bind')
->withConsecutive(
['elsa', 'test1234A$']
);
$this->ldap->expects($this->any())->method('escape')->with('Wouter', '', LdapInterface::ESCAPE_FILTER)->willReturn('wouter');
$this->ldap->expects($this->once())->method('query')->with('{username}', 'wouter_test')->willReturn($query);

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

$this->ldap->expects($this->at(0))->method('bind')->with('elsa', 'test1234A$');
$this->ldap
->method('bind')
->withConsecutive(
['elsa', 'test1234A$']
);
$this->ldap->expects($this->once())->method('query')->willReturn($query);

$listener = $this->createListener();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,31 +198,36 @@ public function testKeepGettingPendingMessages()
->method('getQueueUrl')
->with(['QueueName' => 'queue', 'QueueOwnerAWSAccountId' => 123])
->willReturn(ResultMockFactory::create(GetQueueUrlResult::class, ['QueueUrl' => 'https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue']));
$client->expects($this->at(1))
$client->expects($this->exactly(2))
->method('receiveMessage')
->with([
'QueueUrl' => 'https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue',
'MaxNumberOfMessages' => 9,
'WaitTimeSeconds' => 20,
'MessageAttributeNames' => ['All'],
'VisibilityTimeout' => null,
])
->willReturn(ResultMockFactory::create(ReceiveMessageResult::class, ['Messages' => [
new Message(['MessageId' => 1, 'Body' => 'this is a test']),
new Message(['MessageId' => 2, 'Body' => 'this is a test']),
new Message(['MessageId' => 3, 'Body' => 'this is a test']),
]]));
$client->expects($this->at(2))
->method('receiveMessage')
->with([
'QueueUrl' => 'https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue',
'MaxNumberOfMessages' => 9,
'WaitTimeSeconds' => 20,
'MessageAttributeNames' => ['All'],
'VisibilityTimeout' => null,
])
->willReturn(ResultMockFactory::create(ReceiveMessageResult::class, ['Messages' => [
]]));
->withConsecutive(
[
[
'QueueUrl' => 'https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue',
'MaxNumberOfMessages' => 9,
'WaitTimeSeconds' => 20,
'MessageAttributeNames' => ['All'],
'VisibilityTimeout' => null,
],
],
[
[
'QueueUrl' => 'https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue',
'MaxNumberOfMessages' => 9,
'WaitTimeSeconds' => 20,
'MessageAttributeNames' => ['All'],
'VisibilityTimeout' => null,
],
]
)
->willReturnOnConsecutiveCalls(
ResultMockFactory::create(ReceiveMessageResult::class, ['Messages' => [
new Message(['MessageId' => 1, 'Body' => 'this is a test']),
new Message(['MessageId' => 2, 'Body' => 'this is a test']),
new Message(['MessageId' => 3, 'Body' => 'this is a test']),
]]),
ResultMockFactory::create(ReceiveMessageResult::class, ['Messages' => []])
);

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