From 1d65576a93474df1785140083a8da6cd130e5dc2 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 21 Mar 2023 11:06:35 +0100 Subject: [PATCH 1/3] Fix test application with exampletestbundle --- .editorconfig | 3 ++ .github/workflows/test-application.yaml | 5 ++- .../Doctrine/MetadataLoader.php | 5 ++- .../Sulu/Link/ContentLinkProvider.php | 1 - Tests/Application/.env | 4 +- Tests/Application/.env.dev | 1 - Tests/Application/.env.test | 1 + .../Application/assets/admin/.browserslistrc | 3 ++ Tests/Application/assets/admin/.npmrc | 15 +++++++ Tests/Application/assets/admin/app.js | 1 + .../assets/admin/babel.config.json | 13 ++++-- Tests/Application/assets/admin/index.js | 10 +++-- Tests/Application/assets/admin/package.json | 43 +++++++++---------- Tests/Application/config/config_admin_dev.yml | 9 ++++ Tests/Application/config/routing_admin.yml | 9 ++++ Tests/Application/docker-compose.override.yml | 14 ++++++ Tests/Application/docker-compose.yaml | 11 ----- Tests/Application/docker-compose.yml | 22 ++++++++++ .../Model/DimensionContentCollectionTest.php | 1 - 19 files changed, 122 insertions(+), 49 deletions(-) delete mode 100644 Tests/Application/.env.dev create mode 100644 Tests/Application/.env.test create mode 100644 Tests/Application/assets/admin/.browserslistrc create mode 100644 Tests/Application/assets/admin/.npmrc create mode 100644 Tests/Application/assets/admin/app.js create mode 100644 Tests/Application/docker-compose.override.yml delete mode 100644 Tests/Application/docker-compose.yaml create mode 100644 Tests/Application/docker-compose.yml diff --git a/.editorconfig b/.editorconfig index 73a6c8de..670237b0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,6 +12,9 @@ trim_trailing_whitespace = true insert_final_newline = true max_line_length = 120 +[{docker-compose.yml,docker-compose.override.yml}] +indent_size = 2 + # markdown uses two trailing spaces for explicit line breaks [*.md] trim_trailing_whitespace = false diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index dfc6333c..43195743 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -13,7 +13,8 @@ jobs: runs-on: ubuntu-latest env: - DATABASE_URL: mysql://root:root@127.0.0.1:3306/su_content_test?serverVersion=5.7 + APP_ENV: test + DATABASE_URL: mysql://root:root@127.0.0.1:3306/su_content_test?serverVersion=8.0 DATABASE_CHARSET: utf8mb4 DATABASE_COLLATE: utf8mb4_unicode_ci @@ -53,7 +54,7 @@ jobs: services: mysql: - image: mysql:5.7 + image: mysql:8.0 env: MYSQL_ROOT_PASSWORD: root ports: diff --git a/Content/Infrastructure/Doctrine/MetadataLoader.php b/Content/Infrastructure/Doctrine/MetadataLoader.php index 6bd9ec6f..8244a7e4 100644 --- a/Content/Infrastructure/Doctrine/MetadataLoader.php +++ b/Content/Infrastructure/Doctrine/MetadataLoader.php @@ -31,7 +31,10 @@ use Sulu\Bundle\MediaBundle\Entity\MediaInterface; use Sulu\Bundle\TagBundle\Tag\TagInterface; -class MetadataLoader implements EventSubscriber +/** + * @internal + */ +final class MetadataLoader implements EventSubscriber { public function getSubscribedEvents() { diff --git a/Content/Infrastructure/Sulu/Link/ContentLinkProvider.php b/Content/Infrastructure/Sulu/Link/ContentLinkProvider.php index 4ae7181d..7ee470e8 100644 --- a/Content/Infrastructure/Sulu/Link/ContentLinkProvider.php +++ b/Content/Infrastructure/Sulu/Link/ContentLinkProvider.php @@ -104,7 +104,6 @@ public function preload(array $hrefs, $locale, $published = true): array /** * @param B $dimensionContent - * * @param mixed[] $data */ protected function getTitle(DimensionContentInterface $dimensionContent, array $data): ?string diff --git a/Tests/Application/.env b/Tests/Application/.env index a33dd03a..165a285d 100644 --- a/Tests/Application/.env +++ b/Tests/Application/.env @@ -1,4 +1,4 @@ -APP_ENV=test -DATABASE_URL=mysql://root:@127.0.0.1:3306/su_content_test?serverVersion=5.7 +APP_ENV=dev +DATABASE_URL=mysql://root:ChangeMe@127.0.0.1:3306/su_content_dev?serverVersion=5.7 DATABASE_CHARSET=utf8mb4 DATABASE_COLLATE=utf8mb4_unicode_ci diff --git a/Tests/Application/.env.dev b/Tests/Application/.env.dev deleted file mode 100644 index 393bcccd..00000000 --- a/Tests/Application/.env.dev +++ /dev/null @@ -1 +0,0 @@ -DATABASE_URL=mysql://root:@127.0.0.1:3306/su_content_test_dev?serverVersion=5.7 diff --git a/Tests/Application/.env.test b/Tests/Application/.env.test new file mode 100644 index 00000000..10a8a70c --- /dev/null +++ b/Tests/Application/.env.test @@ -0,0 +1 @@ +DATABASE_URL=mysql://root:ChangeMe@127.0.0.1:3306/su_content_test?serverVersion=8.0 diff --git a/Tests/Application/assets/admin/.browserslistrc b/Tests/Application/assets/admin/.browserslistrc new file mode 100644 index 00000000..467cada8 --- /dev/null +++ b/Tests/Application/assets/admin/.browserslistrc @@ -0,0 +1,3 @@ +last 2 versions and not dead +not ie < 12 +not ie_mob < 12 diff --git a/Tests/Application/assets/admin/.npmrc b/Tests/Application/assets/admin/.npmrc new file mode 100644 index 00000000..3bac8243 --- /dev/null +++ b/Tests/Application/assets/admin/.npmrc @@ -0,0 +1,15 @@ +# the package.json in this folder uses a preinstall and postinstall script for symlinking the javascript code of the +# sulu/sulu package into the node_modules directory: https://github.com/sulu/sulu/blob/2.x/symlink-vendor-directory.js +# when executing npm as root (eg. inside a docker container), npm will drop permissions when executing these scripts +# and therefore the symlink cannot be created. to prevent dropping permissions, we enable the "unsafe-perm" setting +# https://docs.npmjs.com/cli/v6/using-npm/scripts#user +unsafe-perm=true + +# the javascript setup in this folder is not compatible with npm 7: https://github.com/sulu/skeleton/issues/88 +# to display a helpful error message if an incompatible version is used, we enable the "engine-strict" setting +engine-strict=true + +# unfortunately, npm 7 tries to resolve the dependency tree before validating the "engines" section of the +# package.json. to display a helpful message instead of a confusing dependency tree error when using npm 7, we enable +# the "legacy-peer-deps" setting: https://github.com/sulu/skeleton/issues/133#issuecomment-907271497 +legacy-peer-deps=true diff --git a/Tests/Application/assets/admin/app.js b/Tests/Application/assets/admin/app.js new file mode 100644 index 00000000..f8c3475f --- /dev/null +++ b/Tests/Application/assets/admin/app.js @@ -0,0 +1 @@ +// Add project specific javascript code and import of additional bundles here: diff --git a/Tests/Application/assets/admin/babel.config.json b/Tests/Application/assets/admin/babel.config.json index 3e7bd2ff..8c3416c1 100644 --- a/Tests/Application/assets/admin/babel.config.json +++ b/Tests/Application/assets/admin/babel.config.json @@ -1,9 +1,14 @@ { - "presets": ["@babel/preset-env", "@babel/preset-react"], + "presets": [ + ["@babel/preset-env", {"useBuiltIns": "usage", "corejs": "3.18"}], + "@babel/preset-react" + ], "plugins": [ ["@babel/plugin-proposal-decorators", {"legacy": true}], - "@babel/plugin-proposal-object-rest-spread", "@babel/plugin-transform-flow-strip-types", - ["@babel/plugin-proposal-class-properties", {"loose": true}] - ] + "@babel/plugin-proposal-class-properties" + ], + "assumptions": { + "setPublicClassFields": true + } } diff --git a/Tests/Application/assets/admin/index.js b/Tests/Application/assets/admin/index.js index bc3740d8..11cbebb8 100644 --- a/Tests/Application/assets/admin/index.js +++ b/Tests/Application/assets/admin/index.js @@ -1,7 +1,7 @@ -// Polyfills -import 'regenerator-runtime/runtime'; +// This file should only be changed by the `bin/console sulu:admin:update-build` command: +// See https://docs.sulu.io/en/latest/upgrades/upgrade-2.x.html -// Bundles +// Sulu Core Bundles import {startAdmin} from 'sulu-admin-bundle'; import 'sulu-audience-targeting-bundle'; import 'sulu-category-bundle'; @@ -15,9 +15,11 @@ import 'sulu-route-bundle'; import 'sulu-search-bundle'; import 'sulu-security-bundle'; import 'sulu-snippet-bundle'; +import 'sulu-trash-bundle'; import 'sulu-website-bundle'; -// Implement custom extensions here +// Add project specific javascript code and import of additional bundles to the following file: +import './app.js'; // Start admin application startAdmin(); diff --git a/Tests/Application/assets/admin/package.json b/Tests/Application/assets/admin/package.json index c034c4cc..6952a381 100644 --- a/Tests/Application/assets/admin/package.json +++ b/Tests/Application/assets/admin/package.json @@ -1,9 +1,10 @@ { + "name": "sulu-skeleton", "license": "MIT", "repository": "https://github.com/sulu/skeleton.git", "scripts": { - "preinstall": "node ../../../../vendor/sulu/sulu/preinstall.js ../../../../vendor node_modules/@sulu/vendor", - "postinstall": "node ../../../../vendor/sulu/sulu/postinstall.js ../../../../vendor node_modules/@sulu/vendor", + "preinstall": "node ../../../../vendor/sulu/sulu/preinstall.js ../../../../vendor", + "postinstall": "node ../../../../vendor/sulu/sulu/postinstall.js ../../../../vendor", "build": "webpack --mode production", "watch": "webpack --mode development --watch" }, @@ -30,38 +31,36 @@ }, "devDependencies": { "@babel/core": "^7.5.5", + "@babel/plugin-proposal-class-properties": "^7.16.5", "@babel/plugin-proposal-decorators": "^7.4.4", - "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.2", "@babel/plugin-transform-flow-strip-types": "^7.4.4", "@babel/preset-env": "^7.5.5", "@babel/preset-react": "^7.0.0", - "@ckeditor/ckeditor5-dev-utils": "^24.4.2", - "@ckeditor/ckeditor5-theme-lark": "^27.1.0", - "autoprefixer": "^9.8.6", - "babel-loader": "^8.0.6", - "clean-webpack-plugin": "^3.0.0", + "@ckeditor/ckeditor5-dev-utils": "^30.3.2", + "@ckeditor/ckeditor5-theme-lark": "^34.2.0", + "autoprefixer": "^10.4.7", + "babel-loader": "^9.1.0", "core-js": "^3.18.0", "css-loader": "^5.2.4", + "css-minimizer-webpack-plugin": "^4.2.2", "file-loader": "^6.0.0", "glob": "^7.1.2", - "mini-css-extract-plugin": "^1.5.0", - "optimize-css-assets-webpack-plugin": "^5.0.3", - "postcss": "7.0.35", - "postcss-calc": "^7.0.5", - "postcss-hexrgba": "^2.0.0", - "postcss-import": "^12.0.1", - "postcss-loader": "^3.0.0", - "postcss-nested": "^4.2.3", - "postcss-simple-vars": "^5.0.2", + "mini-css-extract-plugin": "^2.7.1", + "postcss": "^8.4.14", + "postcss-calc": "^8.2.4", + "postcss-hexrgba": "^2.1.0", + "postcss-import": "^15.0.1", + "postcss-loader": "^7.0.2", + "postcss-nested": "^6.0.0", + "postcss-simple-vars": "^7.0.1", "raw-loader": "^4.0.0", "regenerator-runtime": "^0.13.3", - "webpack": "^4.27.0", - "webpack-clean-obsolete-chunks": "^0.4.0", - "webpack-cli": "^4.7.0", - "webpack-manifest-plugin": "^3.1.1" + "webpack": "^5.75.0", + "webpack-cli": "^5.0.0", + "webpack-manifest-plugin": "^5.0.0" }, "engines": { - "node": ">=12", + "node": ">=14", "npm": ">=6 <7" } } diff --git a/Tests/Application/config/config_admin_dev.yml b/Tests/Application/config/config_admin_dev.yml index f485c642..0be73d1c 100644 --- a/Tests/Application/config/config_admin_dev.yml +++ b/Tests/Application/config/config_admin_dev.yml @@ -2,3 +2,12 @@ security: providers: testprovider: id: sulu_security.user_provider + firewalls: + test: + entry_point: sulu_security.authentication_entry_point + json_login: + check_path: sulu_admin.login_check + success_handler: sulu_security.authentication_handler + failure_handler: sulu_security.authentication_handler + logout: + path: sulu_admin.logout diff --git a/Tests/Application/config/routing_admin.yml b/Tests/Application/config/routing_admin.yml index 0ff04a87..07721e7a 100644 --- a/Tests/Application/config/routing_admin.yml +++ b/Tests/Application/config/routing_admin.yml @@ -91,6 +91,15 @@ sulu_preview: resource: "@SuluPreviewBundle/Resources/config/routing.yml" prefix: /admin/preview +sulu_preview_api: + type: rest + resource: "@SuluPreviewBundle/Resources/config/routing_api.yml" + prefix: /admin/api + +sulu_preview_public: + resource: "@SuluPreviewBundle/Resources/config/routing_public.yml" + prefix: /admin/p + sulu_search: resource: "@SuluSearchBundle/Resources/config/routing.yml" prefix: /admin/search diff --git a/Tests/Application/docker-compose.override.yml b/Tests/Application/docker-compose.override.yml new file mode 100644 index 00000000..b6a03e06 --- /dev/null +++ b/Tests/Application/docker-compose.override.yml @@ -0,0 +1,14 @@ +version: '3' + +services: +###> symfony/mailer ### + mailer: + image: schickling/mailcatcher + ports: [1025, 1080] +###< symfony/mailer ### + +###> doctrine/doctrine-bundle ### + database: + ports: + - "3306:3306" +###< doctrine/doctrine-bundle ### diff --git a/Tests/Application/docker-compose.yaml b/Tests/Application/docker-compose.yaml deleted file mode 100644 index f74f3832..00000000 --- a/Tests/Application/docker-compose.yaml +++ /dev/null @@ -1,11 +0,0 @@ -version: '3.3' - -services: - mysql: - image: mysql:5.7 - environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 1 - volumes: - - ./var/data/mysql:/var/lib/mysql - ports: - - ${DOCKER_MYSQL_PORT:-3306}:3306 diff --git a/Tests/Application/docker-compose.yml b/Tests/Application/docker-compose.yml new file mode 100644 index 00000000..823df899 --- /dev/null +++ b/Tests/Application/docker-compose.yml @@ -0,0 +1,22 @@ +version: '3' + +services: + ###> doctrine/doctrine-bundle ### + database: + # arm compatible mysql docker image + image: mysql/mysql-server:${MYSQL_VERSION:-8.0} # arm and x86/x64 compatible mysql image + environment: + MYSQL_DATABASE: ${MYSQL_DATABASE:-su_content_dev} + # You should definitely change the password in production + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-ChangeMe} + MYSQL_ROOT_HOST: '%' + volumes: + - db-data:/var/lib/mysql + # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! + # - ./docker/db/data:/var/lib/mysql:rw +###< doctrine/doctrine-bundle ### + +volumes: + ###> doctrine/doctrine-bundle ### + db-data: +###< doctrine/doctrine-bundle ### diff --git a/Tests/Unit/Content/Domain/Model/DimensionContentCollectionTest.php b/Tests/Unit/Content/Domain/Model/DimensionContentCollectionTest.php index 583da89f..6377a1fa 100644 --- a/Tests/Unit/Content/Domain/Model/DimensionContentCollectionTest.php +++ b/Tests/Unit/Content/Domain/Model/DimensionContentCollectionTest.php @@ -57,7 +57,6 @@ public function testCount(): void public function testSortedByAttributes(): void { - $example = new Example(); $dimensionContent1 = new ExampleDimensionContent($example); $dimensionContent1->setStage('draft'); From 3de150544fd68fc3eeee5878a55bbdb447a98a42 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 21 Mar 2023 11:08:59 +0100 Subject: [PATCH 2/3] Increase version of coduo php matcher --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5fa536af..04958c8f 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "webmozart/assert": "^1.3" }, "require-dev": { - "coduo/php-matcher": "^3.2 || ^4.0 || ^5.0 || ^6.0", + "coduo/php-matcher": "^5.0.1 || ^6.0", "doctrine/data-fixtures": "^1.3.3", "doctrine/doctrine-fixtures-bundle": "^2.0 || ^3.0", "friendsofphp/php-cs-fixer": "^3.4", From 581cfa56d9e780be42d5e58363268c66aeb5fd5c Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 21 Mar 2023 11:10:29 +0100 Subject: [PATCH 3/3] Revert tested mysql version --- .github/workflows/test-application.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 43195743..439c9606 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -14,7 +14,7 @@ jobs: env: APP_ENV: test - DATABASE_URL: mysql://root:root@127.0.0.1:3306/su_content_test?serverVersion=8.0 + DATABASE_URL: mysql://root:root@127.0.0.1:3306/su_content_test?serverVersion=5.7.32 DATABASE_CHARSET: utf8mb4 DATABASE_COLLATE: utf8mb4_unicode_ci @@ -54,7 +54,7 @@ jobs: services: mysql: - image: mysql:8.0 + image: mysql:5.7 env: MYSQL_ROOT_PASSWORD: root ports: