From fdc6c423ff5b326742c81a8575d169f76c0d3a0b Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 8 Jan 2023 21:47:33 +0100 Subject: [PATCH 01/28] feat(tests): configure tests --- Makefile | 3 +++ phpunit.xml.dist | 1 + tests/bootstrap.php | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 4a190b7..79f7f65 100644 --- a/Makefile +++ b/Makefile @@ -24,3 +24,6 @@ doctrine-migration: PHP=$(PHP_BIN) ./bin/doctrine-migrate build: clean js-routing asset + +run-tests: + $(PHP_BIN) bin/phpunit tests/ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index af3f147..c5117fb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -13,6 +13,7 @@ + diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3181151..1ff1e4c 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -13,3 +13,9 @@ if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) { if ($_SERVER['APP_DEBUG']) { umask(0000); } + +passthru(sprintf( + 'APP_ENV=test PHP=%s "%s/../bin/doctrine-migrate"', + $_ENV['PHP_BIN'] ?? $_ENV['PHP'] ?? 'php', + __DIR__ +)); From d4eabf19374d91c29027ae6aa094192eb8068e09 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 8 Jan 2023 21:47:59 +0100 Subject: [PATCH 02/28] feat(db): add APP_ENV in doctrine-migrate script --- bin/doctrine-migrate | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/doctrine-migrate b/bin/doctrine-migrate index 42a19a0..1125cd8 100755 --- a/bin/doctrine-migrate +++ b/bin/doctrine-migrate @@ -1,7 +1,9 @@ #!/bin/sh -CLASS_NAME="$(echo "yes" | "$PHP" ./bin/console doctrine:migration:diff -e dev | grep -o "Version[0-9]*" | tail -n 1)" +APP_ENV="${APP_ENV:-dev}" + +CLASS_NAME="$(echo "yes" | "$PHP" ./bin/console doctrine:migration:diff -e "$APP_ENV" | grep -o "Version[0-9]*" | tail -n 1)" if [ -n "$CLASS_NAME" ]; then - echo "yes" | "$PHP" ./bin/console doctrine:migration:exec --up "DoctrineMigrations\\$CLASS_NAME" -e dev + echo "yes" | "$PHP" ./bin/console doctrine:migration:exec --up "DoctrineMigrations\\$CLASS_NAME" -e "$APP_ENV" fi From 9937160ae028ef20199bd34e0a0c26695ba3440f Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 8 Jan 2023 21:48:34 +0100 Subject: [PATCH 03/28] feat(test): update murph/murph-core version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index dea6ca6..58b8a95 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "prefer-stable": true, "require": { "php": ">=8.0.0", - "murph/murph-core": "^1.17" + "murph/murph-core": "dev-master" }, "require-dev": { "symfony/browser-kit": "^5.4", From 518c98710eae700748762838327c0f517b3ec6ba Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 8 Jan 2023 21:48:56 +0100 Subject: [PATCH 04/28] feat(ci): add base of CI --- .woodpecker.yml | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .woodpecker.yml diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..708c540 --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,55 @@ +matrix: + PHP_VERSION: + - 8.0 + - 8.1 + +services: + db: + image: mariadb:10.3 + environment: + - MARIADB_ROOT_PASSWORD=root + +pipeline: + wait_db: + image: gitnet.fr/deblan/timeout:latest + commands: + - /bin/timeout -t 30 -v -c 'while true; do nc -z -v db 3306 2>&1 | grep succeeded && exit 0; sleep 0.5; done' + + create_db: + image: mariadb:10.3 + commands: + - mysql -hdb -uroot -proot -e "CREATE DATABASE app" + + config: + image: deblan/php:8.1 + commands: + - echo APP_ENV=prod >> .env.local + - echo APP_SECRET=$(openssl rand -hex 32) >> .env.local + - echo DATABASE_URL=mysql://root:root@db/app >> .env.local + + composer: + image: deblan/php:${PHP_VERSION} + commands: + - apt-get update && apt-get -y install git + - composer install --no-scripts + + migrate: + image: deblan/php:${PHP_VERSION} + environment: + - PHP=php + commands: + - ./bin/doctrine-migrate + + node: + image: node:16-slim + commands: + - yarn + - test -f public/js/fos_js_routes.json || echo "{}" > public/js/fos_js_routes.json + - npm run build + + tests: + image: deblan/php:${PHP_VERSION} + environment: + - APP_ENV=test + commands: + - php bin/phpunit From 919edfe664d271d6d11d07702608d938f781b0de Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 8 Jan 2023 21:49:34 +0100 Subject: [PATCH 05/28] test(auth): add test of admin page access --- tests/Core/LoginTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/Core/LoginTest.php diff --git a/tests/Core/LoginTest.php b/tests/Core/LoginTest.php new file mode 100644 index 0000000..feec63b --- /dev/null +++ b/tests/Core/LoginTest.php @@ -0,0 +1,18 @@ +request('GET', '/admin'); + + $this->assertResponseStatusCodeSame(302); + $client->followRedirect(); + $this->assertResponseIsSuccessful(); + } +} From 49b90f6e6cc83bda20cea8e4a81021375e9206f3 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 8 Jan 2023 21:58:23 +0100 Subject: [PATCH 06/28] fix(ci): create directory public/js in CI --- .woodpecker.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 708c540..b571fa1 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,6 +1,6 @@ matrix: PHP_VERSION: - - 8.0 + # - 8.0 - 8.1 services: @@ -44,6 +44,7 @@ pipeline: image: node:16-slim commands: - yarn + - test -d public/js || mkdir public/js - test -f public/js/fos_js_routes.json || echo "{}" > public/js/fos_js_routes.json - npm run build From a22725ad6d56640d2217336f63f295c2d84169cd Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 8 Jan 2023 22:51:01 +0100 Subject: [PATCH 07/28] ci(command): add for murph:user:create --- tests/Core/Command/CreateUserTest.php | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/Core/Command/CreateUserTest.php diff --git a/tests/Core/Command/CreateUserTest.php b/tests/Core/Command/CreateUserTest.php new file mode 100644 index 0000000..306f120 --- /dev/null +++ b/tests/Core/Command/CreateUserTest.php @@ -0,0 +1,64 @@ +query = self::$container->get(UserRepositoryQuery::class); + } + + public function testCommandExecute(): void + { + $kernel = static::createKernel(); + $application = new Application($kernel); + $command = $application->find('murph:user:create'); + $commandTester = new CommandTester($command); + + $commandTester->setInputs([ + 'admin@localhost', + 'admin_password', + 'y', + 'n', + ]); + $commandTester->execute(['command' => $command->getName()]); + $output = $commandTester->getDisplay(); + $this->assertStringContainsString('User created!', $output); + + $commandTester->setInputs([ + 'writer@localhost', + 'writer_password', + 'n', + 'y', + ]); + $commandTester->execute(['command' => $command->getName()]); + $output = $commandTester->getDisplay(); + $this->assertStringContainsString('User created!', $output); + } + + public function testCreatedUsers(): void + { + $users = $this->query->create()->find(); + $this->assertEquals(2, count($users)); + + $this->assertEquals('admin@localhost', $users[0]->getEmail()); + $this->assertEquals('admin@localhost', $users[0]->getUsername()); + $this->assertEquals('writer@localhost', $users[1]->getEmail()); + $this->assertEquals('writer@localhost', $users[1]->getUsername()); + + $this->assertEquals(true, $users[0]->getIsAdmin()); + $this->assertEquals(false, $users[0]->getIsWriter()); + $this->assertEquals(false, $users[1]->getIsAdmin()); + $this->assertEquals(true, $users[1]->getIsWriter()); + } +} From 80af94a95eda88f5e650b6b769a4eb8f305cd52d Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 8 Jan 2023 22:51:27 +0100 Subject: [PATCH 08/28] refactor(test): rename LoginTest --- tests/Core/{ => Auth}/LoginTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename tests/Core/{ => Auth}/LoginTest.php (92%) diff --git a/tests/Core/LoginTest.php b/tests/Core/Auth/LoginTest.php similarity index 92% rename from tests/Core/LoginTest.php rename to tests/Core/Auth/LoginTest.php index feec63b..8cf820f 100644 --- a/tests/Core/LoginTest.php +++ b/tests/Core/Auth/LoginTest.php @@ -1,6 +1,6 @@ Date: Sun, 8 Jan 2023 22:51:53 +0100 Subject: [PATCH 09/28] feat(test): configure phpunit --- phpunit.xml.dist | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c5117fb..6e8a29e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -19,8 +19,11 @@ - - tests + + tests/Core/Command/CreateUserTest.php + + + tests/Core/Auth/LoginTest.php From 8535ef908228fb308967c14bc9abe5912567f281 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 8 Jan 2023 23:10:57 +0100 Subject: [PATCH 10/28] refactor(test): apply php-cs-fixer add select user by email --- tests/Core/Auth/LoginTest.php | 28 ++++++++++++++++++++++++--- tests/Core/Command/CreateUserTest.php | 10 +++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/tests/Core/Auth/LoginTest.php b/tests/Core/Auth/LoginTest.php index 8cf820f..2b8c96e 100644 --- a/tests/Core/Auth/LoginTest.php +++ b/tests/Core/Auth/LoginTest.php @@ -2,17 +2,39 @@ namespace App\Tests\Core\Auth; +use App\Repository\UserRepositoryQuery; +use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +/** + * @internal + * @coversNothing + */ class LoginTest extends WebTestCase { + protected UserRepositoryQuery $query; + protected KernelBrowser $client; + + protected function setUp(): void + { + $this->client = static::createClient(); + $this->query = self::$container->get(UserRepositoryQuery::class); + } + public function testLoginRedirect(): void { - $client = static::createClient(); - $crawler = $client->request('GET', '/admin'); + $crawler = $this->client->request('GET', '/admin'); $this->assertResponseStatusCodeSame(302); - $client->followRedirect(); + $this->client->followRedirect(); $this->assertResponseIsSuccessful(); } + + public function testLoginUser(): void + { + $user = $this->query->create()->andWhere('.email=\'admin@localhost\'')->findOne(); + $this->client->loginUser($user); + $this->client->request('GET', '/admin/account/'); + $this->assertResponseStatusCodeSame(200); + } } diff --git a/tests/Core/Command/CreateUserTest.php b/tests/Core/Command/CreateUserTest.php index 306f120..63af056 100644 --- a/tests/Core/Command/CreateUserTest.php +++ b/tests/Core/Command/CreateUserTest.php @@ -2,11 +2,15 @@ namespace App\Tests\Core\Command; +use App\Repository\UserRepositoryQuery; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Console\Tester\CommandTester; -use App\Repository\UserRepositoryQuery; +/** + * @internal + * @coversNothing + */ class CreateUserTest extends KernelTestCase { protected UserRepositoryQuery $query; @@ -31,7 +35,7 @@ class CreateUserTest extends KernelTestCase 'y', 'n', ]); - $commandTester->execute(['command' => $command->getName()]); + $commandTester->execute(['command' => $command->getName()]); $output = $commandTester->getDisplay(); $this->assertStringContainsString('User created!', $output); @@ -41,7 +45,7 @@ class CreateUserTest extends KernelTestCase 'n', 'y', ]); - $commandTester->execute(['command' => $command->getName()]); + $commandTester->execute(['command' => $command->getName()]); $output = $commandTester->getDisplay(); $this->assertStringContainsString('User created!', $output); } From 40633fa5673faedba2d4f9bb4e36a7a30beef5d0 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 8 Jan 2023 23:14:16 +0100 Subject: [PATCH 11/28] ci(conf): use mariadb for tests --- .env.test | 1 - 1 file changed, 1 deletion(-) diff --git a/.env.test b/.env.test index 3261772..9e7162f 100644 --- a/.env.test +++ b/.env.test @@ -4,4 +4,3 @@ APP_SECRET='$ecretf0rt3st' SYMFONY_DEPRECATIONS_HELPER=999999 PANTHER_APP_ENV=panther PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots -DATABASE_URL="sqlite:///%kernel.project_dir%/var/data_tests.db" From 85e04205cdb658f60cc1aec1877f5f8a8598eeb5 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 9 Jan 2023 09:49:30 +0100 Subject: [PATCH 12/28] feat(test): add dependencies --- .gitignore | 3 +++ .woodpecker.yml | 2 ++ composer.json | 2 ++ 3 files changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 2f54f0e..d10c279 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ yarn-error.log /phpunit.xml .phpunit.result.cache ###< phpunit/phpunit ### + +# Tests +/drivers/ diff --git a/.woodpecker.yml b/.woodpecker.yml index b571fa1..dab0b69 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -53,4 +53,6 @@ pipeline: environment: - APP_ENV=test commands: + - composer require --dev dbrekelmans/bdi + - vendor/bin/bdi detect drivers - php bin/phpunit diff --git a/composer.json b/composer.json index 58b8a95..28f9f87 100644 --- a/composer.json +++ b/composer.json @@ -10,10 +10,12 @@ "murph/murph-core": "dev-master" }, "require-dev": { + "dbrekelmans/bdi": "^1.0", "symfony/browser-kit": "^5.4", "symfony/css-selector": "^5.4", "symfony/debug-bundle": "^5.4", "symfony/maker-bundle": "^1.0", + "symfony/panther": "^2.0", "symfony/phpunit-bridge": "^6.2", "symfony/stopwatch": "^5.4", "symfony/var-dumper": "^5.4", From 3df5aba32061668aebac0131932e6247066fe1b7 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 9 Jan 2023 09:59:21 +0100 Subject: [PATCH 13/28] ci(test): add test database --- .woodpecker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker.yml b/.woodpecker.yml index dab0b69..bc7783e 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -19,6 +19,7 @@ pipeline: image: mariadb:10.3 commands: - mysql -hdb -uroot -proot -e "CREATE DATABASE app" + - mysql -hdb -uroot -proot -e "CREATE DATABASE app_test" config: image: deblan/php:8.1 From 2aab5310d228717686a0865e3e03b73a025a598a Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 9 Jan 2023 10:06:59 +0100 Subject: [PATCH 14/28] feat(test): remove doctrine prefix on test --- config/packages/doctrine.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index b07e18f..0d4e65a 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -29,11 +29,11 @@ doctrine: alias: GedmoTree # (optional) it will default to the name set for the mapping is_bundle: false -when@test: - doctrine: - dbal: - # "TEST_TOKEN" is typically set by ParaTest - dbname_suffix: '_test%env(default::TEST_TOKEN)%' +# when@test: +# doctrine: +# dbal: +# # "TEST_TOKEN" is typically set by ParaTest +# dbname_suffix: '_test%env(default::TEST_TOKEN)%' when@prod: doctrine: From 4b1fdb86529786cdd2b199364c367d455160dda9 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 9 Jan 2023 10:09:05 +0100 Subject: [PATCH 15/28] ci(test): configure test database --- .woodpecker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker.yml b/.woodpecker.yml index bc7783e..721b1b2 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -27,6 +27,7 @@ pipeline: - echo APP_ENV=prod >> .env.local - echo APP_SECRET=$(openssl rand -hex 32) >> .env.local - echo DATABASE_URL=mysql://root:root@db/app >> .env.local + - echo DATABASE_URL=mysql://root:root@db/app_test >> .env.test.local composer: image: deblan/php:${PHP_VERSION} From 5dbcc513090b72d8c83bee1f721fd85875a45ac3 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 9 Jan 2023 10:20:19 +0100 Subject: [PATCH 16/28] ci(test): update commands --- .woodpecker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 721b1b2..ba5402f 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -55,6 +55,6 @@ pipeline: environment: - APP_ENV=test commands: - - composer require --dev dbrekelmans/bdi + - composer install --no-scripts --dev - vendor/bin/bdi detect drivers - php bin/phpunit From dd3630237c2f50a5b0b3f3ee756d925e4090c980 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 9 Jan 2023 22:25:39 +0100 Subject: [PATCH 17/28] test(backoffice): add base functional tests test creation of a navigation test creation of a menu test creation of a page --- tests/Core/PantherTestCase.php | 50 ++++++++++++++++++++++++++++++ tests/Core/Site/NavigationTest.php | 39 +++++++++++++++++++++++ tests/Core/Site/PageTest.php | 30 ++++++++++++++++++ tests/Core/Site/TreeTest.php | 32 +++++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 tests/Core/PantherTestCase.php create mode 100644 tests/Core/Site/NavigationTest.php create mode 100644 tests/Core/Site/PageTest.php create mode 100644 tests/Core/Site/TreeTest.php diff --git a/tests/Core/PantherTestCase.php b/tests/Core/PantherTestCase.php new file mode 100644 index 0000000..f81c358 --- /dev/null +++ b/tests/Core/PantherTestCase.php @@ -0,0 +1,50 @@ +client = static::createPantherClient([ + 'external_base_uri' => 'http://localhost:9080' + ]); + $this->query = $this->container()->get(UserRepositoryQuery::class); + } + + protected function authenticateAdmin(): void + { + $this->client->request('GET', '/login'); + $this->client->submitForm('Login', [ + '_username' => 'admin@localhost', + '_password' => 'admin_password', + ]); + $this->client->waitFor('.nav-item-label'); + } + + protected function authenticateWriter(): void + { + $this->client->request('GET', '/login'); + $this->client->submitForm('Login', [ + '_username' => 'writer@localhost', + '_password' => 'writer_password', + ]); + $this->client->waitFor('.nav-item-label'); + } +} diff --git a/tests/Core/Site/NavigationTest.php b/tests/Core/Site/NavigationTest.php new file mode 100644 index 0000000..1108a13 --- /dev/null +++ b/tests/Core/Site/NavigationTest.php @@ -0,0 +1,39 @@ +authenticateAdmin(); + + $this->client->request('GET', '/admin/site/tree'); + $this->client->waitFor('.toast-body.text-text-warning'); + $this->assertSelectorTextContains('.toast-body.text-text-warning', 'You must add a navigation.'); + + $this->client->request('GET', '/admin/site/navigation'); + $this->assertSelectorTextContains('h1', 'Navigations'); + + $this->client->request('GET', '/admin/site/navigation/new'); + $this->assertSelectorTextContains('h1', 'New navigation'); + $this->client->submitForm('Save', [ + 'navigation[label]' => 'Test navigation', + 'navigation[locale]' => 'en', + 'navigation[code]' => 'nav', + 'navigation[domain]' => 'localhost', + ]); + + $this->client->waitFor('.toast-body.text-text-success'); + $this->assertSelectorTextContains('.toast-body.text-text-success', 'The data has been saved.'); + + $this->client->request('GET', '/admin/site/navigation'); + $this->assertSelectorTextContains('.table tbody tr td', 'Test navigation'); + } +} diff --git a/tests/Core/Site/PageTest.php b/tests/Core/Site/PageTest.php new file mode 100644 index 0000000..0a7a529 --- /dev/null +++ b/tests/Core/Site/PageTest.php @@ -0,0 +1,30 @@ +client->request('GET', '/admin/site/tree'); + $this->client->executeScript("document.querySelector('#node-2 .float-right button[data-modal]').click()"); + + $this->client->waitFor('#form-node-edit'); + $this->client->executeScript("document.querySelector('#node-page-action .card-header label').click()"); + $this->client->executeScript("document.querySelector('a[href=\"#form-node-edit-routing\"]').click()"); + $this->client->executeScript("document.querySelector('#node_url').value='/foo'"); + $this->client->executeScript("document.querySelector('#node_code').value='/foo'"); + $this->client->executeScript("document.querySelector('.modal.show .modal-footer button[type=\"submit\"]').click()"); + + $this->client->waitFor('.toast-body.text-text-success'); + $this->assertSelectorTextContains('.toast-body.text-text-success', 'The data has been saved.'); + + $this->assertSelectorTextContains('#node-2 .float-right a', 'Page'); + } +} diff --git a/tests/Core/Site/TreeTest.php b/tests/Core/Site/TreeTest.php new file mode 100644 index 0000000..d51d114 --- /dev/null +++ b/tests/Core/Site/TreeTest.php @@ -0,0 +1,32 @@ +client->request('GET', '/admin/site/tree'); + $this->assertSelectorTextContains('button[data-toggle="modal"]', 'Add a menu'); + $this->client->executeScript("document.querySelector('button[data-toggle=\"modal\"]').click()"); + + $this->client->waitFor('#form-menu-new'); + $this->client->submitForm('Save', [ + 'menu[label]' => 'Test menu', + 'menu[code]' => 'menu', + ]); + + $this->client->waitFor('.toast-body.text-text-success'); + $this->assertSelectorTextContains('.toast-body.text-text-success', 'The data has been saved.'); + + $this->client->request('GET', '/admin/site/tree'); + $this->assertSelectorTextContains('.h4', 'Test menu'); + $this->assertSelectorTextContains('#node-2 .col-6', 'First element'); + } +} From 496cd46db7c545663ee9216116797443c0b42b2f Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 9 Jan 2023 22:26:12 +0100 Subject: [PATCH 18/28] ci(tests): add web server start --- .woodpecker.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index ba5402f..5acc7f1 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -52,9 +52,8 @@ pipeline: tests: image: deblan/php:${PHP_VERSION} - environment: - - APP_ENV=test commands: - composer install --no-scripts --dev - vendor/bin/bdi detect drivers + - symfony server:start --port=9080 --no-tls - php bin/phpunit From 2ed04163b48b0e7086a5899d521dc3efc029a2a5 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 9 Jan 2023 22:28:25 +0100 Subject: [PATCH 19/28] feat(tests): add phpunit conf --- phpunit.xml.dist | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6e8a29e..96e8ed1 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -25,6 +25,11 @@ tests/Core/Auth/LoginTest.php + + tests/Core/Site/NavigationTest.php + tests/Core/Site/TreeTest.php + tests/Core/Site/PageTest.php + @@ -37,10 +42,7 @@ - - From c16e4652cbedbc33fb33ebbc9c89b183c1eb8af8 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 9 Jan 2023 22:28:57 +0100 Subject: [PATCH 20/28] feat(tests): update default env --- .env.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.test b/.env.test index 9e7162f..cfdfd53 100644 --- a/.env.test +++ b/.env.test @@ -2,5 +2,5 @@ KERNEL_CLASS='App\Kernel' APP_SECRET='$ecretf0rt3st' SYMFONY_DEPRECATIONS_HELPER=999999 -PANTHER_APP_ENV=panther +PANTHER_APP_ENV=test PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots From b1bf3a42a137679a24e47ae5148172011d304da7 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 9 Jan 2023 22:51:39 +0100 Subject: [PATCH 21/28] ci(conf): use deblan php images --- .woodpecker.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 5acc7f1..76572da 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -22,7 +22,7 @@ pipeline: - mysql -hdb -uroot -proot -e "CREATE DATABASE app_test" config: - image: deblan/php:8.1 + image: gitnet.fr/deblan/php:8.1 commands: - echo APP_ENV=prod >> .env.local - echo APP_SECRET=$(openssl rand -hex 32) >> .env.local @@ -30,13 +30,13 @@ pipeline: - echo DATABASE_URL=mysql://root:root@db/app_test >> .env.test.local composer: - image: deblan/php:${PHP_VERSION} + image: gitnet.fr/deblan/php:${PHP_VERSION} commands: - apt-get update && apt-get -y install git - composer install --no-scripts migrate: - image: deblan/php:${PHP_VERSION} + image: gitnet.fr/deblan/php:${PHP_VERSION} environment: - PHP=php commands: @@ -51,7 +51,7 @@ pipeline: - npm run build tests: - image: deblan/php:${PHP_VERSION} + image: gitnet.fr/deblan/php:${PHP_VERSION} commands: - composer install --no-scripts --dev - vendor/bin/bdi detect drivers From f55605bea01c131fd6838af04b94bd9bd7b9b253 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 9 Jan 2023 22:52:24 +0100 Subject: [PATCH 22/28] ci(conf): rollback images --- .woodpecker.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 76572da..5acc7f1 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -22,7 +22,7 @@ pipeline: - mysql -hdb -uroot -proot -e "CREATE DATABASE app_test" config: - image: gitnet.fr/deblan/php:8.1 + image: deblan/php:8.1 commands: - echo APP_ENV=prod >> .env.local - echo APP_SECRET=$(openssl rand -hex 32) >> .env.local @@ -30,13 +30,13 @@ pipeline: - echo DATABASE_URL=mysql://root:root@db/app_test >> .env.test.local composer: - image: gitnet.fr/deblan/php:${PHP_VERSION} + image: deblan/php:${PHP_VERSION} commands: - apt-get update && apt-get -y install git - composer install --no-scripts migrate: - image: gitnet.fr/deblan/php:${PHP_VERSION} + image: deblan/php:${PHP_VERSION} environment: - PHP=php commands: @@ -51,7 +51,7 @@ pipeline: - npm run build tests: - image: gitnet.fr/deblan/php:${PHP_VERSION} + image: deblan/php:${PHP_VERSION} commands: - composer install --no-scripts --dev - vendor/bin/bdi detect drivers From f8094c45f8db4a689b06ef94176268ab387dda66 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 9 Jan 2023 23:11:56 +0100 Subject: [PATCH 23/28] ci(conf): webserver is now run as daemon --- .woodpecker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 5acc7f1..b1f496d 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -55,5 +55,5 @@ pipeline: commands: - composer install --no-scripts --dev - vendor/bin/bdi detect drivers - - symfony server:start --port=9080 --no-tls + - symfony server:start --port=9080 --no-tls -d - php bin/phpunit From 8aa1b2f8c38ab13546b065696918882365c0decb Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Tue, 10 Jan 2023 10:00:38 +0100 Subject: [PATCH 24/28] ci(conf): dbrekelmans/bdi --- .woodpecker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.woodpecker.yml b/.woodpecker.yml index b1f496d..29a18a2 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -54,6 +54,7 @@ pipeline: image: deblan/php:${PHP_VERSION} commands: - composer install --no-scripts --dev + - composer require --dev dbrekelmans/bdi - vendor/bin/bdi detect drivers - symfony server:start --port=9080 --no-tls -d - php bin/phpunit From 56be2ebec7a0778147c4c85e39869b131524798b Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Tue, 10 Jan 2023 10:10:29 +0100 Subject: [PATCH 25/28] ci(conf): add chrome driver --- .woodpecker.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 29a18a2..7dce14b 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -53,8 +53,10 @@ pipeline: tests: image: deblan/php:${PHP_VERSION} commands: + - apt install unzip - composer install --no-scripts --dev - - composer require --dev dbrekelmans/bdi + - curl -o chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/108.0.5359.71/chromedriver_linux64.zip + - unzip -d drivers chromedriver_linux64.zip - vendor/bin/bdi detect drivers - symfony server:start --port=9080 --no-tls -d - php bin/phpunit From 7769e25c758a9f2b369041f12a2df821f9c4d939 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Tue, 10 Jan 2023 10:23:14 +0100 Subject: [PATCH 26/28] ci(conf): add chrome driver --- .woodpecker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 7dce14b..57065d2 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -53,7 +53,7 @@ pipeline: tests: image: deblan/php:${PHP_VERSION} commands: - - apt install unzip + - apt-get update && apt-get install -y unzip libnss3 - composer install --no-scripts --dev - curl -o chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/108.0.5359.71/chromedriver_linux64.zip - unzip -d drivers chromedriver_linux64.zip From bbe14360d93bf9af1752863971b072113eb4e1c5 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Tue, 10 Jan 2023 10:30:03 +0100 Subject: [PATCH 27/28] ci(conf): add chrome --- .woodpecker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 57065d2..933b673 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -55,8 +55,8 @@ pipeline: commands: - apt-get update && apt-get install -y unzip libnss3 - composer install --no-scripts --dev - - curl -o chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/108.0.5359.71/chromedriver_linux64.zip - - unzip -d drivers chromedriver_linux64.zip + - curl -o chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/108.0.5359.71/chromedriver_linux64.zip && unzip -d drivers chromedriver_linux64.zip + - curl -o /tmp/chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && apt install /tmp/chrome.deb - vendor/bin/bdi detect drivers - symfony server:start --port=9080 --no-tls -d - php bin/phpunit From 6c248452df5b1d5088a71ebe08a67f2c1ee54317 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Tue, 10 Jan 2023 10:36:01 +0100 Subject: [PATCH 28/28] ci(conf): add chrome --- .woodpecker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 933b673..e388b8e 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -53,10 +53,10 @@ pipeline: tests: image: deblan/php:${PHP_VERSION} commands: - - apt-get update && apt-get install -y unzip libnss3 + - apt-get update && apt-get install -y unzip - composer install --no-scripts --dev - curl -o chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/108.0.5359.71/chromedriver_linux64.zip && unzip -d drivers chromedriver_linux64.zip - - curl -o /tmp/chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && apt install /tmp/chrome.deb + - curl -o /tmp/chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && apt install -y /tmp/chrome.deb - vendor/bin/bdi detect drivers - symfony server:start --port=9080 --no-tls -d - php bin/phpunit