From 46536efc2afcdca80dc14b7ba353acdbd1fa435f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Thu, 6 Jun 2019 15:42:52 +0200 Subject: [PATCH] Fix XML configuration support for custom templates This functionality has been added on previous versions but it seems we forgot to expose the configuration options for XML. --- .../Migrations/Configuration/XML/configuration.xsd | 1 + .../Migrations/Configuration/XmlConfiguration.php | 4 ++++ .../Tests/Configuration/AbstractConfigurationTest.php | 7 +++++++ .../Configuration/_files/config_custom_template.json | 3 +++ .../Tests/Configuration/_files/config_custom_template.php | 5 +++++ .../Tests/Configuration/_files/config_custom_template.xml | 8 ++++++++ .../Tests/Configuration/_files/config_custom_template.yml | 2 ++ 7 files changed, 30 insertions(+) create mode 100644 tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.json create mode 100644 tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.php create mode 100644 tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.xml create mode 100644 tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.yml diff --git a/lib/Doctrine/Migrations/Configuration/XML/configuration.xsd b/lib/Doctrine/Migrations/Configuration/XML/configuration.xsd index 3c05f63048..0b5411018a 100644 --- a/lib/Doctrine/Migrations/Configuration/XML/configuration.xsd +++ b/lib/Doctrine/Migrations/Configuration/XML/configuration.xsd @@ -7,6 +7,7 @@ + diff --git a/lib/Doctrine/Migrations/Configuration/XmlConfiguration.php b/lib/Doctrine/Migrations/Configuration/XmlConfiguration.php index 79a95aa1ea..0c074828db 100644 --- a/lib/Doctrine/Migrations/Configuration/XmlConfiguration.php +++ b/lib/Doctrine/Migrations/Configuration/XmlConfiguration.php @@ -54,6 +54,10 @@ protected function doLoad(string $file) : void $config['name'] = (string) $xml->name; } + if (isset($xml->{'custom-template'})) { + $config['custom_template'] = (string) $xml->{'custom-template'}; + } + if (isset($xml->table['name'])) { $config['table_name'] = (string) $xml->table['name']; } diff --git a/tests/Doctrine/Migrations/Tests/Configuration/AbstractConfigurationTest.php b/tests/Doctrine/Migrations/Tests/Configuration/AbstractConfigurationTest.php index 99811eb21e..86b8c433e5 100644 --- a/tests/Doctrine/Migrations/Tests/Configuration/AbstractConfigurationTest.php +++ b/tests/Doctrine/Migrations/Tests/Configuration/AbstractConfigurationTest.php @@ -131,6 +131,13 @@ public function testVersionsOrganizationInvalid() : void $this->loadConfiguration('organize_invalid'); } + public function testCustomTemplate() : void + { + $config = $this->loadConfiguration('custom_template'); + + self::assertSame('template.tpl', $config->getCustomTemplate()); + } + public function testVersionsOrganizationIncompatibleFinder() : void { $this->expectException(MigrationException::class); diff --git a/tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.json b/tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.json new file mode 100644 index 0000000000..512256bc01 --- /dev/null +++ b/tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.json @@ -0,0 +1,3 @@ +{ + "custom_template" : "template.tpl" +} diff --git a/tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.php b/tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.php new file mode 100644 index 0000000000..a5ea37c0f6 --- /dev/null +++ b/tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.php @@ -0,0 +1,5 @@ + 'template.tpl']; diff --git a/tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.xml b/tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.xml new file mode 100644 index 0000000000..a81b572dff --- /dev/null +++ b/tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.xml @@ -0,0 +1,8 @@ + + + + template.tpl + diff --git a/tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.yml b/tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.yml new file mode 100644 index 0000000000..75ed71ac1a --- /dev/null +++ b/tests/Doctrine/Migrations/Tests/Configuration/_files/config_custom_template.yml @@ -0,0 +1,2 @@ +--- +custom_template: "template.tpl"