diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61914da..e20057f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: DB_DATABASE: phplist DB_USERNAME: root DB_PASSWORD: phplist - BROADCAST_DRIVER: log + BROADCAST_DRIVER: log services: mysql: image: mysql:5.7 @@ -22,17 +22,21 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['7.2', '7.3', '7.4', '8.0'] - # dependencies: ['latest', 'oldest'] + php-versions: ['8.1'] steps: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, fileinfo, mysql coverage: xdebug #optional + - name: Install Symfony CLI + run: | + curl -sS https://get.symfony.com/cli/installer | bash + mv $HOME/.symfony*/bin/symfony /usr/local/bin/symfony + symfony version - name: Start mysql service run: sudo /etc/init.d/mysql start - name: Verify MySQL connection on host @@ -44,36 +48,23 @@ jobs: uses: actions/cache@v2 with: path: ${{ steps.composer-cache.outputs.dir }} - # Use composer.json for key, if composer.lock is not committed. - # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install the latest dependencies run: composer install - continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8] - # - name: Install lowest dependencies from - # run: composer update --with-dependencies --prefer-stable --prefer-dist --prefer-lowest - # if: ${{ matrix.dependencies }} == "oldest" - name: Set up database schema run: mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u${{ env.DB_USERNAME }} -p${{ env.DB_PASSWORD }} ${{ env.DB_DATABASE }} < vendor/phplist/core/resources/Database/Schema.sql - continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8] - name: Validating composer.json run: composer validate --no-check-all --no-check-lock --strict; - continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8] - name: Linting all php files run: find src/ tests/ public/ -name ''*.php'' -print0 | xargs -0 -n 1 -P 4 php -l; php -l; - name: Running integration tests with phpunit run: vendor/bin/phpunit tests/Integration/; - continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8] - name: Running the system tests run: vendor/bin/phpunit tests/System/; - continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8] - name: Running static analysis run: vendor/bin/phpstan analyse -l 5 src/ tests/; - continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8] - name: Running PHPMD run: vendor/bin/phpmd src/ text vendor/phplist/core/config/PHPMD/rules.xml; - continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8] - name: Running PHP_CodeSniffer run: vendor/bin/phpcs --standard=vendor/phplist/core/config/PhpCodeSniffer/ src/ tests/; - continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8] \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9cd86d7..8bf5efa 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ /public/ /var/ /vendor/ +.phpunit.result.cache diff --git a/CHANGELOG.md b/CHANGELOG.md index d6f9c57..cbfb13f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ This project adheres to [Semantic Versioning](https://semver.org/). ### Fixed +## 5.0.0-alpha1 + +### Changed +- updated to php8.1 + ## 4.0.0-alpha2 ### Added diff --git a/composer.json b/composer.json index a7ea5ca..93b8650 100644 --- a/composer.json +++ b/composer.json @@ -33,14 +33,14 @@ "phplist/core": "dev-ISSUE-337" }, "require-dev": { - "phpunit/phpunit": "^9.5.2", - "phpunit/phpunit-mock-objects": "^6.1.2", + "phpunit/phpunit": "^9.5", "guzzlehttp/guzzle": "^7.2.0", "squizlabs/php_codesniffer": "^3.5.8", - "phpstan/phpstan": " ^0.12.57", + "phpstan/phpstan": "^1.10", "nette/caching": "^3.1.0", "nikic/php-parser": "^v4.10.4", - "phpmd/phpmd": "^2.9.1" + "phpmd/phpmd": "^2.9.1", + "symfony/process": "^6.4" }, "autoload": { "psr-4": { @@ -52,15 +52,6 @@ "PhpList\\WebFrontend\\Tests\\": "tests/" } }, - "repositories": [ - { - "type": "path", - "url": "../core", - "options": { - "symlink": true - } - } - ], "scripts": { "list-modules": [ "PhpList\\Core\\Composer\\ScriptHandler::listModules" @@ -87,7 +78,7 @@ }, "extra": { "branch-alias": { - "dev-ISSUE-337": "v5.0.x-dev" + "dev-ISSUE-337": "5.0.x-dev" }, "symfony-app-dir": "bin", "symfony-bin-dir": "bin", diff --git a/tests/Integration/Composer/ScriptsTest.php b/tests/Integration/Composer/ScriptsTest.php index 8d4d915..01afaf0 100644 --- a/tests/Integration/Composer/ScriptsTest.php +++ b/tests/Integration/Composer/ScriptsTest.php @@ -1,4 +1,5 @@ getAbsolutePublicDirectoryPath()); - } - - /** - * @return string - */ - private function getAbsolutePublicDirectoryPath(): string - { - return dirname(__DIR__, 3) . '/public/'; - } - - /** - * @return string[][] - */ - public function publicDirectoryFilesDataProvider(): array - { - return [ - 'production entry point' => ['app.php'], - 'development entry point' => ['app_dev.php'], - 'testing entry point' => ['app_test.php'], - '.htaccess' => ['.htaccess'], - ]; - } - - /** - * @test - * @param string $fileName - * @dataProvider publicDirectoryFilesDataProvider - */ - public function publicDirectoryFilesExist(string $fileName) - { - static::assertFileExists($this->getAbsolutePublicDirectoryPath() . $fileName); - } - - /** - * @test - */ - public function binariesDirectoryHasBeenCreated() + private function getBundleConfigurationFilePath(): string { - static::assertDirectoryExists($this->getAbsoluteBinariesDirectoryPath()); + return dirname(__DIR__, 3) . '/config/bundles.yml'; } - /** - * @return string - */ - private function getAbsoluteBinariesDirectoryPath(): string + public function testBundleConfigurationFileExists(): void { - return dirname(__DIR__, 3) . '/bin/'; + self::assertFileExists($this->getBundleConfigurationFilePath()); } - /** - * @return string[][] - */ - public function binariesDataProvider(): array + public function bundleClassNameDataProvider(): array { return [ - 'Symfony console' => ['console'], + 'Symfony framework bundle' => ['Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'], + 'Doctrine bundle' => ['Doctrine\\Bundle\\DoctrineBundle\\DoctrineBundle'], + 'empty start page bundle' => ['PhpList\\Core\\EmptyStartPageBundle\\EmptyStartPageBundle'], ]; } /** - * @test - * @param string $fileName - * @dataProvider binariesDataProvider + * @dataProvider bundleClassNameDataProvider */ - public function binariesExist(string $fileName) + public function testBundleConfigurationFileContainsModuleBundles(string $bundleClassName): void { - static::assertFileExists($this->getAbsoluteBinariesDirectoryPath() . $fileName); + $fileContents = file_get_contents($this->getBundleConfigurationFilePath()); + self::assertStringContainsString($bundleClassName, $fileContents); } - /** - * @return string - */ - private function getBundleConfigurationFilePath(): string + private function getModuleRoutesConfigurationFilePath(): string { - return dirname(__DIR__, 3) . '/config/bundles.yml'; + return dirname(__DIR__, 3) . '/config/routing_modules.yml'; } - /** - * @test - */ - public function bundleConfigurationFileExists() + public function testModuleRoutesConfigurationFileExists(): void { - static::assertFileExists($this->getBundleConfigurationFilePath()); + self::assertFileExists($this->getModuleRoutesConfigurationFilePath()); } - /** - * @return string[][] - */ - public function bundleClassNameDataProvider(): array + public function moduleRoutingDataProvider(): array { return [ - 'framework bundle' => ['Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'], + 'route name' => ['phplist/core.homepage'], + 'resource' => ["resource: '@EmptyStartPageBundle/Controller/'"], + 'type' => ['type: attribute'], ]; } /** - * @test - * @param string $bundleClassName - * @dataProvider bundleClassNameDataProvider - */ - public function bundleConfigurationFileContainsModuleBundles(string $bundleClassName) - { - $fileContents = file_get_contents($this->getBundleConfigurationFilePath()); - - static::assertContains($bundleClassName, $fileContents); - } - - /** - * @return string - */ - private function getModuleRoutesConfigurationFilePath(): string - { - return dirname(__DIR__, 3) . '/config/routing_modules.yml'; - } - - /** - * @test + * @dataProvider moduleRoutingDataProvider */ - public function moduleRoutesConfigurationFileExists() + public function testModuleRoutesConfigurationFileContainsModuleRoutes(string $routeSearchString): void { - static::assertFileExists($this->getModuleRoutesConfigurationFilePath()); + $fileContents = file_get_contents($this->getModuleRoutesConfigurationFilePath()); + self::assertStringContainsString($routeSearchString, $fileContents); } - /** - * @test - */ - public function parametersConfigurationFileExists() + public function testParametersConfigurationFileExists(): void { - static::assertFileExists(dirname(__DIR__, 3) . '/config/parameters.yml'); + self::assertFileExists(dirname(__DIR__, 3) . '/config/parameters.yml'); } - /** - * @test - */ - public function modulesConfigurationFileExists() + public function testModulesConfigurationFileExists(): void { - static::assertFileExists(dirname(__DIR__, 3) . '/config/config_modules.yml'); + self::assertFileExists(dirname(__DIR__, 3) . '/config/config_modules.yml'); } } diff --git a/tests/System/ApplicationBundle/PhpListApplicationBundleTest.php b/tests/System/ApplicationBundle/PhpListApplicationBundleTest.php index 1588c7e..7504ebe 100644 --- a/tests/System/ApplicationBundle/PhpListApplicationBundleTest.php +++ b/tests/System/ApplicationBundle/PhpListApplicationBundleTest.php @@ -1,4 +1,5 @@ httpClient = new Client(['http_errors' => false]); } - protected function tearDown() + protected function tearDown(): void { $this->stopSymfonyServer(); + $this->httpClient = null; + parent::tearDown(); } - /** - * @return string[][] - */ - public function environmentDataProvider(): array - { - return [ - 'test' => ['test'], - 'dev' => ['dev'], - ]; - } - - /** - * @test - * @param string $environment - * @dataProvider environmentDataProvider - */ - public function homepageReturnsSuccess(string $environment) + public function testHomepageReturnsSuccess(): void { - $this->startSymfonyServer($environment); - - $response = $this->httpClient->get('/', ['base_uri' => $this->getBaseUrl()]); - - static::assertSame(200, $response->getStatusCode()); - } - - /** - * @test - * @param string $environment - * @dataProvider environmentDataProvider - */ - public function homepageReturnsContent(string $environment) - { - $this->startSymfonyServer($environment); - - $response = $this->httpClient->get('/', ['base_uri' => $this->getBaseUrl()]); - - static::assertNotEmpty($response->getBody()->getContents()); + $this->startSymfonyServer(); + $response = $this->httpClient->get('/api/v2', [ + 'base_uri' => $this->getBaseUrl(), + ]); + + self::assertSame(200, $response->getStatusCode()); + self::assertStringContainsString( + 'This page has been intentionally left empty.', + $response->getBody()->getContents() + ); } }