Skip to content

Commit

Permalink
[8.x ]Refactor setMethods to onlyMethods and addMethods
Browse files Browse the repository at this point in the history
`MockBuilder::setMethods` is soft deprecated as of PHPUnit 9
So I refactor the test.

Please merge laravel#35474  after merging

sebastianbergmann/phpunit#3687
  • Loading branch information
soilSpoon committed Dec 4, 2020
1 parent b89363b commit bf45f11
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/Database/DatabaseConnectionTest.php
Expand Up @@ -62,7 +62,7 @@ public function testSelectProperlyCallsPDO()
$writePdo = $this->getMockBuilder(DatabaseConnectionTestMockPDO::class)->onlyMethods(['prepare'])->getMock();
$writePdo->expects($this->never())->method('prepare');
$statement = $this->getMockBuilder('PDOStatement')
->setMethods(['setFetchMode', 'execute', 'fetchAll', 'bindValue'])
->onlyMethods(['setFetchMode', 'execute', 'fetchAll', 'bindValue'])
->getMock();
$statement->expects($this->once())->method('setFetchMode');
$statement->expects($this->once())->method('bindValue')->with('foo', 'bar', 2);
Expand Down
2 changes: 1 addition & 1 deletion tests/Validation/ValidationValidatorTest.php
Expand Up @@ -2872,7 +2872,7 @@ public function testValidateImage()
$v = new Validator($trans, ['x' => $file7], ['x' => 'Image']);
$this->assertTrue($v->passes());

$file2 = $this->getMockBuilder(UploadedFile::class)->setMethods(['guessExtension', 'getClientOriginalExtension'])->setConstructorArgs($uploadedFile)->getMock();
$file2 = $this->getMockBuilder(UploadedFile::class)->onlyMethods(['guessExtension', 'getClientOriginalExtension'])->setConstructorArgs($uploadedFile)->getMock();
$file2->expects($this->any())->method('guessExtension')->willReturn('jpg');
$file2->expects($this->any())->method('getClientOriginalExtension')->willReturn('jpg');
$v = new Validator($trans, ['x' => $file2], ['x' => 'Image']);
Expand Down

0 comments on commit bf45f11

Please sign in to comment.