Skip to content

Commit e8c5b0b

Browse files
TatevikGrtatevikg1
andauthored
change test db to mysql (#341)
* change test db * update column lengths --------- Co-authored-by: Tatevik <[email protected]>
1 parent 7d26acc commit e8c5b0b

File tree

6 files changed

+25
-19
lines changed

6 files changed

+25
-19
lines changed

config/config_test.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ framework:
1111

1212
doctrine:
1313
dbal:
14-
driver: 'pdo_sqlite'
15-
memory: true
14+
driver: 'pdo_mysql'
15+
host: '%database_host%'
16+
port: '%database_port%'
17+
dbname: 'phplist'
18+
user: '%database_user%'
19+
password: '%database_password%'
1620
charset: UTF8
17-
# orm:
18-
# entity_managers:
19-
# default:
20-
# report_fields_where_declared: true
21+

src/Domain/Analytics/Model/LinkTrackForward.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ class LinkTrackForward implements DomainModel, Identity
2121
#[ORM\GeneratedValue]
2222
private ?int $id = null;
2323

24-
#[ORM\Column(type: 'string', length: 2083, nullable: true)]
24+
// Defined as string(255) due to MySQL limitation (actual max URL length is 2083):
25+
// TEXT can't be indexed without a prefix, which Doctrine doesn't support.
26+
#[ORM\Column(type: 'string', length: 255, nullable: true)]
2527
private ?string $url = null;
2628

2729
#[ORM\Column(name: 'urlhash', type: 'string', length: 32, nullable: true)]

src/Domain/Configuration/Model/I18n.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ class I18n implements DomainModel
1818
#[ORM\Column(type: 'string', length: 10)]
1919
private string $lan;
2020

21+
// Defined as string with length due to MySQL limitation:
22+
// TEXT columns can't be indexed without a prefix length, which Doctrine doesn't support.
2123
#[ORM\Id]
22-
#[ORM\Column(type: 'text')]
24+
#[ORM\Column(type: 'string', length: 255)]
2325
private string $original;
2426

2527
#[ORM\Column(type: 'text')]

src/Domain/Configuration/Model/UrlCache.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class UrlCache implements DomainModel, Identity
2020
#[ORM\GeneratedValue]
2121
private ?int $id = null;
2222

23-
#[ORM\Column(name: 'url', type: 'string', length: 2083)]
23+
// Defined as string(255) due to MySQL limitation (actual max URL length is 2083):
24+
// TEXT can't be indexed without a prefix, which Doctrine doesn't support.
25+
#[ORM\Column(name: 'url', type: 'string', length: 255)]
2426
private string $url;
2527

2628
#[ORM\Column(name: 'lastmodified', type: 'integer', nullable: true)]

src/TestingSupport/Traits/DatabaseTestTrait.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,17 @@ protected function loadSchema(): void
8383
$schemaTool = new SchemaTool($this->entityManager);
8484
$metadata = $this->entityManager->getMetadataFactory()->getAllMetadata();
8585

86-
$connection = $this->entityManager->getConnection();
87-
$schemaManager = $connection->createSchemaManager();
86+
try {
87+
$schemaTool->createSchema($metadata);
88+
} catch (ToolsException $e) {
89+
$connection = $this->entityManager->getConnection();
90+
$schemaManager = $connection->createSchemaManager();
8891

89-
foreach ($metadata as $classMetadata) {
90-
$tableName = $classMetadata->getTableName();
92+
foreach ($metadata as $classMetadata) {
93+
$tableName = $classMetadata->getTableName();
9194

92-
if (!$schemaManager->tablesExist([$tableName])) {
93-
try {
95+
if (!$schemaManager->tablesExist([$tableName])) {
9496
$schemaTool->createSchema([$classMetadata]);
95-
} catch (ToolsException $e) {
96-
// nothing to do
97-
echo $e->getMessage();
9897
}
9998
}
10099
}

tests/Integration/Domain/Identity/Repository/AdministratorRepositoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function tearDown(): void
4343
public function testFindReadsModelFromDatabase(): void
4444
{
4545
/** @var Administrator $actual */
46-
$actual = $this->repository->find(1);
46+
$actual = $this->repository->findOneBy(['email' => '[email protected]']);
4747

4848
$this->assertNotNull($actual);
4949
$this->assertFalse($actual->isDisabled());

0 commit comments

Comments
 (0)