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 <taylorotwell@users.noreply.github.com>
  • Loading branch information
2 people authored and driesvints committed Sep 13, 2021
1 parent 120af34 commit ea94f26
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit ea94f26

Please sign in to comment.