From c77d90f068ca08f7e3aa896ab0015053cfca6ea0 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Fri, 7 Jul 2023 18:20:31 +0200 Subject: [PATCH 1/3] Pimcore 11 Support, see #41 --- .gitignore | 2 +- README.md | 19 +++--- UPGRADE.md | 24 +++---- codeception.dist.yml | 9 +-- composer.json | 13 ++-- docs/10_FormBuilder.md | 8 +-- src/EmailizrBundle/Collector/CssCollector.php | 2 +- src/EmailizrBundle/EmailizrBundle.php | 11 +--- src/EmailizrBundle/Parser/InkyParser.php | 12 +--- .../Parser/InlineStyleParser.php | 12 +--- .../Resources/config/services/twig.yml | 4 -- .../Resources/views/layout.html.twig | 24 ++++--- src/EmailizrBundle/Service/ContentService.php | 15 ++--- .../Twig/Extension/InkyExtension.php | 36 ---------- .../Twig/Extension/InlineStyleExtension.php | 2 +- src/EmailizrBundle/Twig/Node/InkyNode.php | 24 ------- .../Twig/Parser/InkyTokenParser.php | 36 ---------- .../Twig/Parser/InlineStyleTokenParser.php | 9 +-- tests/Support/FunctionalTester.php | 7 ++ tests/Support/UnitTester.php | 8 +++ tests/Unit.suite.dist.yml | 7 ++ tests/{unit => Unit}/CssCollectorTest.php | 10 +-- tests/{unit => Unit}/InkyParserTest.php | 17 ++--- .../{unit => Unit}/InlineStyleParserTest.php | 19 +++--- tests/Unit/TwigInkyExtensionTest.php | 30 +++++++++ .../TwigInlineStyleExtensionTest.php | 22 +++---- tests/{unit => Unit}/_bootstrap.php | 0 tests/_bootstrap.php | 7 +- tests/_envs/github.yml | 2 +- tests/_envs/local.yml | 2 +- tests/_etc/config.yaml | 9 +++ tests/_etc/config.yml | 5 -- tests/_etc/config/app/config.yaml | 56 ++++++++++++++++ tests/_etc/config/app/config.yml | 35 ---------- tests/_etc/config/app/system.yml | 65 ------------------- tests/_etc/config/app/system_settings.yaml | 49 ++++++++++++++ .../_etc/config/bundle/config_default.yaml | 0 tests/_etc/config/bundle/config_default.yml | 0 tests/_etc/inky/inline-style.thtml | 2 +- tests/_support/FunctionalTester.php | 8 --- tests/_support/UnitTester.php | 8 --- tests/unit.suite.dist.yml | 7 -- tests/unit/TwigInkyExtensionTest.php | 43 ------------ 43 files changed, 259 insertions(+), 421 deletions(-) delete mode 100644 src/EmailizrBundle/Twig/Extension/InkyExtension.php delete mode 100644 src/EmailizrBundle/Twig/Node/InkyNode.php delete mode 100644 src/EmailizrBundle/Twig/Parser/InkyTokenParser.php create mode 100644 tests/Support/FunctionalTester.php create mode 100644 tests/Support/UnitTester.php create mode 100644 tests/Unit.suite.dist.yml rename tests/{unit => Unit}/CssCollectorTest.php (76%) rename tests/{unit => Unit}/InkyParserTest.php (91%) rename tests/{unit => Unit}/InlineStyleParserTest.php (83%) create mode 100644 tests/Unit/TwigInkyExtensionTest.php rename tests/{unit => Unit}/TwigInlineStyleExtensionTest.php (73%) rename tests/{unit => Unit}/_bootstrap.php (100%) create mode 100644 tests/_etc/config.yaml delete mode 100644 tests/_etc/config.yml create mode 100755 tests/_etc/config/app/config.yaml delete mode 100755 tests/_etc/config/app/config.yml delete mode 100755 tests/_etc/config/app/system.yml create mode 100755 tests/_etc/config/app/system_settings.yaml rename src/EmailizrBundle/Resources/config/pimcore/config.yml => tests/_etc/config/bundle/config_default.yaml (100%) mode change 100644 => 100755 delete mode 100755 tests/_etc/config/bundle/config_default.yml delete mode 100644 tests/_support/FunctionalTester.php delete mode 100644 tests/_support/UnitTester.php delete mode 100644 tests/unit.suite.dist.yml delete mode 100644 tests/unit/TwigInkyExtensionTest.php diff --git a/.gitignore b/.gitignore index c4c84f2..c63d370 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,4 @@ php-cgi.core /tests/_output/* /tests/_data/* !/tests/_data/.gitkeep -/tests/_support/_generated/* +/tests/Support/_generated/* diff --git a/README.md b/README.md index 45a4441..d813301 100644 --- a/README.md +++ b/README.md @@ -7,21 +7,22 @@ [![PhpStan](https://img.shields.io/github/actions/workflow/status/dachcom-digital/pimcore-dynamic-search/.github/workflows/php-stan.yml?branch=master&style=flat-square&logo=github&label=phpstan%20level%204)](https://github.com/dachcom-digital/pimcore-emailizr/actions?query=workflow%3A%22PHP%20Stan%22) ### Requirements -* Pimcore >= 10.1.0 -* PHP >= 8.0 +* Pimcore: ^11.0 +* PHP: >= 8.1 ### Release Plan -| Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch | -|---------|----------------------------|----------------------------|--------------|----------------|------------| -| **2.x** | `10.1` - `10.6` | `^5.4` | 21.09.2021 | Feature Branch | dev-master | -| **1.x** | `6.0` - `6.9` | `3.4`, `^4.4` | 06.12.2017 | No | 1.x | +| Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch | +|---------|----------------------------|----------------------------|--------------|----------------|---------------------------------------------------------------------| +| **3.x** | `11.0` | `^5.4` | -- | Feature Branch | master | +| **2.x** | `10.1` - `10.6` | `^5.4` | 21.09.2021 | Maintained | [2.x](https://github.com/dachcom-digital/pimcore-emailizr/tree/2.x) | +| **1.x** | `6.0` - `6.9` | `3.4`, `^4.4` | 06.12.2017 | No | [1.x](https://github.com/dachcom-digital/pimcore-emailizr/tree/1.x) | ## Installation ```json "require" : { - "dachcom-digital/emailizr" : "~2.0.0", + "dachcom-digital/emailizr" : "~3.0.0", } ``` @@ -53,7 +54,7 @@ This will include a markup like this. You may want to change it: {% endblock %} -{% emailizr_inky %} +{% apply inky_to_html %} {% block body %} @@ -70,7 +71,7 @@ This will include a markup like this. You may want to change it:
                                                           
