Skip to content
Draft
Show file tree
Hide file tree
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
50 changes: 13 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
.DEFAULT_GOAL := help
SHELL=/bin/bash
APP_DIR=tests/Application
SYLIUS_VERSION=2.1.0
SYMFONY=cd ${APP_DIR} && symfony
APP_DIR=vendor/sylius/test-application
SYMFONY=symfony
COMPOSER=symfony composer
CONSOLE=${SYMFONY} console
CONSOLE=${SYMFONY} php vendor/bin/console
export COMPOSE_PROJECT_NAME=rich-editor
PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin
COMPOSE=docker compose
Expand All @@ -21,9 +20,7 @@ up: docker.up server.start ## Up the project (start docker, start symfony server
stop: server.stop docker.stop ## Stop the project (stop docker, stop symfony server)
down: server.stop docker.down ## Down the project (removes docker containers, stop symfony server)

reset: ## Stop docker and remove dependencies
${MAKE} docker.down || true
rm -rf ${APP_DIR}
reset: down ## Stop docker and remove dependencies
rm -rf node_modules yarn.lock vendor composer.lock
.PHONY: reset

Expand Down Expand Up @@ -59,33 +56,12 @@ ${APP_DIR}/node_modules: yarn.install
### TEST APPLICATION
### ¯¯¯¯¯

application: .php-version php.ini ${APP_DIR} setup_application ${APP_DIR}/docker-compose.yaml

${APP_DIR}:
(${COMPOSER} create-project --no-interaction --prefer-dist --no-scripts --no-progress --no-install sylius/sylius-standard="~${SYLIUS_VERSION}" ${APP_DIR})

setup_application:
rm -f ${APP_DIR}/yarn.lock
(cd ${APP_DIR} && ${COMPOSER} config repositories.plugin '{"type": "path", "url": "../../"}')
(cd ${APP_DIR} && ${COMPOSER} config extra.symfony.allow-contrib true)
(cd ${APP_DIR} && ${COMPOSER} config minimum-stability dev)
(cd ${APP_DIR} && ${COMPOSER} config --no-plugins allow-plugins true)
(cd ${APP_DIR} && ${COMPOSER} config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]')
(cd ${APP_DIR} && ${COMPOSER} require --no-install --no-scripts --no-progress sylius/sylius="~${SYLIUS_VERSION}") # Make sure to install the required version of sylius because the sylius-standard has a soft constraint
$(MAKE) ${APP_DIR}/.php-version
$(MAKE) ${APP_DIR}/php.ini
(cd ${APP_DIR} && ${COMPOSER} install --no-interaction)
$(MAKE) apply_dist
(cd ${APP_DIR} && ${COMPOSER} require --no-progress monsieurbiz/${PLUGIN_NAME}="*@dev")
rm -rf ${APP_DIR}/var/cache

application: .php-version php.ini dependencies apply_dist ${APP_DIR}/docker-compose.yaml
.PHONY: application

${APP_DIR}/docker-compose.yaml:
rm -f ${APP_DIR}/docker-compose.yml
rm -f ${APP_DIR}/docker-compose.yaml
rm -f ${APP_DIR}/compose.yml # Remove Sylius file about Docker
rm -f ${APP_DIR}/compose.override.dist.yml # Remove Sylius file about Docker
ln -s ../../docker-compose.yaml.dist ${APP_DIR}/docker-compose.yaml
rm -f ${APP_DIR}/{docker-compose.yml,docker-compose.yaml,compose.yml,compose.override.dist.yml} # Remove all Sylius files about Docker
ln -s ../../../docker-compose.yaml.dist ${APP_DIR}/docker-compose.yaml
.PHONY: ${APP_DIR}/docker-compose.yaml

${APP_DIR}/.php-version: .php-version
Expand Down Expand Up @@ -136,19 +112,19 @@ test.container: ## Lint the symfony container
${CONSOLE} lint:container

test.yaml: ## Lint the symfony Yaml files
${CONSOLE} lint:yaml ../../src/Resources/config --parse-tags
${CONSOLE} lint:yaml src/Resources/config tests/TestApplication/config --parse-tags

test.schema: ## Validate MySQL Schema
${CONSOLE} doctrine:schema:validate

test.twig: ## Validate Twig templates
${CONSOLE} lint:twig --no-debug templates/ ../../src/Resources/views/
${CONSOLE} lint:twig --no-debug src/Resources/views/ tests/TestApplication/templates/

###
### SYLIUS
### ¯¯¯¯¯¯

sylius: dependencies sylius.database sylius.fixtures sylius.assets messenger.setup ## Install Sylius
sylius: sylius.database sylius.fixtures sylius.assets messenger.setup ## Install Sylius
.PHONY: sylius

