Skip to content

Commit

Permalink
Merge pull request #63 from novaway/feat-symfony7-compatibility
Browse files Browse the repository at this point in the history
Symfony 7 compatibility
  • Loading branch information
jdecool authored Oct 27, 2023
2 parents 1f917ea + 0be109e commit 7c74981
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 100 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
- name: Run PHP CS Fixer
run: tools/vendor/bin/php-cs-fixer fix --dry-run --diff


phpstan:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -61,7 +60,10 @@ jobs:
matrix:
php: ['8.1', '8.2']
flags: ['--prefer-lowest', '--prefer-stable']
symfony-version: ['5.4.*', '6.0.*', '6.1.*', '6.2.*', '6.3.*']
symfony-version: ['5.4.*', '6.0.*', '6.1.*', '6.2.*', '6.3.*', '6.4.*']
include:
- php: '8.2'
symfony-version: '7.0.*'
fail-fast: false
steps:
- name: Checkout
Expand All @@ -80,6 +82,9 @@ jobs:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Setup Composer minimum stability if required
run: composer config minimum-stability dev
if: ${{ contains(fromJSON('["6.4.*", "7.0.*"]'), matrix.symfony-version) }}
- name: Install symfony version from matrix
env:
SYMFONY_VERSION: ${{ matrix.symfony-version }}
Expand Down
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
"require": {
"php": ">= 8.1",
"ext-json": "*",
"symfony/console": "^5.4|^6.0",
"symfony/framework-bundle": "^5.4|^6.0",
"symfony/options-resolver": "^5.4|^6.0"
"symfony/console": "^5.4|^6.0|^7.0",
"symfony/framework-bundle": "^5.4|^6.0|^7.0",
"symfony/options-resolver": "^5.4|^6.0|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^10.1",
"symfony/asset": "^5.4|^6.0",
"symfony/browser-kit": "^5.4|^6.0",
"symfony/css-selector": "^5.4|^6.0",
"symfony/expression-language": "^5.4|^6.0",
"symfony/templating": "^5.4|^6.0",
"symfony/twig-bundle": "^5.4|^6.0",
"symfony/yaml": "^5.4|^6.0",
"twig/twig": "^2.0|^3.0"
"symfony/asset": "^5.4|^6.0|^7.0",
"symfony/browser-kit": "^5.4|^6.0|^7.0",
"symfony/css-selector": "^5.4|^6.0|^7.0",
"symfony/expression-language": "^5.4|^6.0|^7.0",
"symfony/templating": "^5.4|^6.0|^7.0",
"symfony/twig-bundle": "^5.4|^6.0|^7.0",
"symfony/yaml": "^5.4|^6.0|^7.0",
"twig/twig": "^3.0"
},
"suggest": {
"twig/twig": "To check feature in your Twig templates"
Expand Down
8 changes: 4 additions & 4 deletions coverage_badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
failOnWarning="true"
colors="true"
cacheDirectory=".phpunit.cache">
<php>
<env name="KERNEL_CLASS" value="Novaway\Bundle\FeatureFlagBundle\Tests\Fixtures\App\AppKernel"/>
<env name="APP_ENV" value="test"/>
</php>

<testsuites>
<testsuite name="unit">
<directory>tests/Unit</directory>
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Command/ListFeatureCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

namespace Novaway\Bundle\FeatureFlagBundle\Tests\Functional\Command;

use Novaway\Bundle\FeatureFlagBundle\Tests\Functional\WebTestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Command\Command;

final class ListFeatureCommandTest extends WebTestCase
final class ListFeatureCommandTest extends KernelTestCase
{
public function testCommandIsAvailable(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@

namespace Novaway\Bundle\FeatureFlagBundle\Tests\Functional\Controller;

use Novaway\Bundle\FeatureFlagBundle\Tests\Functional\WebTestCase;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

final class AttributeClassDisabledControllerTest extends WebTestCase
{
public function testAttributeFooDisabledAction(): void
{
static::$client->request('GET', '/attribute/class/disabled');
$response = static::$client->getResponse();
$client = static::createClient();
$client->request('GET', '/attribute/class/disabled');
$response = $client->getResponse();

static::assertFalse($response->isSuccessful());
static::assertSame(404, $response->getStatusCode());
Expand Down
27 changes: 16 additions & 11 deletions tests/Functional/Controller/CustomExceptionControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,47 @@

namespace Novaway\Bundle\FeatureFlagBundle\Tests\Functional\Controller;

use Novaway\Bundle\FeatureFlagBundle\Tests\Functional\WebTestCase;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

final class CustomExceptionControllerTest extends WebTestCase
{
public function testFoo(): void
{
static::$client->request('GET', '/configuration/custom_exception/disabled');
$client = static::createClient();
$client->request('GET', '/configuration/custom_exception/disabled');

static::assertSame(410, static::$client->getResponse()->getStatusCode());
static::assertSame(410, $client->getResponse()->getStatusCode());
}

public function testIsFeatureDisableAttributeWithCustomException(): void
{
static::$client->request('GET', '/attribute/custom_exception/disabled');
$client = static::createClient();
$client->request('GET', '/attribute/custom_exception/disabled');

static::assertSame(400, static::$client->getResponse()->getStatusCode());
static::assertSame(400, $client->getResponse()->getStatusCode());
}

public function testIsFeatureEnableAttributeWithCustomException(): void
{
static::$client->request('GET', '/attribute/custom_exception/enabled');
$client = static::createClient();
$client->request('GET', '/attribute/custom_exception/enabled');

static::assertSame(409, static::$client->getResponse()->getStatusCode());
static::assertSame(409, $client->getResponse()->getStatusCode());
}

public function testIsFeatureDisableAttributeWithCustomExceptionFactory(): void
{
static::$client->request('GET', '/attribute/custom_exception_factory/disabled');
$client = static::createClient();
$client->request('GET', '/attribute/custom_exception_factory/disabled');

static::assertSame(423, static::$client->getResponse()->getStatusCode());
static::assertSame(423, $client->getResponse()->getStatusCode());
}

public function testIsFeatureEnableAttributeWithCustomExceptionFactory(): void
{
static::$client->request('GET', '/attribute/custom_exception_factory/enabled');
$client = static::createClient();
$client->request('GET', '/attribute/custom_exception_factory/enabled');

static::assertSame(411, static::$client->getResponse()->getStatusCode());
static::assertSame(411, $client->getResponse()->getStatusCode());
}
}
32 changes: 19 additions & 13 deletions tests/Functional/Controller/DefaultControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@

namespace Novaway\Bundle\FeatureFlagBundle\Tests\Functional\Controller;

use Novaway\Bundle\FeatureFlagBundle\Tests\Functional\WebTestCase;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

final class DefaultControllerTest extends WebTestCase
{
public function testFeatureEnabled(): void
{
$crawler = static::$client->request('GET', '/features');
static::assertTrue(static::$client->getResponse()->isSuccessful());
$client = static::createClient();
$crawler = $client->request('GET', '/features');
static::assertTrue($client->getResponse()->isSuccessful());

static::assertGreaterThan(
0,
Expand All @@ -33,8 +34,9 @@ public function testFeatureEnabled(): void

public function testFeatureDisabled(): void
{
$crawler = static::$client->request('GET', '/features');
static::assertTrue(static::$client->getResponse()->isSuccessful());
$client = static::createClient();
$crawler = $client->request('GET', '/features');
static::assertTrue($client->getResponse()->isSuccessful());

static::assertSame(
0,
Expand All @@ -49,9 +51,10 @@ public function testFeatureDisabled(): void

public function testRequestFooEnabled(): void
{
$crawler = static::$client->request('GET', '/request/enabled');
$client = static::createClient();
$crawler = $client->request('GET', '/request/enabled');

static::assertSame(200, static::$client->getResponse()->getStatusCode());
static::assertSame(200, $client->getResponse()->getStatusCode());
static::assertGreaterThan(
0,
$crawler->filter('html:contains("DefaultController::requestFooEnabledAction")')->count(),
Expand All @@ -60,16 +63,18 @@ public function testRequestFooEnabled(): void

public function testRequestFooDisabled(): void
{
static::$client->request('GET', '/request/disabled');
$client = static::createClient();
$client->request('GET', '/request/disabled');

static::assertSame(404, static::$client->getResponse()->getStatusCode());
static::assertSame(404, $client->getResponse()->getStatusCode());
}

public function testAttributeFooEnabledAction(): void
{
$crawler = static::$client->request('GET', '/attribute/enabled');
$client = static::createClient();
$crawler = $client->request('GET', '/attribute/enabled');

static::assertSame(200, static::$client->getResponse()->getStatusCode());
static::assertSame(200, $client->getResponse()->getStatusCode());
static::assertGreaterThan(
0,
$crawler->filter('html:contains("DefaultController::attributeRouteIsAccessibleIfFeatureIsEnabled")')->count(),
Expand All @@ -78,8 +83,9 @@ public function testAttributeFooEnabledAction(): void

public function testAttributeFooDisabledAction(): void
{
static::$client->request('GET', '/attribute/disabled');
$client = static::createClient();
$client->request('GET', '/attribute/disabled');

static::assertSame(404, static::$client->getResponse()->getStatusCode());
static::assertSame(404, $client->getResponse()->getStatusCode());
}
}
2 changes: 2 additions & 0 deletions tests/Functional/TwigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Novaway\Bundle\FeatureFlagBundle\Tests\Functional;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

final class TwigTest extends WebTestCase
{
public function testTwigRenderWithFeatureEnable(): void
Expand Down
54 changes: 0 additions & 54 deletions tests/Functional/WebTestCase.php

This file was deleted.

0 comments on commit 7c74981

Please sign in to comment.