{% endblock %} -{% end_emailizr_inky %} +{% endapply %} {% end_emailizr_inline_style %} {% endapply %} diff --git a/UPGRADE.md b/UPGRADE.md index 37501b6..67f13c1 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,20 +1,14 @@ # Upgrade Notes +-- -## Version 2.0.3 -- Allow `pelago/emogrifier:^7.0` -- Bump `lorenzo/pinky` to `1.0.9` - -## Version 2.0.2 -- Allow Pimcore 11 -- Fix parsing of variables in links (`link`) - -## Version 2.0.1 -- [ENHANCEMENT] PHP 8.1 compatibility [@scrummer](https://github.com/dachcom-digital/pimcore-emailizr/pull/35) - -## Migrating from Version 1.x to Version 2.0.0 -- Pimcore X support only -- PHP 8.0 support only +## Migrating from Version 2.x to Version 3.0.0 +- Pimcore 11.0 support only +- PHP >= 8.1 support only +- [NEW FEATURE][BC BREAK] We're now using the symfony [inky parser](https://twig.symfony.com/doc/2.x/filters/inky_to_html.html) instead of `lorenzo/pinky` (which will be used by twig, but we want to stick with Symfony's recommended stack). + - replace `{% emailizr_inky %}` with `{% apply inky_to_html %}` + - replace `{% end_emailizr_inky %}` with `{% endapply %}` +- [BC BREAK] `@Emailizr/layout.html.twig` is using inky markup by default *** -Emailizr 1.x Upgrade Notes: https://github.com/dachcom-digital/pimcore-emailizr/blob/1.x/UPGRADE.md +Emailizr 2.x Upgrade Notes: https://github.com/dachcom-digital/pimcore-emailizr/blob/2.x/UPGRADE.md diff --git a/codeception.dist.yml b/codeception.dist.yml index 882426c..296aad2 100644 --- a/codeception.dist.yml +++ b/codeception.dist.yml @@ -1,14 +1,15 @@ namespace: DachcomBundle\Test +support_namespace: Support actor: Tester paths: tests: tests - output: tests/_output - data: tests/_data - support: tests/_support envs: tests/_envs + output: tests/_output log: tests/_output/var/logs + data: tests/_data + support: tests/Support +bootstrap: _bootstrap.php settings: - bootstrap: _bootstrap.php memory_limit: -1 colors: true params: diff --git a/composer.json b/composer.json index 1c0019a..fa669e8 100755 --- a/composer.json +++ b/composer.json @@ -28,19 +28,16 @@ "bundles": [ "EmailizrBundle\\EmailizrBundle" ] - }, - "branch-alias": { - "dev-master": "2.0-dev" } }, "require": { - "pimcore/pimcore": "^10.1 || ^11.0", - "lorenzo/pinky": "^1.0.9", - "pelago/emogrifier": "^4.0 | ^5.0 | ^6.0 | ^7.0" + "pimcore/pimcore": "^11.0", + "twig/inky-extra": "^3.0", + "pelago/emogrifier": "^7.0" }, "require-dev": { - "codeception/codeception": "^4.1", - "codeception/module-symfony": "^1.6", + "codeception/codeception": "^5.0", + "codeception/module-symfony": "^3.1", "phpstan/phpstan": "^1.0", "phpstan/phpstan-symfony": "^1.0", "symplify/easy-coding-standard": "^9.0" diff --git a/docs/10_FormBuilder.md b/docs/10_FormBuilder.md index 0a86e21..cb4690c 100644 --- a/docs/10_FormBuilder.md +++ b/docs/10_FormBuilder.md @@ -24,7 +24,7 @@ Get FormBuilder [here](https://github.com/dachcom-digital/pimcore-formbuilder). {% endblock %} -{% emailizr_inky %} +{% apply inky_to_html %} {% if editmode %} @@ -63,7 +63,7 @@ Get FormBuilder [here](https://github.com/dachcom-digital/pimcore-formbuilder). {% endif %} -{% end_emailizr_inky %} +{% endapply %} {% end_emailizr_inline_style %} {% endapply %} @@ -79,7 +79,7 @@ Get FormBuilder [here](https://github.com/dachcom-digital/pimcore-formbuilder). {% emailizr_inline_style %} - {% emailizr_inky %} + {% apply inky_to_html %} @@ -105,7 +105,7 @@ Get FormBuilder [here](https://github.com/dachcom-digital/pimcore-formbuilder). {% endfor %} - {% end_emailizr_inky %} + {% endapply %} {% end_emailizr_inline_style %} diff --git a/src/EmailizrBundle/Collector/CssCollector.php b/src/EmailizrBundle/Collector/CssCollector.php index a03a097..2c0c064 100644 --- a/src/EmailizrBundle/Collector/CssCollector.php +++ b/src/EmailizrBundle/Collector/CssCollector.php @@ -11,7 +11,7 @@ public function add(string $file): void $this->cssFiles[] = $file; } - public function removeAll() + public function removeAll(): void { $this->cssFiles = []; } diff --git a/src/EmailizrBundle/EmailizrBundle.php b/src/EmailizrBundle/EmailizrBundle.php index c15dde1..5e5425e 100644 --- a/src/EmailizrBundle/EmailizrBundle.php +++ b/src/EmailizrBundle/EmailizrBundle.php @@ -4,22 +4,13 @@ use Pimcore\Extension\Bundle\AbstractPimcoreBundle; use Pimcore\Extension\Bundle\Traits\PackageVersionTrait; -use Symfony\Component\DependencyInjection\ContainerBuilder; class EmailizrBundle extends AbstractPimcoreBundle { use PackageVersionTrait; - const PACKAGE_NAME = 'dachcom-digital/emailizr'; + public const PACKAGE_NAME = 'dachcom-digital/emailizr'; - public function build(ContainerBuilder $container) - { - parent::build($container); - } - - /** - * {@inheritdoc} - */ protected function getComposerPackageName(): string { return self::PACKAGE_NAME; diff --git a/src/EmailizrBundle/Parser/InkyParser.php b/src/EmailizrBundle/Parser/InkyParser.php index 871513c..a0c3a6a 100644 --- a/src/EmailizrBundle/Parser/InkyParser.php +++ b/src/EmailizrBundle/Parser/InkyParser.php @@ -7,19 +7,11 @@ class InkyParser { - protected EditmodeResolver $editmodeResolver; - - public function __construct(EditmodeResolver $editmodeResolver) + public function __construct(protected EditmodeResolver $editmodeResolver) { - $this->editmodeResolver = $editmodeResolver; } - /** - * @param string $templateHtml - * - * @return string - */ - public function parseInkyHtml($templateHtml) + public function parseInkyHtml(string $templateHtml): string { if ($this->editmodeResolver->isEditmode() === false) { return Pinky\transformString($templateHtml)->saveHTML(); diff --git a/src/EmailizrBundle/Parser/InlineStyleParser.php b/src/EmailizrBundle/Parser/InlineStyleParser.php index da6a619..76e4e92 100644 --- a/src/EmailizrBundle/Parser/InlineStyleParser.php +++ b/src/EmailizrBundle/Parser/InlineStyleParser.php @@ -8,17 +8,14 @@ class InlineStyleParser { - protected EditmodeResolver $editmodeResolver; - - public function __construct(EditmodeResolver $editmodeResolver) + public function __construct(protected EditmodeResolver $editmodeResolver) { - $this->editmodeResolver = $editmodeResolver; } /** * @throws ParseException */ - public function parseInlineHtml(string $html = '', string $css = '', bool $onlyBodyContent = false): array|string + public function parseInlineHtml(string $html = '', string $css = '', bool $onlyBodyContent = false): string { if ($this->editmodeResolver->isEditmode()) { return $html; @@ -32,11 +29,6 @@ public function parseInlineHtml(string $html = '', string $css = '', bool $onlyB $mergedHtml = $inliner->render(); } - //replace %DataObject(member_id,%7B'method'%20:%20'getResetHash'%7D); placeholder - $mergedHtml = preg_replace_callback('/%DataObject\((.*),(%7B)(.*)(%7D)\);/', static function ($hit) { - return '%DataObject(' . $hit[1] . ',{' . str_replace('%20', '', $hit[3]) . '});'; - }, $mergedHtml); - //replace "{{ }}" placeholder in quotes $mergedHtml = preg_replace_callback('/"(%7B%7B%20)(.*)(%20%7D%7D)"/', static function ($hit) { return '"{{' . $hit[2] . '}}"'; diff --git a/src/EmailizrBundle/Resources/config/services/twig.yml b/src/EmailizrBundle/Resources/config/services/twig.yml index 7249526..a8c438a 100644 --- a/src/EmailizrBundle/Resources/config/services/twig.yml +++ b/src/EmailizrBundle/Resources/config/services/twig.yml @@ -5,10 +5,6 @@ services: autoconfigure: true public: false - EmailizrBundle\Twig\Extension\InkyExtension: - tags: - - { name: twig.extension } - EmailizrBundle\Twig\Extension\InlineStyleExtension: tags: - { name: twig.extension } \ No newline at end of file diff --git a/src/EmailizrBundle/Resources/views/layout.html.twig b/src/EmailizrBundle/Resources/views/layout.html.twig index 83ba1a4..c1fe479 100644 --- a/src/EmailizrBundle/Resources/views/layout.html.twig +++ b/src/EmailizrBundle/Resources/views/layout.html.twig @@ -14,24 +14,22 @@ {% endblock %} - {% emailizr_inky %} + {% apply inky_to_html %} {% block body %} -
- - - -
-
- {% block content %} - {% endblock %} -
-
+ + + + {% block content %} + {% endblock %} + + + -
                                                           
