diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index f098d76..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Build extension -on: - push: - branches: - - '1.x' - -jobs: - build: - uses: FriendsOfShopware/actions/.github/workflows/store-shopware-cli.yml@main - with: - extensionName: ${{ github.event.repository.name }} - secrets: - accountUser: ${{ secrets.ACCOUNT_USER }} - accountPassword: ${{ secrets.ACCOUNT_PASSWORD }} - ghToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml deleted file mode 100644 index 70fa771..0000000 --- a/.github/workflows/unit.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: PHPUnit -on: - push: - branches: - - '1.x' - tags-ignore: - - '*' - pull_request: - -env: - PLUGIN_NAME: FroshPlatformTemplateMail - -jobs: - phpunit: - name: Run tests - container: ghcr.io/friendsofshopware/platform-plugin-dev:v6.4.17 - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - path: ${{ env.PLUGIN_NAME }} - - - name: Run Tests - run: | - cp -r "./${PLUGIN_NAME}" "/plugins/${PLUGIN_NAME}" - shopware-cli extension prepare "/plugins/${PLUGIN_NAME}" - start-mysql - export PROJECT_ROOT=/opt/shopware - /opt/shopware/bin/console plugin:refresh - /opt/shopware/bin/console plugin:install --activate -c ${PLUGIN_NAME} - cd /opt/shopware/custom/plugins/${PLUGIN_NAME} - php -d pcov.enabled=1 /opt/shopware/vendor/bin/phpunit --coverage-clover clover.xml - - - uses: codecov/codecov-action@v1 - with: - file: ./clover.xml - root_dir: /plugins/FroshPlatformTemplateMail - working-directory: /plugins/FroshPlatformTemplateMail - diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 9ad6d93..0000000 --- a/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -.idea -*.phar -/.phpunit.result.cache -/composer.lock -/vendor -src/Resources/views/ -src/Resources/public/ diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile deleted file mode 100644 index 4b009a6..0000000 --- a/.gitpod.Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM gitpod/workspace-full:latest - -RUN sudo apt-get update && \ - sudo apt-get install -y php8.1-fpm rsync && \ - brew install symfony-cli/tap/symfony-cli FriendsOfShopware/tap/shopware-cli \ No newline at end of file diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index 16e53b4..0000000 --- a/.gitpod.yml +++ /dev/null @@ -1,91 +0,0 @@ -image: - file: .gitpod.Dockerfile - -tasks: - - name: Shopware - before: | - echo 'alias admin-watch="LOAD_DOTENV=0 APP_URL=http://localhost:8000 ./bin/watch-administration.sh"' >> ~/.bashrc - init: | - EXTENSION_NAME=$(basename $PWD) - TMP_DIR=$(mktemp -d) - - mv * .* "$TMP_DIR" || true - - # Run MySQL - docker run --restart always -d --name=mysql -p 127.0.0.1:3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:8 - docker run --restart always -d --name=adminer --link mysql:mysql -p 5000:8080 -e ADMINER_DESIGN=pepa-linha -e ADMINER_DEFAULT_SERVER=mysql -e ADMINER_PLUGINS="tables-filter table-structure json-column version-noverify" ghcr.io/shyim/shopware-docker/adminer - - # Configure Github Token. Needed for Symfony Flex - sudo chown -R gitpod:gitpod /home/gitpod/.config/composer - composer config --global github-oauth.github.com $(printf '%s\n' host=github.com | gp credential-helper get | sort | head -2 | tail -1 | sed 's;password=;;') - - composer create-project shopware/production:dev-flex . -n - composer req --dev profiler fakerphp/faker mbezhanov/faker-provider-collection maltyxx/images-generator - - # PHP Settings - echo "memory_limit=512M" > php.ini - echo "assert.active=0" >> php.ini - echo "opcache.interned_strings_buffer=20" >> php.ini - echo "zend.detect_unicode=0" >> php.ini - echo "realpath_cache_ttl=3600" >> php.ini - # Configure Shopware - sed -i -e 's;DATABASE_URL=.*$;DATABASE_URL=mysql://root:root@127.0.0.1:3306/shopware;' .env - sed -i -e "s;APP_URL=.*$;APP_URL=$(gp url 8000);" .env - echo "TRUSTED_PROXIES=192.168.0.0/16" >> .env - - ./bin/console system:install --basic-setup --create-database --drop-database - - ./bin/console framework:demodata --products 300 - ./bin/console dal:refresh:index - rm -rf var/cache/* - # Set by default to dev - sed -i -e "s;APP_ENV=.*$;APP_URL=dev;" .env - - # Move actual repository - mv "$TMP_DIR" "custom/plugins/$EXTENSION_NAME" - command: docker ps && sleep 2 && ./bin/console sales-channel:update:domain $(gp url 8000 | awk -F[/:] '{print $4}') && symfony server:start --port 8000 -d - -ports: - - port: 8000 - visibility: private - description: Shopware - onOpen: open-browser - - port: 5000 - visibility: private - description: Adminer - onOpen: notify - - name: Admin-Watcher - port: 8080 - onOpen: notify - description: "Use Forward Proxy to localhost to access this service" - -jetbrains: - plugins: - - com.jetbrains.php - - com.intellij.php.tools.quality.phpstan - - com.intellij.php.psalm - - org.jetbrains.plugins.yaml - - com.jetbrains.twig - - de.espend.idea.php.annotation - - fr.adrienbrault.idea.symfony2plugin - - de.shyim.shopware6 - - de.shyim.ideaphpstantoolbox - phpstorm: - vmoptions: "-Xmx4g" - prebuilds: - version: stable - -vscode: - extensions: - - bmewburn.vscode-intelephense-client - - redhat.vscode-yaml - -github: - prebuilds: - master: true - branches: true - pullRequests: true - pullRequestsFromForks: true - addCheck: false - addComment: false - addBadge: true diff --git a/.shopware-extension.yml b/.shopware-extension.yml deleted file mode 100644 index 2c25dc9..0000000 --- a/.shopware-extension.yml +++ /dev/null @@ -1,14 +0,0 @@ -build: - zip: - composer: - enabled: true - assets: - enabled: true - enable_es_build_for_admin: true - enable_es_build_for_storefront: true - pack: - excludes: - paths: - - .idea - - var - - .gitignore diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..22c82dc --- /dev/null +++ b/composer.lock @@ -0,0 +1,72 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "bebb4f5075dc028c60e31563328c59cf", + "packages": [ + { + "name": "lorenzo/pinky", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/lorenzo/pinky.git", + "reference": "e1b1bdb2c132b8a7ba32bca64d2443f646ddbd17" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/lorenzo/pinky/zipball/e1b1bdb2c132b8a7ba32bca64d2443f646ddbd17", + "reference": "e1b1bdb2c132b8a7ba32bca64d2443f646ddbd17", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xsl": "*", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.21 || ^9.5.10" + }, + "type": "library", + "autoload": { + "files": [ + "src/pinky.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jose Lorenzo Rodriguez", + "email": "jose.zap@gmail.com" + } + ], + "description": "A Foundation for Emails (Inky) template transpiler", + "keywords": [ + "email", + "foundation", + "inky", + "template", + "zurb" + ], + "support": { + "issues": "https://github.com/lorenzo/pinky/issues", + "source": "https://github.com/lorenzo/pinky/tree/1.1.0" + }, + "time": "2023-07-31T13:36:50+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/src/Resources/public/administration/css/frosh-platform-template-mail.css b/src/Resources/public/administration/css/frosh-platform-template-mail.css new file mode 100644 index 0000000..1b3fcb0 --- /dev/null +++ b/src/Resources/public/administration/css/frosh-platform-template-mail.css @@ -0,0 +1 @@ +.sw-mail-template-detail__options-info-wrapper .sw-field,.sw-mail-template-detail .sw-code-editor{margin-bottom:5px}.sw-mail-template-detail .sw-code-editor+.sw-label{margin-bottom:32px} diff --git a/src/Resources/public/administration/js/frosh-platform-template-mail.js b/src/Resources/public/administration/js/frosh-platform-template-mail.js new file mode 100644 index 0000000..75f597d --- /dev/null +++ b/src/Resources/public/administration/js/frosh-platform-template-mail.js @@ -0,0 +1,127 @@ +(()=>{var l=`{% block sw_mail_template_list_grid %} + + + + + + +{% endblock %} +`;Shopware.Component.override("sw-mail-template-list",{template:l,methods:{getListColumns(){let e=this.$super("getListColumns");return e.unshift({property:"froshTemplateMail",label:"sw-mail-template.list.columnTemplateMail",allowResize:!0},{property:"technicalName",label:"sw-mail-template.list.columnTechnicalName",allowResize:!0,visible:!1}),e},getFroshTooltip(e,t){return{message:t?this.$t(`sw-mail-template.frosh.${e}`,{folder:t}):this.$t("sw-mail-template.frosh.noTemplate")}}}});var a=`{% block sw_mail_template_options_form_subject_field %} + {% parent %} + + + +{% endblock %} + +{% block sw_mail_template_mail_text_form_content_plain_field %} + {% parent %} + + + +{% endblock %} + +{% block sw_mail_template_mail_text_form_content_html_field %} + {% parent %} + + + +{% endblock %} +`;Shopware.Component.override("sw-mail-template-detail",{template:a,methods:{getFroshTooltip(e,t){return{message:t?this.$t(`sw-mail-template.frosh.${e}`,{folder:t}):this.$t("sw-mail-template.frosh.noTemplate")}}}});})(); diff --git a/src/Resources/store/de.md b/src/Resources/store/de.md deleted file mode 100644 index daf8f9b..0000000 --- a/src/Resources/store/de.md +++ /dev/null @@ -1,20 +0,0 @@ -Mit Template Mail kannst du deine Mail-Templates aus der Administration in dein Theme auslagern. -Somit sind deine Mail-Templates versioniert, können voneinander erben und du profitierst von all den anderen tollen Dingen, die man in Twig machen kann. -Dieses Plugin stellt außerdem einen Loader bereit, der dafür sorgt, dass andere Plugins weitere Dateitypen hinzufügen können. Im Plugin selbst werden aktuell Twig, [MJML](https://mjml.io/) und [Inky](https://foundation.zurb.com/emails/docs/inky.html) unterstützt. - - -## Wie benutze ich das Plugin? -Durch die Installation ändert sich erst mal nichts für dich. Du kannst anfangen die ersten Templates in dein Theme auszulagern. - -### Beispiel Pfade für Twig, Zahlungsbestätigung (*order_transaction.state.paid*): -Ordner: custom/plugins/*MyTheme*/Resources/views/email/global/ - -- HTML-Inhalt der Zahlungsbestätigung: *order_transaction.state.paid*/html.twig -- PlainText-Inhalt der Zahlungsbestätigung: *order_transaction.state.paid*/plain.twig -- Betreff der Zahlungsbestätigung: *order_transaction.state.paid*/subject.twig - - -Das Plugin wird von der Github Organization [FriendsOfShopware](https://github.com/FriendsOfShopware/) entwickelt. -Maintainer des Plugin ist [Soner Sayakci](https://github.com/shyim). -Das Github Repository ist zu finden [hier](https://github.com/FriendsOfShopware/FroshPlatformTemplateMail) -[Bei Fragen / Fehlern bitte ein Github Issue erstellen](https://github.com/FriendsOfShopware/FroshPlatformTemplateMail/issues/new) diff --git a/src/Resources/store/en.md b/src/Resources/store/en.md deleted file mode 100644 index 2dc5b2e..0000000 --- a/src/Resources/store/en.md +++ /dev/null @@ -1,19 +0,0 @@ -With Template Mail you can outsource your mail templates in the administration to your theme. -So your mail templates are versioned, can inherit from each other and all the other great things you can do in Twig. -The plugin also supports loaders. So other plugins can add file extensions where they can create the mail. -The plugin itself supports Twig and MJML by default. - -## How do I use the plugin? - -After installation nothing changes for you. You can now start to swap the first templates into your theme. - -Example paths: - -* custom/plugins/MyTheme/Resources/views/email/global/order_transaction.state.paid/html.twig - content of the sOrder in HTML form -* custom/plugins/MyTheme/Resources/views/email/global/order_transaction.state.paid/plain.twig - content of the sOrder in text form -* custom/plugins/MyTheme/Resources/views/email/global/order_transaction.state.paid/subject.twig - title of the sOrder Mailion) - -The plugin is provided by the Github Organization [FriendsOfShopware](https://github.com/FriendsOfShopware/). -Maintainer of the plugin is [Soner Sayakci](https://github.com/shyim). -You can find the Github Repository [here](https://github.com/FriendsOfShopware/FroshPlatformTemplateMail) -[For questions / errors please create a Github Issue](https://github.com/FriendsOfShopware/FroshPlatformTemplateMail/issues/new) diff --git a/src/Resources/store/icon.png b/src/Resources/store/icon.png deleted file mode 100644 index 885856b..0000000 Binary files a/src/Resources/store/icon.png and /dev/null differ diff --git a/src/Resources/store/images/1.png b/src/Resources/store/images/1.png deleted file mode 100644 index b8591de..0000000 Binary files a/src/Resources/store/images/1.png and /dev/null differ diff --git a/tests/Command/ExportCommandTest.php b/tests/Command/ExportCommandTest.php deleted file mode 100644 index d0583b1..0000000 --- a/tests/Command/ExportCommandTest.php +++ /dev/null @@ -1,45 +0,0 @@ -createMock(Connection::class); - $connection->method('fetchAllAssociative')->willReturn([ - [ - 'content_plain' => 'My content', - 'content_html' => '

