Skip to content

Commit b521e89

Browse files
committed
Merge branch '3.6.x' into 4.0.x
* 3.6.x: Don't partially mock the AbstractPlatform class (doctrine#12114)
2 parents a6a94cd + 831232e commit b521e89

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

tests/Tests/ORM/Query/SelectSqlGenerationTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ public function testSupportsMultipleJoins(): void
447447

448448
public function testSupportsTrimFunction(): void
449449
{
450+
$this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform());
451+
450452
$this->assertSqlGeneration(
451453
"SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(TRAILING ' ' FROM u.name) = 'someone'",
452454
"SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE TRIM(TRAILING ' ' FROM c0_.name) = 'someone'",
@@ -456,6 +458,8 @@ public function testSupportsTrimFunction(): void
456458
#[Group('DDC-2668')]
457459
public function testSupportsTrimLeadingZeroString(): void
458460
{
461+
$this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform());
462+
459463
$this->assertSqlGeneration(
460464
"SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(TRAILING '0' FROM u.name) != ''",
461465
"SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE TRIM(TRAILING '0' FROM c0_.name) <> ''",
@@ -579,6 +583,8 @@ public function testSupportsNotInExpressionInWherePart(): void
579583
#[Group('DDC-1802')]
580584
public function testSupportsNotInExpressionForModFunction(): void
581585
{
586+
$this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform());
587+
582588
$this->assertSqlGeneration(
583589
'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE MOD(u.id, 5) NOT IN(1,3,4)',
584590
'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE MOD(c0_.id, 5) NOT IN (1, 3, 4)',
@@ -1916,6 +1922,8 @@ public function testCaseThenParameterArithmeticExpression(): void
19161922
#[Group('DDC-2268')]
19171923
public function testCaseThenFunction(): void
19181924
{
1925+
$this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform());
1926+
19191927
$this->assertSqlGeneration(
19201928
'SELECT CASE WHEN LENGTH(u.name) <> 0 THEN CONCAT(u.id, u.name) ELSE u.id END AS name FROM Doctrine\Tests\Models\CMS\CmsUser u',
19211929
'SELECT CASE WHEN LENGTH(c0_.name) <> 0 THEN c0_.id || c0_.name ELSE c0_.id END AS sclr_0 FROM cms_users c0_',

tests/Tests/OrmTestCase.php

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
use Doctrine\DBAL\Driver;
99
use Doctrine\DBAL\Driver\Result;
1010
use Doctrine\DBAL\Platforms\AbstractPlatform;
11-
use Doctrine\DBAL\Schema\AbstractSchemaManager;
12-
use Doctrine\DBAL\Schema\Name\UnquotedIdentifierFolding;
13-
use Doctrine\DBAL\Schema\SchemaConfig;
11+
use Doctrine\DBAL\Platforms\SQLitePlatform;
1412
use Doctrine\ORM\Cache\CacheConfiguration;
1513
use Doctrine\ORM\Cache\CacheFactory;
1614
use Doctrine\ORM\Cache\DefaultCacheFactory;
@@ -22,7 +20,6 @@
2220
use Psr\Cache\CacheItemPoolInterface;
2321
use Symfony\Component\Cache\Adapter\ArrayAdapter;
2422

25-
use function enum_exists;
2623
use function realpath;
2724
use function sprintf;
2825

@@ -66,9 +63,7 @@ protected function createAttributeDriver(array $paths = []): AttributeDriver
6663
*/
6764
protected function getTestEntityManager(): EntityManagerMock
6865
{
69-
return $this->buildTestEntityManagerWithPlatform(
70-
$this->createConnectionMock($this->createPlatformMock()),
71-
);
66+
return $this->createTestEntityManagerWithPlatform(new SQLitePlatform());
7267
}
7368

7469
protected function createTestEntityManagerWithConnection(Connection $connection): EntityManagerMock
@@ -147,24 +142,6 @@ private function createConnectionMock(AbstractPlatform $platform): Connection
147142
return $connection;
148143
}
149144

150-
private function createPlatformMock(): AbstractPlatform
151-
{
152-
$schemaManager = $this->createMock(AbstractSchemaManager::class);
153-
$schemaManager->method('createSchemaConfig')
154-
->willReturn(new SchemaConfig());
155-
156-
$platform = $this->getMockBuilder(AbstractPlatform::class)
157-
->setConstructorArgs(enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : [])
158-
->onlyMethods(['supportsIdentityColumns', 'createSchemaManager'])
159-
->getMockForAbstractClass();
160-
$platform->method('supportsIdentityColumns')
161-
->willReturn(true);
162-
$platform->method('createSchemaManager')
163-
->willReturn($schemaManager);
164-
165-
return $platform;
166-
}
167-
168145
private function createDriverMock(AbstractPlatform $platform): Driver
169146
{
170147
$result = $this->createMock(Result::class);

0 commit comments

Comments
 (0)