Skip to content

Commit

Permalink
Merge pull request #519 from izisolutions/feature/cherry-pick-4.3
Browse files Browse the repository at this point in the history
Feature/cherry pick 4.3
  • Loading branch information
alexislefebvre authored Jun 5, 2019
2 parents 76c3fd3 + 072fa22 commit 464c7a2
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 76 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ matrix:
env: EXTRA_PACKAGES="doctrine/phpcr-bundle:^1.3 brianium/paratest:^1.0 doctrine/phpcr-odm:^1.3"
- php: 7.3
env: SYMFONY_VERSION="^4.1"
- php: 7.3
env: SYMFONY_VERSION="^4.3"
allow_failures:
- php: 7.2
env: SYMFONY_VERSION="dev-master"
Expand Down
10 changes: 9 additions & 1 deletion src/Test/WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
*/
abstract class WebTestCase extends BaseWebTestCase
{
/** @var Client|null */
protected static $client;

protected $environment = 'test';

protected $containers;
Expand Down Expand Up @@ -410,7 +413,7 @@ protected function makeClient($authentication = false, array $params = []): Clie
$session->save();
}

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

/**
Expand Down Expand Up @@ -568,3 +571,8 @@ protected function tearDown(): void
parent::tearDown();
}
}

// 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
{
$client = static::makeClient();
$this->clientContainer = $client->getContainer();
static::$client = $this->makeClient();
$this->clientContainer = static::$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 = static::makeClient();
$client = $this->makeClient();

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

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

$path = '/form';
$client->request('GET', $path);
Expand Down
30 changes: 13 additions & 17 deletions tests/Test/WebTestCaseConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
*/
class WebTestCaseConfigTest extends WebTestCase
{
/** @var \Symfony\Bundle\FrameworkBundle\Client client */
private $client = null;

protected static function getKernelClass(): string
{
return AppConfigKernel::class;
Expand All @@ -51,16 +48,16 @@ public function testIndexAuthenticationArray(): void
{
$this->loadFixtures([]);

$this->client = static::makeClient([
static::$client = $this->makeClient([
'username' => 'foobar',
'password' => '12341234',
]);

$path = '/';

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

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

$this->assertSame(1,
$crawler->filter('html > body')->count());
Expand All @@ -85,13 +82,13 @@ public function testIndexAuthenticationTrue(): void
{
$this->loadFixtures([]);

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

$path = '/';

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

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

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

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

$path = '/';

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

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

$this->assertSame(1,
$crawler->filter('html > body')->count());
Expand Down Expand Up @@ -171,12 +168,12 @@ public function testAllowedQueriesExceededException(): void
$this->loginAs($repository->getReference('user'),
'secured_area');

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

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

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

/**
Expand All @@ -194,13 +191,12 @@ public function testAnnotationAndException(): void
$this->loadFixtures([
'Liip\Acme\Tests\App\DataFixtures\ORM\LoadUserData',
]);

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

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

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

/**
Expand Down
Loading

0 comments on commit 464c7a2

Please sign in to comment.