Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/Connection/CachedQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private function createConnection(int $expectedQueryCount, array $columnNames, a
->method('query')
->willReturnCallback(static fn (): ArrayResult => new ArrayResult($columnNames, $rows));

$driver = $this->createMock(Driver::class);
$driver = self::createStub(Driver::class);
$driver->method('connect')
->willReturn($connection);

Expand Down
22 changes: 11 additions & 11 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ public function testTransactionIsNotActiveAfterTransactionalInAutoCommitMode():

public function testTransactionIsActiveAfterTransactionalInNoAutoCommitMode(): void
{
$platformMock = $this->createMock(AbstractPlatform::class);
$platformMock = self::createStub(AbstractPlatform::class);
$platformMock
->method('supportsSavepoints')
->willReturn(true);

$driverMock = $this->createMock(Driver::class);
$driverMock = self::createStub(Driver::class);
$driverMock
->method('connect')
->willReturn(
Expand Down Expand Up @@ -472,7 +472,7 @@ public function testFetch(string $method, callable $invoke, mixed $expected): vo
->willReturn($expected);

$driver = $this->createConfiguredMock(Driver::class, [
'connect' => $this->createMock(DriverConnection::class),
'connect' => self::createStub(DriverConnection::class),
]);

$conn = $this->getMockBuilder(Connection::class)
Expand Down Expand Up @@ -567,7 +567,7 @@ public function testPlatformDetectionTriggersConnectionIfRequiredByTheDriver():
->method('getServerVersion')
->willReturn('6.6.6');

$platform = $this->createMock(AbstractPlatform::class);
$platform = self::createStub(AbstractPlatform::class);

$driver = $this->createMock(Driver::class);
$driver->expects(self::once())
Expand All @@ -592,7 +592,7 @@ public function testPlatformDetectionDoesNotTriggerConnectionIfNotRequiredByTheD
$driverConnection->expects(self::never())
->method('getServerVersion');

$platform = $this->createMock(AbstractPlatform::class);
$platform = self::createStub(AbstractPlatform::class);

$driver = $this->createMock(Driver::class);
$driver->expects(self::never())
Expand All @@ -610,9 +610,9 @@ public function testPlatformDetectionFetchedFromParameters(): void
{
$driverMock = $this->createMock(Driver::class);

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

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

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

Expand All @@ -632,9 +632,9 @@ public function testPlatformDetectionFetchedFromPrimaryReplicaParameters(): void
{
$driverMock = $this->createMock(Driver::class);

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

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

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

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

public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCacheQuery(): void
{
$cacheItemMock = $this->createMock(CacheItemInterface::class);
$cacheItemMock = self::createStub(CacheItemInterface::class);
$cacheItemMock->method('isHit')->willReturn(true);
$cacheItemMock->method('get')->willReturn(['realKey' => [[], []]]);

Expand Down Expand Up @@ -684,7 +684,7 @@ public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCach
->with($query, $params, $types, $expectedConnectionParams)
->willReturn(['cacheKey', 'realKey']);

$driver = $this->createMock(Driver::class);
$driver = self::createStub(Driver::class);

(new Connection(self::CONNECTION_PARAMS, $driver))
->executeCacheQuery($query, $params, $types, $queryCacheProfileMock);
Expand Down
4 changes: 2 additions & 2 deletions tests/Driver/Middleware/AbstractConnectionMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class AbstractConnectionMiddlewareTest extends TestCase
{
public function testPrepare(): void
{
$statement = $this->createMock(Statement::class);
$statement = self::createStub(Statement::class);
$connection = $this->createMock(Connection::class);
$connection->expects(self::once())
->method('prepare')
Expand All @@ -26,7 +26,7 @@ public function testPrepare(): void

public function testQuery(): void
{
$result = $this->createMock(Result::class);
$result = self::createStub(Result::class);
$connection = $this->createMock(Connection::class);
$connection->expects(self::once())
->method('query')
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/Middleware/AbstractDriverMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class AbstractDriverMiddlewareTest extends TestCase
{
public function testConnect(): void
{
$connection = $this->createMock(Connection::class);
$connection = self::createStub(Connection::class);
$driver = $this->createMock(Driver::class);
$driver->expects(self::once())
->method('connect')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class AbstractStatementMiddlewareTest extends TestCase
{
public function testExecute(): void
{
$result = $this->createMock(Result::class);
$result = self::createStub(Result::class);
$statement = $this->createMock(Statement::class);
$statement->expects(self::once())
->method('execute')
Expand Down
2 changes: 1 addition & 1 deletion tests/DriverManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testInvalidDriver(): void
#[RequiresPhpExtension('sqlite3')]
public function testCustomWrapper(): void
{
$wrapper = $this->createMock(Connection::class);
$wrapper = self::createStub(Connection::class);
$wrapperClass = $wrapper::class;

$options = [
Expand Down
4 changes: 2 additions & 2 deletions tests/Logging/MiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class MiddlewareTest extends TestCase
#[Override]
public function setUp(): void
{
$connection = $this->createMock(Connection::class);
$connection = self::createStub(Connection::class);

$driver = $this->createMock(Driver::class);
$driver = self::createStub(Driver::class);
$driver->method('connect')
->willReturn($connection);

Expand Down
2 changes: 1 addition & 1 deletion tests/Portability/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testGetNativeConnection(): void
$nativeConnection = new class () {
};

$driverConnection = $this->createMock(ConnectionInterface::class);
$driverConnection = self::createStub(ConnectionInterface::class);
$driverConnection->method('getNativeConnection')
->willReturn($nativeConnection);

Expand Down
2 changes: 1 addition & 1 deletion tests/Query/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function setUp(): void
$this->conn->method('createExpressionBuilder')
->willReturnCallback(fn () => new ExpressionBuilder($this->conn));

$platform = $this->createMock(AbstractPlatform::class);
$platform = self::createStub(AbstractPlatform::class);
$platform->method('getUnionSelectPartSQL')
->willReturnArgument(0);
$platform->method('getUnionAllSQL')
Expand Down
2 changes: 1 addition & 1 deletion tests/Schema/ColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function testSettingUnknownOptionIsStillSupported(): void
$this->expectException(UnknownColumnOption::class);
$this->expectExceptionMessage('The "unknown_option" column option is not supported.');

new Column('foo', $this->createMock(Type::class), ['unknown_option' => 'bar']);
new Column('foo', self::createStub(Type::class), ['unknown_option' => 'bar']);
}

public function testOptionsShouldNotBeIgnored(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Schema/MySQLInheritCharsetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function testTableOptions(): void
*/
private function getTableOptionsForOverride(array $params = []): array
{
$driverMock = $this->createMock(Driver::class);
$driverMock = self::createStub(Driver::class);

$platform = new MySQLPlatform();
$conn = new Connection($params, $driverMock, new Configuration());
Expand Down
2 changes: 1 addition & 1 deletion tests/Tools/DsnParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static function databaseUrls(): iterable

public function testDriverClassScheme(): void
{
$driverClass = get_class($this->createMock(Driver::class));
$driverClass = get_class(self::createStub(Driver::class));
$parser = new DsnParser(['custom' => $driverClass]);
$actual = $parser->parse('custom://foo:bar@localhost/baz');

Expand Down
6 changes: 3 additions & 3 deletions tests/Types/BinaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Doctrine\DBAL\Types\ConversionException;
use Override;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;

use function array_map;
Expand All @@ -21,13 +21,13 @@

class BinaryTest extends TestCase
{
protected AbstractPlatform&MockObject $platform;
protected AbstractPlatform&Stub $platform;
protected BinaryType $type;

#[Override]
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
$this->platform = self::createStub(AbstractPlatform::class);
$this->type = new BinaryType();
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Types/BlobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\BlobType;
use Override;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;

class BlobTest extends TestCase
{
protected AbstractPlatform&MockObject $platform;
protected AbstractPlatform&Stub $platform;
protected BlobType $type;

#[Override]
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
$this->platform = self::createStub(AbstractPlatform::class);
$this->type = new BlobType();
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Types/ConversionExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ConversionExceptionTest extends TestCase
{
public function testConversionFailedPreviousException(): void
{
$previous = $this->createMock(Throwable::class);
$previous = self::createStub(Throwable::class);

$exception = ValueNotConvertible::new('foo', 'foo', null, $previous);

Expand Down Expand Up @@ -55,7 +55,7 @@ public function testConversionFailedInvalidTypeWithNonScalar(mixed $nonScalar):

public function testConversionFailedInvalidTypePreviousException(): void
{
$previous = $this->createMock(Throwable::class);
$previous = self::createStub(Throwable::class);

$exception = InvalidType::new('foo', 'foo', ['bar', 'baz'], $previous);

Expand All @@ -64,7 +64,7 @@ public function testConversionFailedInvalidTypePreviousException(): void

public function testConversionFailedFormatPreservesPreviousException(): void
{
$previous = $this->createMock(Throwable::class);
$previous = self::createStub(Throwable::class);

$exception = InvalidFormat::new('foo', 'bar', 'baz', $previous);

Expand Down
7 changes: 2 additions & 5 deletions tests/Types/DateImmutableTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use DateTime;
use DateTimeImmutable;
use DateTimeZone;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
Expand Down Expand Up @@ -38,15 +39,11 @@ public function testReturnsBindingType(): void

public function testConvertsDateTimeImmutableInstanceToDatabaseValue(): void
{
$date = $this->createMock(DateTimeImmutable::class);
$date = new DateTimeImmutable('2016-01-01 12:34:56', new DateTimeZone('UTC'));

$this->platform->expects(self::once())
->method('getDateFormatString')
->willReturn('Y-m-d');
$date->expects(self::once())
->method('format')
->with('Y-m-d')
->willReturn('2016-01-01');

self::assertSame(
'2016-01-01',
Expand Down
6 changes: 3 additions & 3 deletions tests/Types/DateIntervalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
use Doctrine\DBAL\Types\DateIntervalType;
use Override;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;
use stdClass;

final class DateIntervalTest extends TestCase
{
private AbstractPlatform&MockObject $platform;
private AbstractPlatform&Stub $platform;
private DateIntervalType $type;

#[Override]
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
$this->platform = self::createStub(AbstractPlatform::class);
$this->type = new DateIntervalType();
}

Expand Down
7 changes: 2 additions & 5 deletions tests/Types/DateTimeImmutableTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use DateTime;
use DateTimeImmutable;
use DateTimeZone;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
Expand Down Expand Up @@ -38,15 +39,11 @@ public function testReturnsBindingType(): void

public function testConvertsDateTimeImmutableInstanceToDatabaseValue(): void
{
$date = $this->createMock(DateTimeImmutable::class);
$date = new DateTimeImmutable('2016-01-01 15:58:59', new DateTimeZone('UTC'));

$this->platform->expects(self::once())
->method('getDateTimeFormatString')
->willReturn('Y-m-d H:i:s');
$date->expects(self::once())
->method('format')
->with('Y-m-d H:i:s')
->willReturn('2016-01-01 15:58:59');

self::assertSame(
'2016-01-01 15:58:59',
Expand Down
7 changes: 2 additions & 5 deletions tests/Types/DateTimeTzImmutableTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use DateTime;
use DateTimeImmutable;
use DateTimeZone;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
Expand Down Expand Up @@ -38,15 +39,11 @@ public function testReturnsBindingType(): void

public function testConvertsDateTimeImmutableInstanceToDatabaseValue(): void
{
$date = $this->createMock(DateTimeImmutable::class);
$date = new DateTimeImmutable('2016-01-01 15:58:59', new DateTimeZone('UTC'));

$this->platform->expects(self::once())
->method('getDateTimeTzFormatString')
->willReturn('Y-m-d H:i:s T');
$date->expects(self::once())
->method('format')
->with('Y-m-d H:i:s T')
->willReturn('2016-01-01 15:58:59 UTC');

self::assertSame(
'2016-01-01 15:58:59 UTC',
Expand Down
6 changes: 3 additions & 3 deletions tests/Types/DecimalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\DecimalType;
use Override;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;

class DecimalTest extends TestCase
{
private AbstractPlatform&MockObject $platform;
private AbstractPlatform&Stub $platform;
private DecimalType $type;

#[Override]
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
$this->platform = self::createStub(AbstractPlatform::class);
$this->type = new DecimalType();
}

Expand Down
Loading