Skip to content

[tests] handle missing type config value for doctrine #1041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions tests/Maker/MakeEntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ private function createMakeEntityTest(bool $withDatabase = true): MakerTestDetai
{
return $this->createMakerTest()
->preRun(function (MakerTestRunner $runner) use ($withDatabase) {
if ($this->useAttributes($runner)) {
$config = $runner->readYaml('config/packages/doctrine.yaml');

if (isset($config['doctrine']['orm']['mappings']['App']['type']) && $this->useAttributes($runner)) {
// use attributes
$runner->replaceInFile(
'config/packages/doctrine.yaml',
Expand Down Expand Up @@ -656,13 +658,14 @@ private function setupGroupEntityInVendor(MakerTestRunner $runner)
);
}

private function changeToXmlMapping(MakerTestRunner $runner)
private function changeToXmlMapping(MakerTestRunner $runner): void
{
$runner->replaceInFile(
'config/packages/doctrine.yaml',
$this->useAttributes($runner) ? 'type: attribute' : 'type: annotation',
'type: xml'
);
$runner->modifyYamlFile('config/packages/doctrine.yaml', function (array $data) {
$data['doctrine']['orm']['mappings']['App']['type'] = 'xml';

return $data;
});

$runner->replaceInFile(
'config/packages/doctrine.yaml',
"dir: '%kernel.project_dir%/src/Entity'",
Expand Down