My content

', - 'subject' => 'Test template', - 'technical_name' => 'test_template', - 'locale' => 'en', - ], - ]); - - $command = new ExportCommand($connection); - - $tester = new CommandTester($command); - $tester->execute(['directory' => sys_get_temp_dir()]); - - $htmlFile = sys_get_temp_dir() . '/en/test_template/html.twig'; - $plainFile = sys_get_temp_dir() . '/en/test_template/plain.twig'; - $subjectFile = sys_get_temp_dir() . '/en/test_template/subject.twig'; - - static::assertFileExists($htmlFile); - static::assertFileExists($plainFile); - static::assertFileExists($subjectFile); - - static::assertEquals('

My content

', file_get_contents($htmlFile)); - static::assertEquals('My content', file_get_contents($plainFile)); - static::assertEquals('Test template', file_get_contents($subjectFile)); - - static::assertSame(0, $tester->getStatusCode()); - static::assertStringContainsString('Files has been exported', $tester->getDisplay()); - } -} diff --git a/tests/DependencyInjection/CacheCompilerPassTest.php b/tests/DependencyInjection/CacheCompilerPassTest.php deleted file mode 100644 index da99edd..0000000 --- a/tests/DependencyInjection/CacheCompilerPassTest.php +++ /dev/null @@ -1,42 +0,0 @@ -buildContainer(); - $c->setParameter('kernel.environment', 'dev'); - $c->compile(); - - static::assertFalse($c->hasDefinition(CachedMailFinderService::class)); - } - - public function testCacheStaysInProd(): void - { - $c = $this->buildContainer(); - $c->compile(); - - static::assertTrue($c->hasDefinition(CachedMailFinderService::class)); - } - - private function buildContainer(): ContainerBuilder - { - $container = new ContainerBuilder(); - $container->addCompilerPass(new CacheCompilerPass()); - $d = new Definition(); - $d->setPublic(true); - $container->setDefinition(CachedMailFinderService::class, $d); - $container->setParameter('kernel.environment', 'prod'); - - return $container; - } -} diff --git a/tests/Extension/MailTemplateExtensionTest.php b/tests/Extension/MailTemplateExtensionTest.php deleted file mode 100644 index 9138364..0000000 --- a/tests/Extension/MailTemplateExtensionTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getMockBuilder(FieldCollection::class) - ->disableOriginalConstructor() - ->onlyMethods(['add']) - ->getMock(); - - $collection - ->expects(static::once()) - ->method('add') - ->withConsecutive( - [ - (new StringField('frosh_template_mail', 'froshTemplateMail'))->addFlags(new Runtime()), - ] - ); - - (new MailTemplateExtension())->extendFields($collection); - } - - public function testGetDefinitionClassReturnsMailTemplateDefinitionClass(): void - { - static::assertSame( - MailTemplateDefinition::class, - (new MailTemplateExtension())->getDefinitionClass() - ); - } -} diff --git a/tests/Integration/OrderTest.php b/tests/Integration/OrderTest.php deleted file mode 100644 index 671414e..0000000 --- a/tests/Integration/OrderTest.php +++ /dev/null @@ -1,192 +0,0 @@ -orderService = $this->getContainer()->get(OrderService::class); - - $this->orderRepository = $this->getContainer()->get('order.repository'); - - $this->addCountriesToSalesChannel(); - - $contextFactory = $this->getContainer()->get(SalesChannelContextFactory::class); - $this->salesChannelContext = $contextFactory->create( - '', - Defaults::SALES_CHANNEL, - [SalesChannelContextService::CUSTOMER_ID => $this->createCustomer('Jon', 'Doe')] - ); - } - - public function testOrderConfirmationMail(): void - { - $eventDispatcher = $this->getContainer()->get('event_dispatcher'); - $mailSentEvent = null; - - $eventDispatcher->addListener(MailSentEvent::class, function (MailSentEvent $e) use(&$mailSentEvent) { - $mailSentEvent = $e; - }); - - $this->performOrder(); - - static::assertNotNull($mailSentEvent, 'Mail did not sent'); - - static::assertSame( - [ - 'text/html' => 'HTML CONFIRM', - 'text/plain' => "TEXT CONFIRM" - ], - $mailSentEvent->getContents() - ); - static::assertSame('SUBJECT CONFIRM', $mailSentEvent->getSubject()); - } - - private function fillCart(string $contextToken): void - { - $cart = $this->getContainer()->get(CartService::class)->createNew($contextToken); - - $productId = $this->createProduct(); - $cart->add(new LineItem('lineItem1', LineItem::PRODUCT_LINE_ITEM_TYPE, $productId)); - $cart->setTransactions($this->createTransaction()); - } - - private function createProduct(): string - { - $productId = Uuid::randomHex(); - - $product = [ - 'id' => $productId, - 'name' => 'Test product', - 'productNumber' => '123456789', - 'stock' => 1, - 'price' => [ - ['currencyId' => Defaults::CURRENCY, 'gross' => 19.99, 'net' => 10, 'linked' => false], - ], - 'manufacturer' => ['id' => $productId, 'name' => 'shopware AG'], - 'tax' => ['id' => $this->getValidTaxId(), 'name' => 'testTaxRate', 'taxRate' => 15], - 'categories' => [ - ['id' => $productId, 'name' => 'Test category'], - ], - 'visibilities' => [ - [ - 'id' => $productId, - 'salesChannelId' => Defaults::SALES_CHANNEL, - 'visibility' => ProductVisibilityDefinition::VISIBILITY_ALL, - ], - ], - ]; - - $this->getContainer()->get('product.repository')->create([$product], Context::createDefaultContext()); - - return $productId; - } - - private function createTransaction(): TransactionCollection - { - return new TransactionCollection([ - new Transaction( - new CalculatedPrice( - 13.37, - 13.37, - new CalculatedTaxCollection(), - new TaxRuleCollection() - ), - $this->getValidPaymentMethodId() - ), - ]); - } - - private function performOrder(): string - { - $data = new RequestDataBag(['tos' => true]); - $this->fillCart($this->salesChannelContext->getToken()); - - return $this->orderService->createOrder($data, $this->salesChannelContext); - } - - private function createCustomer(string $firstName, string $lastName, array $options = []): string - { - $customerId = Uuid::randomHex(); - $salutationId = $this->getValidSalutationId(); - $paymentMethodId = $this->getValidPaymentMethodId(); - - $customer = [ - 'id' => $customerId, - 'salesChannelId' => Defaults::SALES_CHANNEL, - 'defaultShippingAddress' => [ - 'id' => $customerId, - 'firstName' => $firstName, - 'lastName' => $lastName, - 'city' => 'Schöppingen', - 'street' => 'Ebbinghoff 10', - 'zipcode' => '48624', - 'salutationId' => $salutationId, - 'countryId' => $this->getValidCountryId(), - ], - 'defaultBillingAddressId' => $customerId, - 'defaultPaymentMethodId' => $paymentMethodId, - 'groupId' => Defaults::FALLBACK_CUSTOMER_GROUP, - 'email' => Uuid::randomHex() . '@example.com', - 'password' => 'not', - 'firstName' => $firstName, - 'lastName' => $lastName, - 'salutationId' => $salutationId, - 'customerNumber' => '12345', - ]; - - $customer = array_merge_recursive($customer, $options); - - $this->getContainer()->get('customer.repository')->create([$customer], Context::createDefaultContext()); - - return $customerId; - } -} diff --git a/tests/Integration/SetupExampleTemplatesTrait.php b/tests/Integration/SetupExampleTemplatesTrait.php deleted file mode 100644 index 5cd51af..0000000 --- a/tests/Integration/SetupExampleTemplatesTrait.php +++ /dev/null @@ -1,51 +0,0 @@ - 'HTML CONFIRM', - 'global/order_confirmation_mail/plain.twig' => 'TEXT CONFIRM', - 'global/order_confirmation_mail/subject.twig' => 'SUBJECT CONFIRM', - ]; - - /** - * @before - */ - public function setupTemplates(): void - { - $fs = new Filesystem(); - - $resources = $this->getResourcesFolder(); - foreach ($this->tplFiles as $tplFile => $content) { - $file = $resources . '/' . $tplFile; - $folder = dirname($file); - $fs->mkdir($folder); - - $fs->dumpFile($file, $content); - } - } - - /** - * @after - */ - public function removeTemplates(): void - { - $fs = new Filesystem(); - - $resources = $this->getResourcesFolder(); - foreach ($this->tplFiles as $tplFile => $content) { - $file = $resources . '/' . $tplFile; - $fs->remove($file); - } - } - - private function getResourcesFolder(): string - { - return dirname(__DIR__, 2) . '/src/Resources/views/email/'; - } -} diff --git a/tests/Services/MailLoader/CachedMailFinderServiceTest.php b/tests/Services/MailLoader/CachedMailFinderServiceTest.php deleted file mode 100644 index a7f894c..0000000 --- a/tests/Services/MailLoader/CachedMailFinderServiceTest.php +++ /dev/null @@ -1,31 +0,0 @@ -createMock(MailFinderService::class); - $mailFinder->method('findTemplateByTechnicalName')->willReturnCallback(function () { return (string) microtime(true); }); - - $cachedMailFinder = new CachedMailFinderService($mailFinder, new ArrayAdapter()); - $event = $this->createMock(TemplateMailBusinessEvent::class); - $event->method('getName')->willReturn('foo'); - $event->method('getSalesChannelId')->willReturn('foo'); - $event->method('getContext')->willReturn(Context::createDefaultContext()); - $event->method('getConfig')->willReturn([]); - - - $time = $cachedMailFinder->findTemplateByTechnicalName('', '', $event); - static::assertSame($time, $cachedMailFinder->findTemplateByTechnicalName('', '', $event)); - } -} diff --git a/tests/Services/MailLoader/InkyLoaderTest.php b/tests/Services/MailLoader/InkyLoaderTest.php deleted file mode 100644 index 9792a94..0000000 --- a/tests/Services/MailLoader/InkyLoaderTest.php +++ /dev/null @@ -1,24 +0,0 @@ -supportedExtensions()); - - $text = $loader->load(__DIR__ . '/_fixtures/test.inky'); - static::assertStringContainsString('supportedExtensions()); - - $text = $loader->load(__DIR__ . '/_fixtures/test.mjml'); - static::assertStringContainsString('', $text); - static::assertStringContainsString('', $text); - } - - public function testApiIsNotAvailable(): void - { - $mock = new MockHandler([ - new ServerException('Error Communicating with Server', new Request('GET', 'test'), new Response(500)) - ]); - - $handlerStack = HandlerStack::create($mock); - $client = new Client(['handler' => $handlerStack]); - - $loader = new MjmlLoader(new NullLogger(), $client); - - static::assertSame('', $loader->load(__DIR__ . '/_fixtures/test.mjml')); - } - - public function testApiRespondsErrors(): void - { - $mock = new MockHandler([ - new Response(200, ['Content-Type' => 'application/json'], json_encode(['errors' => ['some error happend']])) - ]); - - $handlerStack = HandlerStack::create($mock); - $client = new Client(['handler' => $handlerStack]); - - $loader = new MjmlLoader(new NullLogger(), $client); - - static::expectException(MjmlCompileError::class); - $loader->load(__DIR__ . '/_fixtures/test.mjml'); - } -} diff --git a/tests/Services/MailLoader/TwigLoaderTest.php b/tests/Services/MailLoader/TwigLoaderTest.php deleted file mode 100644 index bd06253..0000000 --- a/tests/Services/MailLoader/TwigLoaderTest.php +++ /dev/null @@ -1,19 +0,0 @@ -supportedExtensions()); - static::assertNotEmpty($loader->load($storefront->getPath() . '/Resources/views/storefront/base.html.twig')); - } -} diff --git a/tests/Services/MailLoader/_fixtures/test.inky b/tests/Services/MailLoader/_fixtures/test.inky deleted file mode 100644 index e514481..0000000 --- a/tests/Services/MailLoader/_fixtures/test.inky +++ /dev/null @@ -1,5 +0,0 @@ - - - Put content in me! - - diff --git a/tests/Services/MailLoader/_fixtures/test.mjml b/tests/Services/MailLoader/_fixtures/test.mjml deleted file mode 100644 index 004b668..0000000 --- a/tests/Services/MailLoader/_fixtures/test.mjml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - Hello World - - - - diff --git a/tests/Services/SearchPathProviderTest.php b/tests/Services/SearchPathProviderTest.php deleted file mode 100644 index 7dd8ecf..0000000 --- a/tests/Services/SearchPathProviderTest.php +++ /dev/null @@ -1,83 +0,0 @@ -createMock(EntityRepository::class); - - $language = new LanguageEntity(); - $language->setId(Defaults::LANGUAGE_SYSTEM); - $locale = new LocaleEntity(); - $locale->setCode('en-GB'); - $language->setLocale($locale); - $repository->method('search')->willReturn(new EntitySearchResult('language', 1, new EntityCollection([$language]), null, new Criteria(), Context::createDefaultContext())); - - $provider = new SearchPathProvider($repository); - static::assertSame($expectedPaths, $provider->buildPaths($event)); - } - - public function eventProvider(): iterable - { - // Without sales channel source - - yield [ - $this->createEvent(), - [ - '98432def39fc4624b33213a56b8c944d/en-GB', // Sales channel and language combo - '98432def39fc4624b33213a56b8c944d', // Sales channel - 'en-GB', // Language code - '2fbb5fe2e29a4d70aa5854ce7ce3e20b', // Language id - 'global' // Global - ] - ]; - - // With sales channel source - - yield [ - $this->createEvent(true), - [ - '98432def39fc4624b33213a56b8c944d/en-GB', // Sales channel and language combo - '98432def39fc4624b33213a56b8c944d', // Sales channel - 'en-GB', // Language code - '2fbb5fe2e29a4d70aa5854ce7ce3e20b', // Language id - 'global' // Global - ] - ]; - } - - private function createEvent(bool $salesChannelSource = false): BusinessEvent - { - $context = new Context( - $salesChannelSource ? new SalesChannelApiSource(Defaults::SALES_CHANNEL) : new SystemSource() - ); - - $innerEvent = new ContactFormEvent($context, Defaults::SALES_CHANNEL, new MailRecipientStruct([]), new DataBag()); - - return new BusinessEvent('mail', $innerEvent, []); - } - -} diff --git a/tests/Services/StringTemplateRendererTest.php b/tests/Services/StringTemplateRendererTest.php deleted file mode 100644 index 8ec3625..0000000 --- a/tests/Services/StringTemplateRendererTest.php +++ /dev/null @@ -1,29 +0,0 @@ -render('{{ text }}', ['text' => 'foo'], Context::createDefaultContext())); - } - - public function testInvalidString(): void - { - $renderer = new StringTemplateRenderer(new Environment(new ArrayLoader())); - - static::expectException(StringTemplateRenderingException::class); - - $renderer->render('{{ text() }}', [], Context::createDefaultContext()); - } -} diff --git a/tests/TestBootstrap.php b/tests/TestBootstrap.php deleted file mode 100644 index c833cc2..0000000 --- a/tests/TestBootstrap.php +++ /dev/null @@ -1,52 +0,0 @@ -addPsr4('Frosh\\TemplateMail\\Tests\\', dirname(__DIR__) . '/tests'); - -if (class_exists('\Shopware\Core\Kernel')) { - $_SERVER['KERNEL_CLASS'] = '\Shopware\Core\Kernel'; -} else if (class_exists('\Shopware\Development\Kernel')) { - $_SERVER['KERNEL_CLASS'] = '\Shopware\Development\Kernel'; -} else if(class_exists('Shopware\Production\Kernel')) { - $_SERVER['KERNEL_CLASS'] = 'Shopware\Production\Kernel'; -} else { - throw new \RuntimeException('Cannot detect kernel class by own.'); -} - -(new Dotenv(true))->load($testProjectDir . '/.env'); - -$dbUrl = \getenv('DATABASE_URL'); -if ($dbUrl !== false) { - \putenv('DATABASE_URL=' . $dbUrl . '_test'); -} - -// Creates DB connection -KernelLifecycleManager::bootKernel();