Skip to content

Commit 464c7a2

Browse files
Merge pull request liip#519 from izisolutions/feature/cherry-pick-4.3
Feature/cherry pick 4.3
2 parents 76c3fd3 + 072fa22 commit 464c7a2

6 files changed

Lines changed: 80 additions & 76 deletions

File tree

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ matrix:
2828
env: EXTRA_PACKAGES="doctrine/phpcr-bundle:^1.3 brianium/paratest:^1.0 doctrine/phpcr-odm:^1.3"
2929
- php: 7.3
3030
env: SYMFONY_VERSION="^4.1"
31+
- php: 7.3
32+
env: SYMFONY_VERSION="^4.3"
3133
allow_failures:
3234
- php: 7.2
3335
env: SYMFONY_VERSION="dev-master"

src/Test/WebTestCase.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
*/
4141
abstract class WebTestCase extends BaseWebTestCase
4242
{
43+
/** @var Client|null */
44+
protected static $client;
45+
4346
protected $environment = 'test';
4447

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

413-
return $client;
416+
return static::$client = $client;
414417
}
415418

416419
/**
@@ -568,3 +571,8 @@ protected function tearDown(): void
568571
parent::tearDown();
569572
}
570573
}
574+
575+
// Compatibility layer for Symfony 4.3+
576+
if (class_exists('Symfony\Bundle\FrameworkBundle\KernelBrowser')) {
577+
class_alias('Symfony\Bundle\FrameworkBundle\KernelBrowser', 'Symfony\Bundle\FrameworkBundle\Client');
578+
}

tests/DependencyInjection/ConfigurationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class ConfigurationTest extends WebTestCase
2525

2626
public function setUp(): void
2727
{
28-
$client = static::makeClient();
29-
$this->clientContainer = $client->getContainer();
28+
static::$client = $this->makeClient();
29+
$this->clientContainer = static::$client->getContainer();
3030
}
3131

3232
/**

tests/Test/WebTestCaseConfigLeanFrameworkTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected static function getKernelClass(): string
3535

3636
public function testAssertStatusCode(): void
3737
{
38-
$client = static::makeClient();
38+
$client = $this->makeClient();
3939

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

4646
public function testAssertValidationErrorsTriggersError(): void
4747
{
48-
$client = static::makeClient();
48+
$client = $this->makeClient();
4949

5050
$path = '/form';
5151
$client->request('GET', $path);

tests/Test/WebTestCaseConfigTest.php

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
*/
3737
class WebTestCaseConfigTest extends WebTestCase
3838
{
39-
/** @var \Symfony\Bundle\FrameworkBundle\Client client */
40-
private $client = null;
41-
4239
protected static function getKernelClass(): string
4340
{
4441
return AppConfigKernel::class;
@@ -51,16 +48,16 @@ public function testIndexAuthenticationArray(): void
5148
{
5249
$this->loadFixtures([]);
5350

54-
$this->client = static::makeClient([
51+
static::$client = $this->makeClient([
5552
'username' => 'foobar',
5653
'password' => '12341234',
5754
]);
5855

5956
$path = '/';
6057

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

63-
$this->assertStatusCode(200, $this->client);
60+
$this->assertStatusCode(200, static::$client);
6461

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

88-
$this->client = static::makeClient(true);
85+
static::$client = $this->makeClient(true);
8986

9087
$path = '/';
9188

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

94-
$this->assertStatusCode(200, $this->client);
91+
$this->assertStatusCode(200, static::$client);
9592

9693
$this->assertSame(1,
9794
$crawler->filter('html > body')->count());
@@ -127,13 +124,13 @@ public function testIndexAuthenticationLoginAs(): void
127124
$loginAs
128125
);
129126

130-
$this->client = static::makeClient();
127+
static::$client = $this->makeClient();
131128

132129
$path = '/';
133130

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

136-
$this->assertStatusCode(200, $this->client);
133+
$this->assertStatusCode(200, static::$client);
137134

138135
$this->assertSame(1,
139136
$crawler->filter('html > body')->count());
@@ -171,12 +168,12 @@ public function testAllowedQueriesExceededException(): void
171168
$this->loginAs($repository->getReference('user'),
172169
'secured_area');
173170

174-
$this->client = static::makeClient();
171+
static::$client = $this->makeClient();
175172

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

179-
$this->client->request('GET', $path);
176+
static::$client->request('GET', $path);
180177
}
181178

182179
/**
@@ -194,13 +191,12 @@ public function testAnnotationAndException(): void
194191
$this->loadFixtures([
195192
'Liip\Acme\Tests\App\DataFixtures\ORM\LoadUserData',
196193
]);
197-
198-
$this->client = static::makeClient();
194+
static::$client = $this->makeClient();
199195

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

203-
$this->client->request('GET', $path);
199+
static::$client->request('GET', $path);
204200
}
205201

206202
/**

0 commit comments

Comments
 (0)