Skip to content

Commit 6844b7c

Browse files
authored
Merge pull request #7 from OpenClassrooms/fix_sf6_compatibility
Improve sf6 compatibility
2 parents e4d60a7 + 02f9760 commit 6844b7c

10 files changed

Lines changed: 60 additions & 44 deletions

File tree

.coveralls.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
12+
13+
jobs:
14+
15+
tests:
16+
runs-on: ubuntu-24.04
17+
strategy:
18+
matrix:
19+
php-versions: [ '8.2', '8.3', '8.4' ]
20+
symfony-version: ['5.4.*', '6.4.*', '7.2.*']
21+
fail-fast: false
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Setup PHP, with composer and extensions
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php-versions }}
29+
coverage: none
30+
31+
- name: Configure Symfony
32+
run: composer config extra.symfony.require "${{ matrix.symfony-version }}"
33+
34+
- name: Update project dependencies
35+
run: composer update --no-progress --ansi --prefer-stable
36+
37+
- name: Composer install
38+
run: composer install --no-scripts --no-interaction --prefer-dist -oa
39+
40+
- name: Run Phpunit
41+
run: ./vendor/bin/phpunit

.travis.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Configuration implements ConfigurationInterface
1313
/**
1414
* @inheritdoc
1515
*/
16-
public function getConfigTreeBuilder()
16+
public function getConfigTreeBuilder(): TreeBuilder
1717
{
1818
$treeBuilder = new TreeBuilder('openclassrooms_akismet');
1919
$rootNode = $treeBuilder->getRootNode();

DependencyInjection/OpenClassroomsAkismetExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function load(array $config, ContainerBuilder $container)
2929
/**
3030
* @inheritdoc
3131
*/
32-
public function getAlias()
32+
public function getAlias(): string
3333
{
3434
return 'openclassrooms_akismet';
3535
}

OpenClassroomsAkismetBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class OpenClassroomsAkismetBundle extends Bundle
1313
/**
1414
* @inheritdoc
1515
*/
16-
public function getContainerExtension()
16+
public function getContainerExtension(): OpenClassroomsAkismetExtension
1717
{
1818
return new OpenClassroomsAkismetExtension();
1919
}

Services/Impl/AkismetServiceImpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function commentCheck(Comment $comment): bool
1919

2020
private function completeComment(Comment $comment): Comment
2121
{
22-
$request = $this->requestStack->getMasterRequest();
22+
$request = $this->requestStack->getMainRequest();
2323

2424
if (null === $request) {
2525
return $comment;

Tests/DependencyInjection/OpenClassroomsAkismetExtensionTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use OpenClassrooms\Bundle\AkismetBundle\OpenClassroomsAkismetBundle;
66
use PHPUnit\Framework\TestCase;
7+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
78
use Symfony\Component\Config\FileLocator;
89
use Symfony\Component\DependencyInjection\ContainerBuilder;
910
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
@@ -26,30 +27,33 @@ class OpenClassroomsAkismetExtensionTest extends TestCase
2627

2728
/**
2829
* @test
29-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
3030
*/
3131
public function NoConfiguration_ThrowException()
3232
{
33+
$this->expectException(InvalidConfigurationException::class);
34+
3335
$this->configLoader->load('empty_config.yml');
3436
$this->container->compile();
3537
}
3638

3739
/**
3840
* @test
39-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
4041
*/
4142
public function WithoutBlogUrlConfiguration_ThrowException()
4243
{
44+
$this->expectException(InvalidConfigurationException::class);
45+
4346
$this->configLoader->load('without_blog_url_config.yml');
4447
$this->container->compile();
4548
}
4649

4750
/**
4851
* @test
49-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
5052
*/
5153
public function WithoutApiKeyConfiguration_ThrowException()
5254
{
55+
$this->expectException(InvalidConfigurationException::class);
56+
5357
$this->configLoader->load('without_api_key_config.yml');
5458
$this->container->compile();
5559
}
@@ -84,7 +88,7 @@ public function assertAkismetService()
8488
$this->assertTrue($this->container->has('openclassrooms.akismet.services.akismet_service'));
8589
}
8690

87-
protected function setUp()
91+
protected function setUp(): void
8892
{
8993
$bundle = new OpenClassroomsAkismetBundle();
9094

Tests/Services/Impl/AkismetServiceImplTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function submitHam()
109109
$this->assertCommentCheckParams();
110110
}
111111

112-
protected function setUp()
112+
protected function setUp(): void
113113
{
114114
$this->akismetService = new AkismetServiceImpl();
115115
$this->akismetService->setAkismet($this->buildAkismet());

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
}
2525
},
2626
"require": {
27-
"php": ">=7.4",
28-
"symfony/http-kernel": "~3.4 || ~4.0 || ~5.0 || ~6.0",
29-
"symfony/dependency-injection": "~3.4 || ~4.0 || ~5.0 || ~6.0",
30-
"symfony/config": "~3.4 || ~4.0 || ~5.0 || ~6.0",
27+
"php": ">=8.2",
28+
"symfony/http-kernel": "~5.4 || ~6.0 || ~7.0",
29+
"symfony/dependency-injection": "~5.4 || ~6.0 || ~7.0",
30+
"symfony/config": "~5.4 || ~6.0 || ~7.0",
3131
"openclassrooms/akismet": "~2.0"
3232
},
3333
"require-dev": {
34-
"phpunit/phpunit": "~7",
35-
"satooshi/php-coveralls": "~2.1"
34+
"phpunit/phpunit": "~9.5",
35+
"symfony/yaml": "~5.4 || ~6.0 || ~7.0"
3636
},
3737
"extra": {
3838
"branch-alias": {

0 commit comments

Comments
 (0)