Skip to content

Commit

Permalink
GetMockForAbstractClass
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Jun 13, 2023
1 parent b66c59a commit f933619
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 39 deletions.
4 changes: 2 additions & 2 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ public function testPlatformDetectionFetchedFromParameters(): void

$driverConnectionMock = $this->createMock(Driver\Connection::class);

$platformMock = $this->getMockForAbstractClass(AbstractPlatform::class);
$platformMock = $this->createMock(AbstractPlatform::class);

$connection = new Connection(['serverVersion' => '8.0'], $driverMock);

Expand All @@ -552,7 +552,7 @@ public function testPlatformDetectionFetchedFromPrimaryReplicaParameters(): void

$driverConnectionMock = $this->createMock(Driver\Connection::class);

$platformMock = $this->getMockForAbstractClass(AbstractPlatform::class);
$platformMock = $this->createMock(AbstractPlatform::class);

$connection = new Connection(['primary' => ['serverVersion' => '8.0']], $driverMock);

Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Ticket/DBAL461Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DBAL461Test extends TestCase
public function testIssue(): void
{
$conn = $this->createMock(Connection::class);
$platform = $this->getMockForAbstractClass(SQLServerPlatform::class);
$platform = new SQLServerPlatform();
$platform->registerDoctrineTypeMapping('numeric', Types::DECIMAL);

$schemaManager = new SQLServerSchemaManager($conn, $platform);
Expand Down
2 changes: 1 addition & 1 deletion tests/Types/BaseDateTypeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class BaseDateTypeTestCase extends TestCase

protected function setUp(): void
{
$this->platform = $this->getMockForAbstractClass(AbstractPlatform::class);
$this->platform = $this->createMock(AbstractPlatform::class);
$this->currentTimezone = date_default_timezone_get();
}

Expand Down
33 changes: 0 additions & 33 deletions tests/Types/BinaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,39 +35,6 @@ public function testReturnsBindingType(): void
self::assertSame(ParameterType::BINARY, $this->type->getBindingType());
}

/**
* @param mixed[][] $definition
*
* @dataProvider definitionProvider()
*/
public function testReturnsSQLDeclaration(array $definition, string $expectedDeclaration): void
{
$platform = $this->getMockForAbstractClass(AbstractPlatform::class);
self::assertSame($expectedDeclaration, $this->type->getSQLDeclaration($definition, $platform));
}

/** @return mixed[][] */
public static function definitionProvider(): iterable
{
return [
'fixed-unspecified-length' => [
['fixed' => true],
'BINARY',
],
'fixed-specified-length' => [
[
'fixed' => true,
'length' => 20,
],
'BINARY(20)',
],
'variable-length' => [
['length' => 20],
'VARBINARY(20)',
],
];
}

public function testBinaryNullConvertsToPHPValue(): void
{
self::assertNull($this->type->convertToPHPValue(null, $this->platform));
Expand Down
3 changes: 3 additions & 0 deletions tests/Types/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ protected function setUp(): void
$this->type = new DateType();

parent::setUp();

$this->platform->method('getDateFormatString')
->willReturn('Y-m-d');
}

public function testDateConvertsToPHPValue(): void
Expand Down
5 changes: 4 additions & 1 deletion tests/Types/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ protected function setUp(): void
$this->type = new DateTimeType();

parent::setUp();

$this->platform->method('getDateTimeFormatString')
->willReturn('Y-m-d H:i:s');
}

public function testDateTimeConvertsToDatabaseValue(): void
{
$date = new DateTime('1985-09-01 10:10:10');

$expected = $date->format($this->platform->getDateTimeTzFormatString());
$expected = $date->format($this->platform->getDateTimeFormatString());
$actual = $this->type->convertToDatabaseValue($date, $this->platform);

self::assertEquals($expected, $actual);
Expand Down
3 changes: 3 additions & 0 deletions tests/Types/DateTimeTzTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ protected function setUp(): void
$this->type = new DateTimeTzType();

parent::setUp();

$this->platform->method('getDateTimeTzFormatString')
->willReturn('Y-m-d H:i:s');
}

public function testDateTimeConvertsToDatabaseValue(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Types/TimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ protected function setUp(): void
$this->type = new TimeType();

parent::setUp();

$this->platform->method('getTimeFormatString')
->willReturn('H:i:s');
}

public function testTimeConvertsToPHPValue(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Types/VarDateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class VarDateTimeTest extends TestCase

protected function setUp(): void
{
$this->platform = $this->getMockForAbstractClass(AbstractPlatform::class);
$this->platform = $this->createMock(AbstractPlatform::class);
$this->type = new VarDateTimeType();
}

Expand Down

0 comments on commit f933619

Please sign in to comment.