Skip to content

Commit c9c4477

Browse files
committed
unit tests: add test.local.php configuration
1 parent 77ca3b4 commit c9c4477

3 files changed

Lines changed: 40 additions & 4 deletions

File tree

config/autoload/local.test.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
use LightTest\Common\TestMode;
5+
if (!TestMode::class::isEnabled()) {
6+
return [];
7+
}
8+
9+
return [
10+
'doctrine' => [
11+
'connection' => [
12+
'orm_default' => [
13+
'params' => [
14+
'url' => 'sqlite3:///:memory:',
15+
],
16+
],
17+
],
18+
],
19+
];

config/config.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040
// - `*.global.php`
4141
// - `local.php`
4242
// - `*.local.php`
43-
new PhpFileProvider(realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local}.php'),
44-
43+
// - `test.local.php`
44+
new PhpFileProvider(
45+
realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local,{,*.}test}.php'
46+
),
4547
// Load development config if it exists
4648
new PhpFileProvider(realpath(__DIR__) . '/development.config.php'),
4749
], $cacheConfig['config_cache_path']);

src/App/src/Entity/AbstractEntity.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use function ucfirst;
1616

1717
#[ORM\MappedSuperclass]
18-
abstract class AbstractEntity implements ArraySerializableInterface
18+
abstract class AbstractEntity implements ArraySerializableInterface, EntityInterface
1919
{
2020
#[ORM\Id]
2121
#[ORM\Column(name: 'id', type: 'uuid', unique: true, nullable: false)]
@@ -27,6 +27,9 @@ abstract class AbstractEntity implements ArraySerializableInterface
2727
#[ORM\Column(name: 'updated', type: 'datetime_immutable', nullable: true)]
2828
protected ?DateTimeImmutable $updated = null;
2929

30+
#[ORM\Column(name: 'deleted', type: 'boolean', nullable: false, options: ['default' => false])]
31+
protected bool $deleted = false;
32+
3033
public function __construct()
3134
{
3235
$this->id = Uuid::uuid7();
@@ -68,6 +71,18 @@ public function getUpdatedFormatted(string $dateFormat = 'Y-m-d H:i:s'): ?string
6871
return null;
6972
}
7073

74+
public function isDeleted(): bool
75+
{
76+
return $this->deleted;
77+
}
78+
79+
public function setDeleted(bool $deleted): static
80+
{
81+
$this->deleted = $deleted;
82+
83+
return $this;
84+
}
85+
7186
#[ORM\PrePersist]
7287
public function created(): void
7388
{
@@ -103,4 +118,4 @@ public function exchangeArray(array $array): void
103118
}
104119
}
105120
}
106-
}
121+
}

0 commit comments

Comments
 (0)