sylius.database: ## Setup the database
Expand Down Expand Up @@ -199,10 +175,10 @@ docker.dc: ## Run docker-compose command. Use ARGS="" to pass parameters to dock
.PHONY: docker.dc

server.start: ## Run the local webserver using Symfony
${SYMFONY} local:server:start -d
${SYMFONY} local:server:start -d --dir=${APP_DIR}/public

server.stop: ## Stop the local webserver
${SYMFONY} local:server:stop
${SYMFONY} local:server:stop --dir=${APP_DIR}/public

###
### HELP
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ composer require monsieurbiz/sylius-media-manager-plugin="^2.0"
### Update your form type

To make a field use the rich editor, you must use the `RichEditorType` type for it.
We have an example of implementation in the [file for the test application](/dist/src/Form/Extension/ProductTypeExtension.php).
We have an example of implementation in the [file for the test application](/test/src/Form/Extension/ProductTypeExtension.php).

If your field has some data already, like some previous text before installing this plugin,
then we will convert it for you as an HTML Element which contains… HTML.
Expand All @@ -115,7 +115,7 @@ To display the content of the rich editor field you must call the twig filter:
{{ content | monsieurbiz_richeditor_render_field }}
```

You can see an example in the [file for the test application](/dist/templates/bundles/SyliusShopBundle/Product/Show/Tabs/Details/_description.html.twig)
You can see an example in the [file for the test application](/tests/TestApplication/templates/bundles/SyliusShopBundle/Product/Show/Tabs/Details/_description.html.twig)

### Custom rendering of elements

Expand Down
1 change: 1 addition & 0 deletions assets/admin/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Empty file added assets/admin/entrypoint.js
Empty file.
1 change: 1 addition & 0 deletions assets/shop/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Empty file added assets/shop/entrypoint.js
Empty file.
14 changes: 11 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"phpstan/phpstan-doctrine": "^1.3.2",
"phpstan/phpstan-webmozart-assert": "^1.1",
"phpunit/phpunit": "^10.5",
"phpmd/phpmd": "^2.15"
"phpmd/phpmd": "^2.15",
"sylius/test-application": "2.1.x-dev"
},
"suggest": {
"monsieurbiz/sylius-media-manager-plugin": "To use the media manager in the ui elements"
Expand All @@ -32,6 +33,11 @@
"MonsieurBiz\\SyliusRichEditorPlugin\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\MonsieurBiz\\SyliusRichEditorPlugin\\TestApplication\\": "tests/TestApplication/src/"
}
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
Expand All @@ -50,15 +56,17 @@
"symfony": {
"docker": false,
"endpoint": ["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master", "flex://defaults"]
}
},
"public-dir": "vendor/sylius/test-application/public"
},
"config": {
"allow-plugins": {
"symfony/thanks": true,
"symfony/flex": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"ergebnis/composer-normalize": true,
"php-http/discovery": true
"php-http/discovery": true,
"symfony/runtime": true
}
}
}
71 changes: 0 additions & 71 deletions dist/src/Migrations/Version20220621100423.php

This file was deleted.

4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.0/phpunit.xsd"
colors="true"
bootstrap="tests/Application/config/bootstrap.php">
bootstrap="vendor/sylius/test-application/config/bootstrap.php">
<testsuites>
<testsuite name="MonsieurBizSyliusRichEditorPlugin Test Suite">
<directory>tests/Unit</directory>
</testsuite>
</testsuites>

<php>
<server name="KERNEL_CLASS_PATH" value="/tests/Application/src/Kernel.php" />
<server name="KERNEL_CLASS_PATH" value="Sylius\TestApplication\Kernel" />
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />

<env name="APP_ENV" value="test"/>
Expand Down
4 changes: 4 additions & 0 deletions tests/TestApplication/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

BUNDLES_TO_ENABLE="MonsieurBiz\SyliusRichEditorPlugin\MonsieurBizSyliusRichEditorPlugin"
CONFIGS_TO_IMPORT="../../../../tests/TestApplication/config/config.yaml"
ROUTES_TO_IMPORT="../../../../tests/TestApplication/config/routes.yaml"
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
imports:
- { resource: "@MonsieurBizSyliusRichEditorPlugin/Resources/config/config.yaml" }

services:
_defaults:
autowire: true
autoconfigure: true
public: false

Tests\MonsieurBiz\SyliusRichEditorPlugin\TestApplication\:
resource: '../src/*'
exclude: '../src/{Entity}'

twig:
paths:
'%kernel.project_dir%/../../../tests/TestApplication/templates': ~

framework:
translator:
paths:
- '%kernel.project_dir%/../../../tests/TestApplication/translations'

monsieurbiz_sylius_richeditor:
ui_elements:
# Example without PHP Attributes
# app.google_maps:
# title: 'app.ui_element.google_maps.title'
# description: 'app.ui_element.google_maps.description'
# icon: tabler:brand-google-maps
# tags: [ map ]
# classes:
# form: App\Form\Type\UiElement\GoogleMapsType
# ui_element: App\UiElement\GoogleMapsUiElement
# templates:
# admin_render: '/admin/ui_element/google_maps.html.twig'
# front_render: '/shop/ui_element/google_maps.html.twig'
# Example without PHP Attributes
# app.google_maps:
# title: 'app.ui_element.google_maps.title'
# description: 'app.ui_element.google_maps.description'
# icon: tabler:brand-google-maps
# tags: [ map ]
# classes:
# form: App\Form\Type\UiElement\GoogleMapsType
# ui_element: App\UiElement\GoogleMapsUiElement
# templates:
# admin_render: '/admin/ui_element/google_maps.html.twig'
# front_render: '/shop/ui_element/google_maps.html.twig'
app.noseeme:
title: 'You should not see me'
description: 'The invisible Ui Element'
Expand All @@ -30,13 +52,13 @@ sylius_fixtures:
monsieurbiz_rich_editor_file:
options:
files:
- source_path: 'src/Resources/fixtures/cap_banner.jpg'
- source_path: '%kernel.project_dir%/../../../tests/TestApplication/fixtures/cap_banner.jpg'
target_path: 'rich-editor/cap_banner.jpg'
- source_path: 'src/Resources/fixtures/cap_image_1.jpg'
- source_path: '%kernel.project_dir%/../../../tests/TestApplication/fixtures/cap_image_1.jpg'
target_path: 'rich-editor/cap_image_1.jpg'
- source_path: 'src/Resources/fixtures/cap_image_2.jpg'
- source_path: '%kernel.project_dir%/../../../tests/TestApplication/fixtures/cap_image_2.jpg'
target_path: 'rich-editor/cap_image_2.jpg'
- source_path: 'src/Resources/fixtures/cap_image_3.jpg'
- source_path: '%kernel.project_dir%/../../../tests/TestApplication/fixtures/cap_image_3.jpg'
target_path: 'rich-editor/cap_image_3.jpg'
monsieurbiz_rich_editor_product:
options:
Expand Down
3 changes: 3 additions & 0 deletions tests/TestApplication/config/routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
monsieurbiz_richeditor_admin:
resource: "@MonsieurBizSyliusRichEditorPlugin/Resources/config/routing/admin.yaml"
prefix: /%sylius_admin.path_name%
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace App\Fixture\Factory;
namespace Tests\MonsieurBiz\SyliusRichEditorPlugin\TestApplication\Fixture\Factory;

use InvalidArgumentException;
use Sylius\Bundle\CoreBundle\Fixture\Factory\AbstractExampleFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace App\Fixture\Factory;
namespace Tests\MonsieurBiz\SyliusRichEditorPlugin\TestApplication\Fixture\Factory;

use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

declare(strict_types=1);

namespace App\Fixture;
namespace Tests\MonsieurBiz\SyliusRichEditorPlugin\TestApplication\Fixture;

use App\Fixture\Factory\RichEditorProductFixtureFactoryInterface;
use Doctrine\ORM\EntityManagerInterface;
use Sylius\Bundle\CoreBundle\Fixture\AbstractResourceFixture;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Tests\MonsieurBiz\SyliusRichEditorPlugin\TestApplication\Fixture\Factory\RichEditorProductFixtureFactoryInterface;

final class RichEditorProductFixture extends AbstractResourceFixture
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace App\Form\Extension;
namespace Tests\MonsieurBiz\SyliusRichEditorPlugin\TestApplication\Form\Extension;

use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\RichEditorType;
use Sylius\Bundle\ProductBundle\Form\Type\ProductTranslationType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

declare(strict_types=1);

namespace App\Form\Type\UiElement;
namespace Tests\MonsieurBiz\SyliusRichEditorPlugin\TestApplication\Form\Type\UiElement;

use App\UiElement\GoogleMapsUiElement;
use MonsieurBiz\SyliusRichEditorPlugin\Attribute\AsUiElement;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Tests\MonsieurBiz\SyliusRichEditorPlugin\TestApplication\UiElement\GoogleMapsUiElement;

#[AsUiElement(
code: 'app.google_maps',
Expand Down
Loading
Loading