Skip to content

Commit

Permalink
Merge pull request #526 from alexislefebvre/revert-add-compatibility-…
Browse files Browse the repository at this point in the history
…for-symfony-4.3.0-512

[3.x] Revert add compatibility for symfony 4.3.0 512
  • Loading branch information
alexislefebvre committed Jun 12, 2019
2 parents fd3383b + cad5563 commit 63ff8eb
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 75 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ matrix:
env: SYMFONY_VERSION="^4.1"
- php: 7.3
env: SYMFONY_VERSION="^4.1"
- php: 7.3
env: SYMFONY_VERSION="^4.3@beta"
allow_failures:
- php: 7.2
env: SYMFONY_VERSION="dev-master"
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
"symfony/symfony": "^3.4 || ^4.1",
"twig/twig": "^2.0"
},
"conflict": {
"symfony/framework-bundle": "4.3.0"
},
"suggest": {
"brianium/paratest": "Required when using paratest to parallelize tests",
"doctrine/dbal": "Required when using the fixture loading functionality with an ORM and SQLite",
Expand Down
6 changes: 0 additions & 6 deletions src/DependencyInjection/Compiler/SetTestClientPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ public function process(ContainerBuilder $container): void
$definition = $container->getDefinition('test.client');
$definition->setPublic(false);
$container->setDefinition('liip_functional_test.query.count_client.parent', $definition);
} elseif ($container->hasAlias('test.client')) {
// Symfony <2.8
$container->setAlias(
'liip_functional_test.query.count_client.parent',
new Alias((string) $container->getAlias('test.client'), false)
);
} else {
throw new \Exception('The LiipFunctionalTestBundle\'s Query Counter can only be used in the test environment.'.PHP_EOL.'See https://github.com/liip/LiipFunctionalTestBundle#only-in-test-environment');
}
Expand Down
8 changes: 7 additions & 1 deletion src/QueryCountClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@

use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;

// Symfony <4 BC
if (class_exists(CompilerDebugDumpPass::class)) {
class_alias(QueryCountClientSymfony3Trait::class, QueryCountClientTrait::class);
}

class QueryCountClient extends Client
// Symfony <4.3.1 BC
if (!class_exists(KernelBrowser::class)) {
class_alias(Client::class, KernelBrowser::class);
}

class QueryCountClient extends KernelBrowser
{
/*
* We use trait only because of Client::request signature strict type mismatch between Symfony 3 and 4.
Expand Down
10 changes: 1 addition & 9 deletions src/Test/WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
*/
abstract class WebTestCase extends BaseWebTestCase
{
/** @var Client|null */
protected static $client;

protected $environment = 'test';

protected $containers;
Expand Down Expand Up @@ -472,11 +469,6 @@ protected function createClientWithParams(array $params, ?string $username = nul
$session->save();
}

return static::$client = $client;
return $client;
}
}

// Compatibility layer for Symfony 4.3+
if (class_exists('Symfony\Bundle\FrameworkBundle\KernelBrowser')) {
class_alias('Symfony\Bundle\FrameworkBundle\KernelBrowser', 'Symfony\Bundle\FrameworkBundle\Client');
}
4 changes: 2 additions & 2 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class ConfigurationTest extends WebTestCase

public function setUp(): void
{
static::$client = $this->makeClient();
$this->clientContainer = static::$client->getContainer();
$client = static::makeClient();
$this->clientContainer = $client->getContainer();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Test/WebTestCaseConfigLeanFrameworkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected static function getKernelClass(): string

public function testAssertStatusCode(): void
{
$client = $this->makeClient();
$client = static::makeClient();

$path = '/';
$client->request('GET', $path);
Expand All @@ -45,7 +45,7 @@ public function testAssertStatusCode(): void

public function testAssertValidationErrorsTriggersError(): void
{
$client = $this->makeClient();
$client = static::makeClient();

$path = '/form';
$client->request('GET', $path);
Expand Down
29 changes: 16 additions & 13 deletions tests/Test/WebTestCaseConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class WebTestCaseConfigTest extends WebTestCase
{
use LiipAcmeFixturesTrait;

/** @var \Symfony\Bundle\FrameworkBundle\Client client */
private $client = null;

protected static function getKernelClass(): string
{
return AppConfigKernel::class;
Expand All @@ -48,13 +51,13 @@ protected static function getKernelClass(): string
*/
public function testIndexClientWithCredentials(): void
{
static::$client = static::makeClientWithCredentials('foobar', '12341234');
$this->client = static::makeClientWithCredentials('foobar', '12341234');

$path = '/';

$crawler = static::$client->request('GET', $path);
$crawler = $this->client->request('GET', $path);

$this->assertStatusCode(200, static::$client);
$this->assertStatusCode(200, $this->client);

$this->assertSame(1,
$crawler->filter('html > body')->count());
Expand All @@ -77,13 +80,13 @@ public function testIndexClientWithCredentials(): void
*/
public function testIndexAuthenticatedClient(): void
{
static::$client = static::makeAuthenticatedClient();
$this->client = static::makeAuthenticatedClient();

$path = '/';

$crawler = static::$client->request('GET', $path);
$crawler = $this->client->request('GET', $path);

$this->assertStatusCode(200, static::$client);
$this->assertStatusCode(200, $this->client);

$this->assertSame(1,
$crawler->filter('html > body')->count());
Expand Down Expand Up @@ -114,13 +117,13 @@ public function testIndexAuthenticationLoginAs(): void
$loginAs
);

static::$client = $this->makeClient();
$this->client = static::makeClient();

$path = '/';

$crawler = static::$client->request('GET', $path);
$crawler = $this->client->request('GET', $path);

$this->assertStatusCode(200, static::$client);
$this->assertStatusCode(200, $this->client);

$this->assertSame(1,
$crawler->filter('html > body')->count());
Expand Down Expand Up @@ -152,12 +155,12 @@ public function testAllowedQueriesExceededException(): void

$this->loginAs($user, 'secured_area');

static::$client = $this->makeClient();
$this->client = static::makeClient();

// One another query to load the second user.
$path = '/user/2';

static::$client->request('GET', $path);
$this->client->request('GET', $path);
}

/**
Expand All @@ -172,11 +175,11 @@ public function testAllowedQueriesExceededException(): void
*/
public function testAnnotationAndException(): void
{
static::$client = $this->makeClient();
$this->client = static::makeClient();

// One query to load the second user
$path = '/user/1';

static::$client->request('GET', $path);
$this->client->request('GET', $path);
}
}
Loading

0 comments on commit 63ff8eb

Please sign in to comment.