Skip to content

Commit b7423c9

Browse files
committed
Migrate away from getMockForAbstractClass()
It has been deprecated.
1 parent 28735af commit b7423c9

File tree

10 files changed

+13
-23
lines changed

10 files changed

+13
-23
lines changed

tests/Tests/ORM/Functional/QueryCacheTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ public function testQueryCacheHitDoesNotSaveParserResult(): void
122122

123123
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');
124124

125-
$sqlExecMock = $this->getMockBuilder(AbstractSqlExecutor::class)
126-
->getMockForAbstractClass();
125+
$sqlExecMock = $this->createMock(AbstractSqlExecutor::class);
127126

128127
$sqlExecMock->expects(self::once())
129128
->method('execute')

tests/Tests/ORM/Hydration/AbstractHydratorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ protected function setUp(): void
5454

5555
$this->hydrator = $this
5656
->getMockBuilder(AbstractHydrator::class)
57+
->onlyMethods(['hydrateAllData'])
5758
->setConstructorArgs([$mockEntityManagerInterface])
58-
->getMockForAbstractClass();
59+
->getMock();
5960
}
6061

6162
/**

tests/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55
namespace Doctrine\Tests\ORM\Mapping;
66

77
use Doctrine\DBAL\Platforms\AbstractPlatform;
8-
use Doctrine\DBAL\Schema\Name\UnquotedIdentifierFolding;
8+
use Doctrine\DBAL\Platforms\SQLitePlatform;
99
use Doctrine\ORM\Mapping\ClassMetadata;
1010
use Doctrine\ORM\Mapping\DefaultQuoteStrategy;
1111
use Doctrine\Tests\Models\NonPublicSchemaJoins\User as NonPublicSchemaUser;
1212
use Doctrine\Tests\OrmTestCase;
1313
use PHPUnit\Framework\Attributes\DataProvider;
1414
use PHPUnit\Framework\Attributes\Group;
1515

16-
use function assert;
17-
use function enum_exists;
1816
use function sprintf;
1917

2018
/**
@@ -29,8 +27,7 @@ public function testGetJoinTableName(): void
2927
$em = $this->getTestEntityManager();
3028
$metadata = $em->getClassMetadata(NonPublicSchemaUser::class);
3129
$strategy = new DefaultQuoteStrategy();
32-
$platform = $this->getMockForAbstractClass(AbstractPlatform::class, enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : []);
33-
assert($platform instanceof AbstractPlatform);
30+
$platform = new SQLitePlatform();
3431

3532
self::assertSame(
3633
'readers.author_reader',

tests/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ public function testUpdateUsesTypeValuesSQL(): void
6868

6969
$platform = $this->getMockBuilder(AbstractPlatform::class)
7070
->setConstructorArgs(enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : [])
71-
->onlyMethods(['supportsIdentityColumns'])
72-
->getMockForAbstractClass();
71+
->getMock();
7372
$platform->method('supportsIdentityColumns')
7473
->willReturn(true);
7574

tests/Tests/ORM/Persisters/ManyToManyPersisterTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
use Doctrine\DBAL\Connection;
88
use Doctrine\DBAL\Driver;
9-
use Doctrine\DBAL\Platforms\AbstractPlatform;
10-
use Doctrine\DBAL\Schema\Name\UnquotedIdentifierFolding;
9+
use Doctrine\DBAL\Platforms\SQLitePlatform;
1110
use Doctrine\ORM\Persisters\Collection\ManyToManyPersister;
1211
use Doctrine\Tests\Models\ManyToManyPersister\ChildClass;
1312
use Doctrine\Tests\Models\ManyToManyPersister\OtherParentClass;
@@ -16,8 +15,6 @@
1615
use PHPUnit\Framework\Attributes\CoversClass;
1716
use PHPUnit\Framework\Attributes\Group;
1817

19-
use function enum_exists;
20-
2118
#[CoversClass(ManyToManyPersister::class)]
2219
final class ManyToManyPersisterTest extends OrmTestCase
2320
{
@@ -34,7 +31,7 @@ public function testDeleteManyToManyCollection(): void
3431
->onlyMethods(['executeStatement', 'getDatabasePlatform'])
3532
->getMock();
3633
$connection->method('getDatabasePlatform')
37-
->willReturn($this->getMockForAbstractClass(AbstractPlatform::class, enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : []));
34+
->willReturn(new SQLitePlatform());
3835

3936
$parent = new ParentClass(1);
4037
$otherParent = new OtherParentClass(42);

tests/Tests/ORM/Query/ParserResultTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testItThrowsWhenAttemptingToAccessTheExecutorBeforeItIsSet(): vo
3737

3838
public function testSetGetSqlExecutor(): void
3939
{
40-
$executor = $this->getMockForAbstractClass(AbstractSqlExecutor::class);
40+
$executor = $this->createMock(AbstractSqlExecutor::class);
4141
$this->parserResult->setSqlExecutor($executor);
4242
self::assertSame($executor, $this->parserResult->getSqlExecutor());
4343
}

tests/Tests/ORM/Query/QueryTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,7 @@ private function createConnection(Result ...$results): Connection
600600

601601
$platform = $this->getMockBuilder(AbstractPlatform::class)
602602
->setConstructorArgs(enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : [])
603-
->onlyMethods(['supportsIdentityColumns'])
604-
->getMockForAbstractClass();
603+
->getMock();
605604
$platform->method('supportsIdentityColumns')
606605
->willReturn(true);
607606

tests/Tests/ORM/Tools/Pagination/PaginatorTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ protected function setUp(): void
3030
{
3131
$platform = $this->getMockBuilder(AbstractPlatform::class)
3232
->setConstructorArgs(enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : [])
33-
->onlyMethods(['supportsIdentityColumns'])
34-
->getMockForAbstractClass();
33+
->getMock();
3534
$platform->method('supportsIdentityColumns')
3635
->willReturn(true);
3736

tests/Tests/ORM/UnitOfWorkTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,7 @@ public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitFails(
570570
{
571571
$platform = $this->getMockBuilder(AbstractPlatform::class)
572572
->setConstructorArgs(enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : [])
573-
->onlyMethods(['supportsIdentityColumns'])
574-
->getMockForAbstractClass();
573+
->getMock();
575574
$platform->method('supportsIdentityColumns')
576575
->willReturn(true);
577576

tests/Tests/OrmTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private function createConnectionMock(AbstractPlatform $platform): Connection
146146
$connection = $this->getMockBuilder(Connection::class)
147147
->setConstructorArgs([[], $this->createDriverMock($platform)])
148148
->onlyMethods(['quote'])
149-
->getMockForAbstractClass();
149+
->getMock();
150150
$connection->method('quote')->willReturnCallback(static fn (string $input) => sprintf("'%s'", $input));
151151

152152
return $connection;

0 commit comments

Comments
 (0)