+
                                                           
{% endblock %} - {% end_emailizr_inky %} + {% endapply %} {% end_emailizr_inline_style %} {% endapply %} \ No newline at end of file diff --git a/src/EmailizrBundle/Service/ContentService.php b/src/EmailizrBundle/Service/ContentService.php index 2802f37..d9f7168 100644 --- a/src/EmailizrBundle/Service/ContentService.php +++ b/src/EmailizrBundle/Service/ContentService.php @@ -9,15 +9,12 @@ class ContentService { - protected FileLocator $fileLocator; - protected InkyParser $inkyParser; - protected InlineStyleParser $inlineStyleParser; - - public function __construct(FileLocator $fileLocator, InkyParser $inkyParser, InlineStyleParser $inlineStyleParser) + public function __construct( + protected FileLocator $fileLocator, + protected InkyParser $inkyParser, + protected InlineStyleParser $inlineStyleParser + ) { - $this->fileLocator = $fileLocator; - $this->inkyParser = $inkyParser; - $this->inlineStyleParser = $inlineStyleParser; } /** @@ -30,7 +27,7 @@ public function checkContent(string $html = '', string|array $css = [], bool $pa return $html; } - if ($parseInky == true) { + if ($parseInky === true) { $html = $this->inkyParser->parseInkyHtml($html); } diff --git a/src/EmailizrBundle/Twig/Extension/InkyExtension.php b/src/EmailizrBundle/Twig/Extension/InkyExtension.php deleted file mode 100644 index ef88b3e..0000000 --- a/src/EmailizrBundle/Twig/Extension/InkyExtension.php +++ /dev/null @@ -1,36 +0,0 @@ -inkyParser = $inkyParser; - } - - public function getName(): string - { - return self::NAME; - } - - public function getTokenParsers(): array - { - return [ - new InkyTokenParser() - ]; - } - - public function parse(string $html): string - { - return $this->inkyParser->parseInkyHtml($html); - } -} diff --git a/src/EmailizrBundle/Twig/Extension/InlineStyleExtension.php b/src/EmailizrBundle/Twig/Extension/InlineStyleExtension.php index c0c97f1..a0bfc38 100644 --- a/src/EmailizrBundle/Twig/Extension/InlineStyleExtension.php +++ b/src/EmailizrBundle/Twig/Extension/InlineStyleExtension.php @@ -12,7 +12,7 @@ class InlineStyleExtension extends AbstractExtension implements GlobalsInterface { - const NAME = 'emailizr.inline_style'; + public const NAME = 'emailizr.inline_style'; protected InlineStyleParser $inlineStyleParser; protected FileLocator $fileLocator; diff --git a/src/EmailizrBundle/Twig/Node/InkyNode.php b/src/EmailizrBundle/Twig/Node/InkyNode.php deleted file mode 100644 index 52da28a..0000000 --- a/src/EmailizrBundle/Twig/Node/InkyNode.php +++ /dev/null @@ -1,24 +0,0 @@ - $body], [], $lineno, $tag); - } - - public function compile(Compiler $compiler): void - { - $compiler - ->addDebugInfo($this) - ->write('ob_start();' . PHP_EOL) - ->subcompile($this->getNode('body')) - ->write('$inkyHtml = ob_get_clean();' . PHP_EOL) - ->write('echo $this->env->getExtension(\'EmailizrBundle\Twig\Extension\InkyExtension\')->parse($inkyHtml);' . PHP_EOL); - } -} diff --git a/src/EmailizrBundle/Twig/Parser/InkyTokenParser.php b/src/EmailizrBundle/Twig/Parser/InkyTokenParser.php deleted file mode 100644 index c7b7edf..0000000 --- a/src/EmailizrBundle/Twig/Parser/InkyTokenParser.php +++ /dev/null @@ -1,36 +0,0 @@ -getLine(); - $this->parser->getStream()->expect(Token::BLOCK_END_TYPE); - $body = $this->parser->subparse([$this, 'decideInkyEnd'], true); - $this->parser->getStream()->expect(Token::BLOCK_END_TYPE); - - return new InkyNode($body, $lineno, $this->getTag()); - } - - public function getTag(): string - { - return self::TAG; - } - - public function decideInkyEnd(Token $token): bool - { - return $token->test('end_' . self::TAG); - } -} diff --git a/src/EmailizrBundle/Twig/Parser/InlineStyleTokenParser.php b/src/EmailizrBundle/Twig/Parser/InlineStyleTokenParser.php index 795263d..9133443 100644 --- a/src/EmailizrBundle/Twig/Parser/InlineStyleTokenParser.php +++ b/src/EmailizrBundle/Twig/Parser/InlineStyleTokenParser.php @@ -9,7 +9,7 @@ class InlineStyleTokenParser extends AbstractTokenParser { - const TAG = 'emailizr_inline_style'; + public const TAG = 'emailizr_inline_style'; /** * @throws SyntaxError @@ -30,13 +30,8 @@ public function getTag(): string return self::TAG; } - /** - * @param Token $token - * - * @return bool - */ public function decideEnd(Token $token): bool { - return $token->test('end_' . self::TAG); + return $token->test(sprintf('end_%s', self::TAG)); } } diff --git a/tests/Support/FunctionalTester.php b/tests/Support/FunctionalTester.php new file mode 100644 index 0000000..60e1f15 --- /dev/null +++ b/tests/Support/FunctionalTester.php @@ -0,0 +1,7 @@ +add('test.css'); $this->assertCount(1, $collector->getIterator()); } - public function testMultiple() + public function testMultiple(): void { $collector = new \EmailizrBundle\Collector\CssCollector(); $collector->add('test.css'); @@ -22,7 +22,7 @@ public function testMultiple() $this->assertCount(2, $collector->getIterator()); } - public function testRemove() + public function testRemove(): void { $collector = new \EmailizrBundle\Collector\CssCollector(); $collector->add('test.css'); diff --git a/tests/unit/InkyParserTest.php b/tests/Unit/InkyParserTest.php similarity index 91% rename from tests/unit/InkyParserTest.php rename to tests/Unit/InkyParserTest.php index 656a9d1..0d9a247 100644 --- a/tests/unit/InkyParserTest.php +++ b/tests/Unit/InkyParserTest.php @@ -1,17 +1,14 @@ inkyParser = new InkyParser($editmodeResolver); } - public function testParseInkyHtmlSimple() + public function testParseInkyHtmlSimple(): void { $content = $this->getSimpleStructure(); $parsedHtml = $this->inkyParser->parseInkyHtml($content); @@ -42,7 +39,7 @@ public function testParseInkyHtmlSimple() } - public function testParseInkyHtmlComplex() + public function testParseInkyHtmlComplex(): void { $content = $this->getExtendedStructure(); $parsedHtml = $this->inkyParser->parseInkyHtml($content); @@ -58,7 +55,7 @@ public function testParseInkyHtmlComplex() $this->assertEqualXMLStructureByCodeception($expectedDom->getElementsByTagName('html')->item(0), $actualDom->getElementsByTagName('html')->item(0)); } - private function getSimpleStructure() + private function getSimpleStructure(): string { return ' @@ -75,7 +72,7 @@ private function getSimpleStructure() '; } - private function getExtendedStructure() + private function getExtendedStructure(): string { return ' diff --git a/tests/unit/InlineStyleParserTest.php b/tests/Unit/InlineStyleParserTest.php similarity index 83% rename from tests/unit/InlineStyleParserTest.php rename to tests/Unit/InlineStyleParserTest.php index b0bbc42..33df627 100644 --- a/tests/unit/InlineStyleParserTest.php +++ b/tests/Unit/InlineStyleParserTest.php @@ -1,17 +1,14 @@ inlineStyleParser = new InlineStyleParser($editmodeResolver); } - public function testParseInlineHtml() + public function testParseInlineHtml(): void { $content = $this->getStructure(); $parsedHtml = $this->inlineStyleParser->parseInlineHtml($content, '.test { width: 100%; }', false); @@ -41,13 +38,13 @@ public function testParseInlineHtml() $this->assertEqualXMLStructureByCodeception($expectedDom->getElementsByTagName('html')->item(0), $actualDom->getElementsByTagName('html')->item(0)); } - public function testParseInlineHtmlWithBodyContentOnly() + public function testParseInlineHtmlWithBodyContentOnly(): void { $content = $this->getStructure(); $parsedHtml = $this->inlineStyleParser->parseInlineHtml($content, '.test { width: 100%; }', true); $expectedDom = new \DomDocument(); - $expectedDom->loadHTML('
%DataObject(667, {"method" : "getName"});
'); + $expectedDom->loadHTML('
{{ object.myProperty }}
'); $expectedDom->preserveWhiteSpace = false; $actualDom = new \DomDocument(); @@ -57,7 +54,7 @@ public function testParseInlineHtmlWithBodyContentOnly() $this->assertEqualXMLStructureByCodeception($expectedDom->getElementsByTagName('html')->item(0), $actualDom->getElementsByTagName('html')->item(0)); } - private function getStructure() + private function getStructure(): string { return ' @@ -69,7 +66,7 @@ private function getStructure() - %DataObject(667, {"method" : "getName"}); + {{ object.myProperty }} diff --git a/tests/Unit/TwigInkyExtensionTest.php b/tests/Unit/TwigInkyExtensionTest.php new file mode 100644 index 0000000..deb7bbb --- /dev/null +++ b/tests/Unit/TwigInkyExtensionTest.php @@ -0,0 +1,30 @@ +getMockBuilder(EditmodeResolver::class)->disableOriginalConstructor()->getMock(); + + $editmodeResolver + ->method('isEditmode') + ->willReturn(false); + + $this->inkyParser = new InkyParser($editmodeResolver); + } + + public function testParse(): void + { + $renderedString = 'rendered string'; + + $this->assertEquals(sprintf("

%s

\n", $renderedString), $this->inkyParser->parseInkyHtml('rendered string')); + } +} diff --git a/tests/unit/TwigInlineStyleExtensionTest.php b/tests/Unit/TwigInlineStyleExtensionTest.php similarity index 73% rename from tests/unit/TwigInlineStyleExtensionTest.php rename to tests/Unit/TwigInlineStyleExtensionTest.php index dd19c48..3129191 100644 --- a/tests/unit/TwigInlineStyleExtensionTest.php +++ b/tests/Unit/TwigInlineStyleExtensionTest.php @@ -1,10 +1,9 @@ method('isEditmode') ->willReturn(false); - $inlineStyleParser = new InlineStyleParser($editmodeResolver); - - $this->extension = new InlineStyleExtension($inlineStyleParser, $fileLocator); + $this->extension = new InlineStyleExtension( + new InlineStyleParser($editmodeResolver), + $fileLocator + ); } - public function testGetTokenParsers() + public function testGetTokenParsers(): void { $this->assertIsArray( $this->extension->getTokenParsers()); $this->assertInstanceOf(InlineStyleTokenParser::class, $this->extension->getTokenParsers()[0]); } - public function testGetFunctions() + public function testGetFunctions(): void { $this->assertEquals( [ @@ -50,5 +47,4 @@ public function testGetFunctions() $this->extension->getFunctions() ); } - } diff --git a/tests/unit/_bootstrap.php b/tests/Unit/_bootstrap.php similarity index 100% rename from tests/unit/_bootstrap.php rename to tests/Unit/_bootstrap.php diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index f4138ac..b0c6a29 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -1,8 +1,3 @@ - %DataObject(667, {"method" : "getName"}); + {{ object.myProperty }} diff --git a/tests/_support/FunctionalTester.php b/tests/_support/FunctionalTester.php deleted file mode 100644 index 6d89997..0000000 --- a/tests/_support/FunctionalTester.php +++ /dev/null @@ -1,8 +0,0 @@ -getMockBuilder(EditmodeResolver::class)->disableOriginalConstructor()->getMock(); - - $editmodeResolver - ->method('isEditmode') - ->willReturn(false); - - $inkyParser = new InkyParser($editmodeResolver); - - $this->extension = new InkyExtension($inkyParser); - } - - public function testGetTokenParsers() - { - $this->assertIsArray($this->extension->getTokenParsers()); - $this->assertInstanceOf(InkyTokenParser::class, $this->extension->getTokenParsers()[0]); - } - - public function testParse() - { - $renderedString = 'rendered string'; - - $this->assertEquals(sprintf("

%s

\n", $renderedString), $this->extension->parse('rendered string')); - } -} From efa8e8ad2d722c4e87cdce205c56315f73519225 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Fri, 7 Jul 2023 18:23:54 +0200 Subject: [PATCH 2/3] adjust test matrix --- .github/workflows/codeception.yml | 12 ++++++------ .github/workflows/ecs.yml | 12 ++++++------ .github/workflows/php-stan.yml | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/codeception.yml b/.github/workflows/codeception.yml index 936fe00..87de40a 100644 --- a/.github/workflows/codeception.yml +++ b/.github/workflows/codeception.yml @@ -15,7 +15,7 @@ jobs: TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}" PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework" - PIMCORE_CODECEPTION_VERSION: "2.0" + PIMCORE_CODECEPTION_VERSION: "3.0" APP_ENV: test PIMCORE_TEST_DB_DSN: "mysql://test:test@127.0.0.1:3306/dachcom_bundle_test" @@ -38,12 +38,12 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: matrix: - php: [ 8.1 ] - symfony: [ ^5.4 ] - pimcore: [ ~10.6.0 ] + php: [ 8.2 ] + symfony: [ ^6.2 ] + pimcore: [ ~11.0.0 ] include: - - pimcore: ~10.6.0 - template_tag: v10.2.5 + - pimcore: ~11.0.0 + template_tag: v11.0.0 steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/ecs.yml b/.github/workflows/ecs.yml index 3419cb7..30e65db 100644 --- a/.github/workflows/ecs.yml +++ b/.github/workflows/ecs.yml @@ -15,7 +15,7 @@ jobs: TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}" PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework" - PIMCORE_CODECEPTION_VERSION: "2.0" + PIMCORE_CODECEPTION_VERSION: "3.0" APP_ENV: test PIMCORE_TEST_DB_DSN: "mysql://root:root@127.0.0.1:3306/dachcom_bundle_test" @@ -37,12 +37,12 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: matrix: - php: [ 8.1 ] - symfony: [ ^5.4 ] - pimcore: [ ~10.6.0 ] + php: [ 8.2 ] + symfony: [ ^6.2 ] + pimcore: [ ~11.0.0 ] include: - - pimcore: ~10.6.0 - template_tag: v10.2.5 + - pimcore: ~11.0.0 + template_tag: v11.0.0 steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/php-stan.yml b/.github/workflows/php-stan.yml index c0d364c..90e5742 100644 --- a/.github/workflows/php-stan.yml +++ b/.github/workflows/php-stan.yml @@ -15,7 +15,7 @@ jobs: TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}" PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework" - PIMCORE_CODECEPTION_VERSION: "2.0" + PIMCORE_CODECEPTION_VERSION: "3.0" APP_ENV: test PIMCORE_TEST_DB_DSN: "mysql://root:root@127.0.0.1:3306/dachcom_bundle_test" @@ -37,12 +37,12 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: matrix: - php: [ 8.1 ] - symfony: [ ^5.4 ] - pimcore: [ ~10.6.0 ] + php: [ 8.2 ] + symfony: [ ^6.2 ] + pimcore: [ ~11.0.0 ] include: - - pimcore: ~10.6.0 - template_tag: v10.2.5 + - pimcore: ~11.0.0 + template_tag: v11.0.0 steps: - uses: actions/checkout@v2 with: From 2e3a979515bef567b102fd95ce9be209247eede9 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Wed, 30 Aug 2023 20:13:09 +0200 Subject: [PATCH 3/3] move to new bundle structure --- ISSUE_TEMPLATE.md | 12 ++++++------ LICENSE.md | 2 +- PULL_REQUEST_TEMPLATE.md | 14 +++++++------- README.md | 11 +++++++++-- UPGRADE.md | 1 + composer.json | 2 +- config/services.yaml | 2 ++ .../parser.yml => config/services/parser.yaml | 0 .../service.yml => config/services/service.yaml | 0 .../services/twig.yml => config/services/twig.yaml | 0 docs/10_FormBuilder.md | 4 ++-- .../css/foundation-for-emails/foundation.css | 0 .../css/foundation-for-emails/foundation.min.css | 0 .../Collector/CssCollector.php | 0 .../DependencyInjection/EmailizrExtension.php | 4 ++-- src/{EmailizrBundle => }/EmailizrBundle.php | 5 +++++ src/EmailizrBundle/Resources/config/services.yml | 2 -- src/{EmailizrBundle => }/Parser/InkyParser.php | 0 .../Parser/InlineStyleParser.php | 0 .../Service/ContentService.php | 0 .../Twig/Extension/InlineStyleExtension.php | 0 .../Twig/Node/InlineStyleNode.php | 0 .../Twig/Parser/InlineStyleTokenParser.php | 0 .../Resources/views => templates}/layout.html.twig | 2 +- tests/_etc/config/app/system_settings.yaml | 5 ----- 25 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 config/services.yaml rename src/EmailizrBundle/Resources/config/services/parser.yml => config/services/parser.yaml (100%) rename src/EmailizrBundle/Resources/config/services/service.yml => config/services/service.yaml (100%) rename src/EmailizrBundle/Resources/config/services/twig.yml => config/services/twig.yaml (100%) rename {src/EmailizrBundle/Resources/public => public}/css/foundation-for-emails/foundation.css (100%) rename {src/EmailizrBundle/Resources/public => public}/css/foundation-for-emails/foundation.min.css (100%) rename src/{EmailizrBundle => }/Collector/CssCollector.php (100%) rename src/{EmailizrBundle => }/DependencyInjection/EmailizrExtension.php (86%) rename src/{EmailizrBundle => }/EmailizrBundle.php (82%) delete mode 100644 src/EmailizrBundle/Resources/config/services.yml rename src/{EmailizrBundle => }/Parser/InkyParser.php (100%) rename src/{EmailizrBundle => }/Parser/InlineStyleParser.php (100%) rename src/{EmailizrBundle => }/Service/ContentService.php (100%) rename src/{EmailizrBundle => }/Twig/Extension/InlineStyleExtension.php (100%) rename src/{EmailizrBundle => }/Twig/Node/InlineStyleNode.php (100%) rename src/{EmailizrBundle => }/Twig/Parser/InlineStyleTokenParser.php (100%) rename {src/EmailizrBundle/Resources/views => templates}/layout.html.twig (92%) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 5c9e622..3f51a10 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,9 +1,9 @@ -| Q | A -| ---------------- | ----- -| Bug report? | yes/no -| Feature request? | yes/no -| BC Break report? | yes/no -| RFC? | yes/no +| Q | A | +|------------------|--------| +| Bug report? | yes/no | +| Feature request? | yes/no | +| BC Break report? | yes/no | +| RFC? | yes/no | +| Q | A | +|---------------|----------------------------------------------------| +| Bug fix? | yes/no | +| New feature? | yes/no | +| BC breaks? | no | +| Deprecations? | yes/no | +| Fixed tickets | #... |