diff --git a/.github/workflows/test-turbo.yml b/.github/workflows/test-turbo.yml index 47008d2605a..cc215185afa 100644 --- a/.github/workflows/test-turbo.yml +++ b/.github/workflows/test-turbo.yml @@ -65,8 +65,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - run: corepack enable - - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -81,25 +79,9 @@ jobs: working-directory: src/Turbo dependency-versions: ${{ matrix.dependency-version }} - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v4 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-yarn- - - name: Install JavaScript dependencies working-directory: src/Turbo/tests/app - run: touch yarn.lock && yarn install --mode update-lockfile && yarn install - - - name: Build JavaScript - working-directory: src/Turbo/tests/app - run: yarn build + run: php public/index.php importmap:install - name: Create DB working-directory: src/Turbo/tests/app diff --git a/src/Turbo/.gitignore b/src/Turbo/.gitignore index 264070be8bd..2f9ac49a826 100644 --- a/src/Turbo/.gitignore +++ b/src/Turbo/.gitignore @@ -5,8 +5,7 @@ /composer.lock /phpunit.xml /vendor/ -/tests/app/var +/tests/app/assets/vendor/ +/tests/app/var/ /tests/app/public/build/ node_modules/ -package-lock.json -yarn.lock diff --git a/src/Turbo/composer.json b/src/Turbo/composer.json index e3cb46514a4..951fdefeb36 100644 --- a/src/Turbo/composer.json +++ b/src/Turbo/composer.json @@ -41,12 +41,13 @@ "doctrine/doctrine-bundle": "^2.4.3", "doctrine/orm": "^2.8 | 3.0", "phpstan/phpstan": "^1.10", + "symfony/asset-mapper": "^6.4|^7.0", "symfony/debug-bundle": "^5.4|^6.0|^7.0", "symfony/form": "^5.4|^6.0|^7.0", - "symfony/framework-bundle": "^5.4|^6.0|^7.0", + "symfony/framework-bundle": "^6.4|^7.0", "symfony/mercure-bundle": "^0.3.7", "symfony/messenger": "^5.4|^6.0|^7.0", - "symfony/panther": "^1.0|^2.0", + "symfony/panther": "^2.1", "symfony/phpunit-bridge": "^5.4|^6.0|^7.0", "symfony/process": "^5.4|6.3.*|^7.0", "symfony/property-access": "^5.4|^6.0|^7.0", diff --git a/src/Turbo/tests/BroadcastTest.php b/src/Turbo/tests/BroadcastTest.php index 3fee2ec3a6a..f95b00cde54 100644 --- a/src/Turbo/tests/BroadcastTest.php +++ b/src/Turbo/tests/BroadcastTest.php @@ -26,8 +26,8 @@ class BroadcastTest extends PantherTestCase protected function setUp(): void { - if (!file_exists(__DIR__.'/app/public/build')) { - throw new \Exception(\sprintf('Move into "%s" and execute Encore before running this test.', realpath(__DIR__.'/app'))); + if (!file_exists(__DIR__.'/app/assets/vendor/installed.php')) { + throw new \Exception(\sprintf('Move into "%s" and execute `php public/index.php importmap:install` before running this test.', realpath(__DIR__.'/app'))); } parent::setUp(); diff --git a/src/Turbo/tests/app/Kernel.php b/src/Turbo/tests/app/Kernel.php index 5e2594135e0..331295ddccb 100644 --- a/src/Turbo/tests/app/Kernel.php +++ b/src/Turbo/tests/app/Kernel.php @@ -67,10 +67,13 @@ protected function configureContainer(ContainerConfigurator $container): void { $container->extension('framework', [ 'secret' => 'ChangeMe', - 'test' => 'test' === ($_SERVER['APP_ENV'] ?? 'dev'), + 'test' => 'test' === $this->environment, 'router' => [ 'utf8' => true, ], + 'asset_mapper' => [ + 'paths' => ['assets/'] + ], 'profiler' => [ 'only_exceptions' => false, ], diff --git a/src/Turbo/tests/app/assets/controllers.json b/src/Turbo/tests/app/assets/controllers.json new file mode 100644 index 00000000000..21f1964543f --- /dev/null +++ b/src/Turbo/tests/app/assets/controllers.json @@ -0,0 +1,5 @@ +{ + "controllers": { + }, + "entrypoints": [] +} diff --git a/src/Turbo/tests/app/assets/controllers/.gitignore b/src/Turbo/tests/app/assets/controllers/.gitignore new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/Turbo/tests/app/importmap.php b/src/Turbo/tests/app/importmap.php new file mode 100644 index 00000000000..68e52d3d234 --- /dev/null +++ b/src/Turbo/tests/app/importmap.php @@ -0,0 +1,31 @@ + [ + 'path' => './assets/app.js', + 'entrypoint' => true, + ], + '@hotwired/stimulus' => [ + 'version' => '3.2.2', + ], + '@symfony/stimulus-bundle' => [ + 'path' => '../../vendor/symfony/stimulus-bundle/assets/dist/loader.js', + ], + '@symfony/ux-turbo/dist/turbo_stream_controller' => [ + 'path' => '../../assets/dist/turbo_stream_controller.js' + ], + '@hotwired/turbo' => [ + 'version' => '7.3.0', + ], +]; diff --git a/src/Turbo/tests/app/package.json b/src/Turbo/tests/app/package.json deleted file mode 100644 index 43fc6df5435..00000000000 --- a/src/Turbo/tests/app/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "packageManager": "yarn@4.5.0", - "devDependencies": { - "@babel/core": "^7.20.12", - "@babel/preset-env": "^7.20.2", - "@hotwired/stimulus": "^3.0.0", - "@hotwired/turbo": "^7.0.1", - "@symfony/ux-turbo": "file:../../assets", - "@symfony/webpack-encore": "^4.2.0", - "core-js": "^3.0.0", - "regenerator-runtime": "^0.13.2", - "webpack": "^5.75.0", - "webpack-cli": "^5.0.1", - "webpack-notifier": "^1.6.0" - }, - "resolutions": { - "coa": "2.0.2" - }, - "license": "MIT", - "private": true, - "scripts": { - "dev-server": "encore dev-server", - "dev": "encore dev", - "watch": "encore dev --watch", - "build": "encore production --progress" - } -} diff --git a/src/Turbo/tests/app/templates/base.html.twig b/src/Turbo/tests/app/templates/base.html.twig index 0a3c7a37350..0d532df5fab 100644 --- a/src/Turbo/tests/app/templates/base.html.twig +++ b/src/Turbo/tests/app/templates/base.html.twig @@ -4,7 +4,9 @@