Skip to content

Commit

Permalink
chore: tests: fix "The at() matcher has been deprecated. It will be r…
Browse files Browse the repository at this point in the history
…emoved in PHPUnit 10. Please refactor your test to not rely on the order in which methods are invoked."

See also sebastianbergmann/phpunit#4297

The replacement using `withConsecutive` ought to do it.
  • Loading branch information
JasperSpence committed Mar 12, 2021
1 parent 8140d53 commit 21c8e14
Showing 1 changed file with 34 additions and 27 deletions.
61 changes: 34 additions & 27 deletions tests/Unit/Console/PublishCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,45 @@ public function testCommand(): void
])
->getMock();
$filesystemMock
->expects($this->at(2))
->expects($this->exactly(2))
->method('copy')
->with(
$this->callback(function (string $from): bool {
$this->assertMatchesRegularExpression('|/config/config.php|', $from, '1st call to copy, $from');
->withConsecutive(
[
$this->callback(function (string $from): bool {
$this->assertMatchesRegularExpression('|/config/config.php|', $from, '1st call to copy, $from');

return true;
}),
$this->callback(function (string $to): bool {
$this->assertMatchesRegularExpression('|laravel[/\\\\]config/graphql.php|', $to, '1st call to copy, $to');
return true;
}),
$this->callback(function (string $to): bool {
$this->assertMatchesRegularExpression(
'|laravel[/\\\\]config/graphql.php|',
$to,
'1st call to copy, $to'
);

return true;
})
);
$filesystemMock
->expects($this->at(5))
->method('copy')
->with(
$this->callback(function (string $from): bool {
$this->assertMatchesRegularExpression('|/resources/views/graphiql.php|', $from, '2nd call to copy, $from');
return true;
}),
],
[
$this->callback(function (string $from): bool {
$this->assertMatchesRegularExpression(
'|/resources/views/graphiql.php|',
$from,
'2nd call to copy, $from'
);

return true;
}),
$this->callback(function (string $to): bool {
$this->assertMatchesRegularExpression(
'|laravel[/\\\\]resources/views/vendor/graphql/graphiql.php|',
$to,
'2nd call to copy, $to'
);
return true;
}),
$this->callback(function (string $to): bool {
$this->assertMatchesRegularExpression(
'|laravel[/\\\\]resources/views/vendor/graphql/graphiql.php|',
$to,
'2nd call to copy, $to'
);

return true;
})
return true;
}),
]
);
$this->instance(Filesystem::class, $filesystemMock);

Expand Down

0 comments on commit 21c8e14

Please sign in to comment.