diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 90ae313..0000000 --- a/.coveralls.yml +++ /dev/null @@ -1,2 +0,0 @@ -service_name: travis-ci -coverage_clover: build/logs/clover.xml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..6372bdb --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,41 @@ +name: Tests + +on: + pull_request: + push: + branches: + - master + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} + +jobs: + + tests: + runs-on: ubuntu-24.04 + strategy: + matrix: + php-versions: [ '8.2', '8.3', '8.4' ] + symfony-version: ['5.4.*', '6.4.*', '7.2.*'] + fail-fast: false + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + + - name: Configure Symfony + run: composer config extra.symfony.require "${{ matrix.symfony-version }}" + + - name: Update project dependencies + run: composer update --no-progress --ansi --prefer-stable + + - name: Composer install + run: composer install --no-scripts --no-interaction --prefer-dist -oa + + - name: Run Phpunit + run: ./vendor/bin/phpunit diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 635d7f0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: php - -php: - - "7.1" - - "7.2" - - "7.3" - -env: - - SYMFONY_VERSION=3.4.* - - SYMFONY_VERSION=4.0.* - - SYMFONY_VERSION=4.1.* - - SYMFONY_VERSION=4.2.* - - SYMFONY_VERSION=4.3.* - -before_script: - - composer self-update - - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/http-kernel:${SYMFONY_VERSION}" --no-update; fi; - - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/dependency-injection:${SYMFONY_VERSION}" --no-update; fi; - - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/config:${SYMFONY_VERSION}" --no-update; fi; - - composer update --no-scripts --no-interaction - - composer dump-autoload -o - -after_script: - - php vendor/bin/coveralls -v - -script: - - ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 2d5c6eb..35744f1 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -13,7 +13,7 @@ class Configuration implements ConfigurationInterface /** * @inheritdoc */ - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('openclassrooms_akismet'); $rootNode = $treeBuilder->getRootNode(); diff --git a/DependencyInjection/OpenClassroomsAkismetExtension.php b/DependencyInjection/OpenClassroomsAkismetExtension.php index ec751e6..a94ba8c 100644 --- a/DependencyInjection/OpenClassroomsAkismetExtension.php +++ b/DependencyInjection/OpenClassroomsAkismetExtension.php @@ -29,7 +29,7 @@ public function load(array $config, ContainerBuilder $container) /** * @inheritdoc */ - public function getAlias() + public function getAlias(): string { return 'openclassrooms_akismet'; } diff --git a/OpenClassroomsAkismetBundle.php b/OpenClassroomsAkismetBundle.php index bc69fb7..8bfeca9 100644 --- a/OpenClassroomsAkismetBundle.php +++ b/OpenClassroomsAkismetBundle.php @@ -13,7 +13,7 @@ class OpenClassroomsAkismetBundle extends Bundle /** * @inheritdoc */ - public function getContainerExtension() + public function getContainerExtension(): OpenClassroomsAkismetExtension { return new OpenClassroomsAkismetExtension(); } diff --git a/Services/Impl/AkismetServiceImpl.php b/Services/Impl/AkismetServiceImpl.php index 3603c1f..fa5369e 100644 --- a/Services/Impl/AkismetServiceImpl.php +++ b/Services/Impl/AkismetServiceImpl.php @@ -19,7 +19,7 @@ public function commentCheck(Comment $comment): bool private function completeComment(Comment $comment): Comment { - $request = $this->requestStack->getMasterRequest(); + $request = $this->requestStack->getMainRequest(); if (null === $request) { return $comment; diff --git a/Tests/DependencyInjection/OpenClassroomsAkismetExtensionTest.php b/Tests/DependencyInjection/OpenClassroomsAkismetExtensionTest.php index de38d66..d793a20 100644 --- a/Tests/DependencyInjection/OpenClassroomsAkismetExtensionTest.php +++ b/Tests/DependencyInjection/OpenClassroomsAkismetExtensionTest.php @@ -4,6 +4,7 @@ use OpenClassrooms\Bundle\AkismetBundle\OpenClassroomsAkismetBundle; use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; @@ -26,30 +27,33 @@ class OpenClassroomsAkismetExtensionTest extends TestCase /** * @test - * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ public function NoConfiguration_ThrowException() { + $this->expectException(InvalidConfigurationException::class); + $this->configLoader->load('empty_config.yml'); $this->container->compile(); } /** * @test - * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ public function WithoutBlogUrlConfiguration_ThrowException() { + $this->expectException(InvalidConfigurationException::class); + $this->configLoader->load('without_blog_url_config.yml'); $this->container->compile(); } /** * @test - * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ public function WithoutApiKeyConfiguration_ThrowException() { + $this->expectException(InvalidConfigurationException::class); + $this->configLoader->load('without_api_key_config.yml'); $this->container->compile(); } @@ -84,7 +88,7 @@ public function assertAkismetService() $this->assertTrue($this->container->has('openclassrooms.akismet.services.akismet_service')); } - protected function setUp() + protected function setUp(): void { $bundle = new OpenClassroomsAkismetBundle(); diff --git a/Tests/Services/Impl/AkismetServiceImplTest.php b/Tests/Services/Impl/AkismetServiceImplTest.php index 1c0ee9f..56e3d70 100644 --- a/Tests/Services/Impl/AkismetServiceImplTest.php +++ b/Tests/Services/Impl/AkismetServiceImplTest.php @@ -109,7 +109,7 @@ public function submitHam() $this->assertCommentCheckParams(); } - protected function setUp() + protected function setUp(): void { $this->akismetService = new AkismetServiceImpl(); $this->akismetService->setAkismet($this->buildAkismet()); diff --git a/composer.json b/composer.json index bfc57bd..ee05a5a 100644 --- a/composer.json +++ b/composer.json @@ -24,15 +24,15 @@ } }, "require": { - "php": ">=7.4", - "symfony/http-kernel": "~3.4 || ~4.0 || ~5.0 || ~6.0", - "symfony/dependency-injection": "~3.4 || ~4.0 || ~5.0 || ~6.0", - "symfony/config": "~3.4 || ~4.0 || ~5.0 || ~6.0", + "php": ">=8.2", + "symfony/http-kernel": "~5.4 || ~6.0 || ~7.0", + "symfony/dependency-injection": "~5.4 || ~6.0 || ~7.0", + "symfony/config": "~5.4 || ~6.0 || ~7.0", "openclassrooms/akismet": "~2.0" }, "require-dev": { - "phpunit/phpunit": "~7", - "satooshi/php-coveralls": "~2.1" + "phpunit/phpunit": "~9.5", + "symfony/yaml": "~5.4 || ~6.0 || ~7.0" }, "extra": { "branch-alias": {