Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reserved words used to name a class, interface or trait (#1406)
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
- Loading branch information
1 parent
abe61d7
commit da1efdb
Showing
5 changed files
with
147 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mockery\Tests\Unit\Regression; | ||
|
||
use Generator; | ||
use Mockery; | ||
use PDO; | ||
use PDOStatement; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @coversDefaultClass \Mockery | ||
* @uses \Mockery\Reflector | ||
*/ | ||
final class Issue1404Test extends TestCase | ||
{ | ||
/** | ||
* @return Generator<string,list<string>> | ||
*/ | ||
public static function provideResult(): Generator | ||
{ | ||
yield from [ | ||
'empty' => [[]], | ||
'non-empty' => [['Black', 'Lives', 'Matter']], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideResult | ||
*/ | ||
public function testDemeterChainsAllows(array $result): void | ||
{ | ||
$dbConnection = Mockery::mock(PDO::class); | ||
|
||
$dbConnection->allows('query->fetchAll')->andReturn($result); | ||
|
||
self::assertSame($result, $dbConnection->query('sql')->fetchAll()); | ||
} | ||
/** | ||
* @dataProvider provideResult | ||
*/ | ||
public function testDemeterChainsExpects(array $result): void | ||
{ | ||
$dbConnection = Mockery::mock(PDO::class); | ||
|
||
$dbConnection->expects('query->fetchAll')->andReturn($result); | ||
|
||
self::assertSame($result, $dbConnection->query('sql')->fetchAll()); | ||
} | ||
|
||
/** | ||
* @dataProvider provideResult | ||
*/ | ||
public function testDemeterChainsAlternativeSyntax(array $result): void | ||
{ | ||
$dbConnection = Mockery::mock(PDO::class); | ||
|
||
$dbConnection->shouldReceive('query->fetchAll')->andReturn($result); | ||
|
||
self::assertSame($result, $dbConnection->query('sql')->fetchAll()); | ||
} | ||
|
||
/** | ||
* @dataProvider provideResult | ||
*/ | ||
public function testNonDemeterChainsSyntax(array $result): void | ||
{ | ||
$dbStatement = Mockery::mock(PDOStatement::class); | ||
$dbStatement->expects('fetchAll') | ||
->andReturn($result); | ||
|
||
$dbConnection = Mockery::mock(PDO::class); | ||
$dbConnection->expects('query') | ||
->with('sql') | ||
->andReturn($dbStatement); | ||
|
||
self::assertSame($result, $dbConnection->query('sql')->fetchAll()); | ||
} | ||
} |