Skip to content

Commit

Permalink
Fix type errors in db tests (#38696)
Browse files Browse the repository at this point in the history
* Fix type errors in db tests

* Apply fixes from StyleCI

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
GrahamCampbell and taylorotwell authored Sep 7, 2021
1 parent 67928ec commit 6307d34
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ protected function pingCallback($url)
return function (Container $container, HttpClient $http) use ($url) {
try {
$http->request('GET', $url);
} catch (ClientExceptionInterface | TransferException $e) {
} catch (ClientExceptionInterface|TransferException $e) {
$container->make(ExceptionHandler::class)->report($e);
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Routing/CompiledRouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function match(Request $request)
if ($result = $matcher->matchRequest($trimmedRequest)) {
$route = $this->getByName($result['_route']);
}
} catch (ResourceNotFoundException | MethodNotAllowedException $e) {
} catch (ResourceNotFoundException|MethodNotAllowedException $e) {
try {
return $this->routes->match($request);
} catch (NotFoundHttpException $e) {
Expand All @@ -136,7 +136,7 @@ public function match(Request $request)
if (! $dynamicRoute->isFallback) {
$route = $dynamicRoute;
}
} catch (NotFoundHttpException | MethodNotAllowedHttpException $e) {
} catch (NotFoundHttpException|MethodNotAllowedHttpException $e) {
//
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Traits/ForwardsCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function forwardCallTo($object, $method, $parameters)
{
try {
return $object->{$method}(...$parameters);
} catch (Error | BadMethodCallException $e) {
} catch (Error|BadMethodCallException $e) {
$pattern = '~^Call to undefined method (?P<class>[^:]+)::(?P<method>[^\(]+)\(\)$~';

if (! preg_match($pattern, $e->getMessage(), $matches)) {
Expand Down
12 changes: 6 additions & 6 deletions tests/Database/DatabaseConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,22 @@ public function testUpdateCallsTheAffectingStatementMethod()
public function testDeleteCallsTheAffectingStatementMethod()
{
$connection = $this->getMockConnection(['affectingStatement']);
$connection->expects($this->once())->method('affectingStatement')->with($this->equalTo('foo'), $this->equalTo(['bar']))->willReturn('baz');
$connection->expects($this->once())->method('affectingStatement')->with($this->equalTo('foo'), $this->equalTo(['bar']))->willReturn(true);
$results = $connection->delete('foo', ['bar']);
$this->assertSame('baz', $results);
$this->assertTrue($results);
}

public function testStatementProperlyCallsPDO()
{
$pdo = $this->getMockBuilder(DatabaseConnectionTestMockPDO::class)->onlyMethods(['prepare'])->getMock();
$statement = $this->getMockBuilder('PDOStatement')->onlyMethods(['execute', 'bindValue'])->getMock();
$statement->expects($this->once())->method('bindValue')->with(1, 'bar', 2);
$statement->expects($this->once())->method('execute')->willReturn('foo');
$statement->expects($this->once())->method('execute')->willReturn(true);
$pdo->expects($this->once())->method('prepare')->with($this->equalTo('foo'))->willReturn($statement);
$mock = $this->getMockConnection(['prepareBindings'], $pdo);
$mock->expects($this->once())->method('prepareBindings')->with($this->equalTo(['bar']))->willReturn(['bar']);
$results = $mock->statement('foo', ['bar']);
$this->assertSame('foo', $results);
$this->assertTrue($results);
$log = $mock->getQueryLog();
$this->assertSame('foo', $log[0]['query']);
$this->assertEquals(['bar'], $log[0]['bindings']);
Expand All @@ -127,12 +127,12 @@ public function testAffectingStatementProperlyCallsPDO()
$statement = $this->getMockBuilder('PDOStatement')->onlyMethods(['execute', 'rowCount', 'bindValue'])->getMock();
$statement->expects($this->once())->method('bindValue')->with('foo', 'bar', 2);
$statement->expects($this->once())->method('execute');
$statement->expects($this->once())->method('rowCount')->willReturn(['boom']);
$statement->expects($this->once())->method('rowCount')->willReturn(42);
$pdo->expects($this->once())->method('prepare')->with('foo')->willReturn($statement);
$mock = $this->getMockConnection(['prepareBindings'], $pdo);
$mock->expects($this->once())->method('prepareBindings')->with($this->equalTo(['foo' => 'bar']))->willReturn(['foo' => 'bar']);
$results = $mock->update('foo', ['foo' => 'bar']);
$this->assertEquals(['boom'], $results);
$this->assertSame(42, $results);
$log = $mock->getQueryLog();
$this->assertSame('foo', $log[0]['query']);
$this->assertEquals(['foo' => 'bar'], $log[0]['bindings']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class UnionListener
{
public function handle(EventOne | EventTwo $event)
public function handle(EventOne|EventTwo $event)
{
//
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Support/Fixtures/UnionTypesClosure.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
use Illuminate\Tests\Support\AnotherExampleParameter;
use Illuminate\Tests\Support\ExampleParameter;

return function (ExampleParameter | AnotherExampleParameter $a, $b) {
return function (ExampleParameter|AnotherExampleParameter $a, $b) {
//
};

0 comments on commit 6307d34

Please sign in to comment.