Skip to content

Commit 6b9f7d8

Browse files
committed
Map embeddable money test with XML for convenience
1 parent 84e2f58 commit 6b9f7d8

File tree

5 files changed

+48
-2
lines changed

5 files changed

+48
-2
lines changed

tests/Maker/FunctionalTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,16 @@ public function getCommandEntityTests()
11441144
])
11451145
->setArgumentsString('--regenerate')
11461146
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeEntityRegenerateEmbeddableObject')
1147+
->addReplacement(
1148+
'config/packages/doctrine.yaml',
1149+
'type: annotation',
1150+
'type: xml'
1151+
)
1152+
->addReplacement(
1153+
'config/packages/doctrine.yaml',
1154+
"dir: '%kernel.project_dir%/src/Entity'",
1155+
"dir: '%kernel.project_dir%/config/doctrine'"
1156+
)
11471157
->configureDatabase()
11481158
->setRequiredPhpVersion(70100)
11491159
];
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
5+
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
6+
<embeddable name="Money\Currency">
7+
<field name="code" type="string" length="3">
8+
<options>
9+
<option name="fixed">true</option>
10+
</options>
11+
</field>
12+
</embeddable>
13+
</doctrine-mapping>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
4+
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
5+
6+
<entity name="App\Entity\Invoice">
7+
<id name="id" type="integer">
8+
<generator strategy="AUTO" />
9+
</id>
10+
11+
<field name="street" type="string" />
12+
13+
<embedded name="total" class="Money\\Money"/>
14+
</entity>
15+
</doctrine-mapping>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
5+
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
6+
<embeddable name="Money\Money">
7+
<field name="amount" type="string" />
8+
<embedded name="currency" class="Money\Currency" />
9+
</embeddable>
10+
</doctrine-mapping>

tests/fixtures/MakeEntityRegenerateEmbeddableObject/tests/GeneratedEntityTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
use Money\Money;
88
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
99
use Doctrine\ORM\EntityManager;
10-
use App\Entity\Food;
11-
use App\Entity\Recipe;
1210

1311
class GeneratedEntityTest extends KernelTestCase
1412
{

0 commit comments

Comments
 (0)