Skip to content

Commit a70f44b

Browse files
Merge branch '4.4'
* 4.4: [Debug] disable new DebugClassLoader when testing the legacy one - updated AbstractToken to compare Roles - Updated isEqualTo method to match roles as default User implements EquatableInterface - added test case - bumped symfony/security-core to 4.4 typos bis typos Fix more bad tests Fix test fixtures with deprecated method signatures. Fix 4.3 tests forward compat [Messenger] fix empty amqp body returned as false [Mailer] Added messenger to dev dependencies. [Validator] Update "suggest" section in composer.json. Fix routing cache broken when using generator_class
2 parents 3e5e2c0 + 07a0d8a commit a70f44b

File tree

4 files changed

+137
-146
lines changed

4 files changed

+137
-146
lines changed

Tests/AbstractBrowserTest.php

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -19,53 +19,6 @@
1919
use Symfony\Component\DomCrawler\Crawler;
2020
use Symfony\Component\DomCrawler\Form as DomCrawlerForm;
2121

22-
class TestClient extends AbstractBrowser
23-
{
24-
protected $nextResponse = null;
25-
protected $nextScript = null;
26-
27-
public function setNextResponse(Response $response)
28-
{
29-
$this->nextResponse = $response;
30-
}
31-
32-
public function setNextScript($script)
33-
{
34-
$this->nextScript = $script;
35-
}
36-
37-
protected function doRequest($request): Response
38-
{
39-
if (null === $this->nextResponse) {
40-
return new Response();
41-
}
42-
43-
$response = $this->nextResponse;
44-
$this->nextResponse = null;
45-
46-
return $response;
47-
}
48-
49-
protected function filterResponse($response): Response
50-
{
51-
return $response;
52-
}
53-
54-
protected function getScript($request)
55-
{
56-
$r = new \ReflectionClass('Symfony\Component\BrowserKit\Response');
57-
$path = $r->getFileName();
58-
59-
return <<<EOF
60-
<?php
61-
62-
require_once('$path');
63-
64-
echo serialize($this->nextScript);
65-
EOF;
66-
}
67-
}
68-
6922
class AbstractBrowserTest extends TestCase
7023
{
7124
public function getBrowser(array $server = [], History $history = null, CookieJar $cookieJar = null)
@@ -879,30 +832,3 @@ public function testInternalRequestNull()
879832
$this->assertNull($client->getInternalRequest());
880833
}
881834
}
882-
883-
class ClassThatInheritClient extends AbstractBrowser
884-
{
885-
protected $nextResponse = null;
886-
887-
public function setNextResponse(Response $response)
888-
{
889-
$this->nextResponse = $response;
890-
}
891-
892-
protected function doRequest($request): Response
893-
{
894-
if (null === $this->nextResponse) {
895-
return new Response();
896-
}
897-
898-
$response = $this->nextResponse;
899-
$this->nextResponse = null;
900-
901-
return $response;
902-
}
903-
904-
public function submit(DomCrawlerForm $form, array $values = [], array $serverParameters = []): Crawler
905-
{
906-
return parent::submit($form, $values, $serverParameters);
907-
}
908-
}

Tests/HttpBrowserTest.php

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -14,81 +14,9 @@
1414
use Symfony\Component\BrowserKit\CookieJar;
1515
use Symfony\Component\BrowserKit\History;
1616
use Symfony\Component\BrowserKit\HttpBrowser;
17-
use Symfony\Component\BrowserKit\Response;
18-
use Symfony\Component\HttpClient\MockHttpClient;
19-
use Symfony\Component\HttpClient\Response\MockResponse;
2017
use Symfony\Contracts\HttpClient\HttpClientInterface;
2118
use Symfony\Contracts\HttpClient\ResponseInterface;
2219

23-
class TestHttpClient extends HttpBrowser
24-
{
25-
protected $nextResponse = null;
26-
protected $nextScript = null;
27-
28-
public function __construct(array $server = [], History $history = null, CookieJar $cookieJar = null)
29-
{
30-
$client = new MockHttpClient(function (string $method, string $url, array $options) {
31-
if (null === $this->nextResponse) {
32-
return new MockResponse();
33-
}
34-
35-
return new MockResponse($this->nextResponse->getContent(), [
36-
'http_code' => $this->nextResponse->getStatusCode(),
37-
'response_headers' => $this->nextResponse->getHeaders(),
38-
]);
39-
});
40-
parent::__construct($client);
41-
42-
$this->setServerParameters($server);
43-
$this->history = $history ?? new History();
44-
$this->cookieJar = $cookieJar ?? new CookieJar();
45-
}
46-
47-
public function setNextResponse(Response $response)
48-
{
49-
$this->nextResponse = $response;
50-
}
51-
52-
public function setNextScript($script)
53-
{
54-
$this->nextScript = $script;
55-
}
56-
57-
protected function filterResponse($response): Response
58-
{
59-
return $response;
60-
}
61-
62-
protected function doRequest($request): Response
63-
{
64-
$response = parent::doRequest($request);
65-
66-
if (null === $this->nextResponse) {
67-
return $response;
68-
}
69-
70-
$class = \get_class($this->nextResponse);
71-
$response = new $class($response->getContent(), $response->getStatusCode(), $response->getHeaders());
72-
$this->nextResponse = null;
73-
74-
return $response;
75-
}
76-
77-
protected function getScript($request)
78-
{
79-
$r = new \ReflectionClass('Symfony\Component\BrowserKit\Response');
80-
$path = $r->getFileName();
81-
82-
return <<<EOF
83-
<?php
84-
85-
require_once('$path');
86-
87-
echo serialize($this->nextScript);
88-
EOF;
89-
}
90-
}
91-
9220
class HttpBrowserTest extends AbstractBrowserTest
9321
{
9422
public function getBrowser(array $server = [], History $history = null, CookieJar $cookieJar = null)

Tests/TestClient.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\BrowserKit\Tests;
13+
14+
use Symfony\Component\BrowserKit\AbstractBrowser;
15+
use Symfony\Component\BrowserKit\Response;
16+
17+
class TestClient extends AbstractBrowser
18+
{
19+
protected $nextResponse = null;
20+
protected $nextScript = null;
21+
22+
public function setNextResponse(Response $response)
23+
{
24+
$this->nextResponse = $response;
25+
}
26+
27+
public function setNextScript($script)
28+
{
29+
$this->nextScript = $script;
30+
}
31+
32+
protected function doRequest($request): Response
33+
{
34+
if (null === $this->nextResponse) {
35+
return new Response();
36+
}
37+
38+
$response = $this->nextResponse;
39+
$this->nextResponse = null;
40+
41+
return $response;
42+
}
43+
44+
protected function getScript($request)
45+
{
46+
$r = new \ReflectionClass('Symfony\Component\BrowserKit\Response');
47+
$path = $r->getFileName();
48+
49+
return <<<EOF
50+
<?php
51+
52+
require_once('$path');
53+
54+
echo serialize($this->nextScript);
55+
EOF;
56+
}
57+
}

Tests/TestHttpClient.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\BrowserKit\Tests;
13+
14+
use Symfony\Component\BrowserKit\CookieJar;
15+
use Symfony\Component\BrowserKit\History;
16+
use Symfony\Component\BrowserKit\HttpBrowser;
17+
use Symfony\Component\BrowserKit\Response;
18+
use Symfony\Component\HttpClient\MockHttpClient;
19+
use Symfony\Component\HttpClient\Response\MockResponse;
20+
21+
class TestHttpClient extends HttpBrowser
22+
{
23+
protected $nextResponse = null;
24+
protected $nextScript = null;
25+
26+
public function __construct(array $server = [], History $history = null, CookieJar $cookieJar = null)
27+
{
28+
$client = new MockHttpClient(function (string $method, string $url, array $options) {
29+
if (null === $this->nextResponse) {
30+
return new MockResponse();
31+
}
32+
33+
return new MockResponse($this->nextResponse->getContent(), [
34+
'http_code' => $this->nextResponse->getStatusCode(),
35+
'response_headers' => $this->nextResponse->getHeaders(),
36+
]);
37+
});
38+
parent::__construct($client);
39+
40+
$this->setServerParameters($server);
41+
$this->history = $history ?? new History();
42+
$this->cookieJar = $cookieJar ?? new CookieJar();
43+
}
44+
45+
public function setNextResponse(Response $response)
46+
{
47+
$this->nextResponse = $response;
48+
}
49+
50+
public function setNextScript($script)
51+
{
52+
$this->nextScript = $script;
53+
}
54+
55+
protected function doRequest($request): Response
56+
{
57+
if (null === $this->nextResponse) {
58+
return parent::doRequest($request);
59+
}
60+
61+
$response = $this->nextResponse;
62+
$this->nextResponse = null;
63+
64+
return $response;
65+
}
66+
67+
protected function getScript($request)
68+
{
69+
$r = new \ReflectionClass('Symfony\Component\BrowserKit\Response');
70+
$path = $r->getFileName();
71+
72+
return <<<EOF
73+
<?php
74+
75+
require_once('$path');
76+
77+
echo serialize($this->nextScript);
78+
EOF;
79+
}
80+
}

0 commit comments

Comments
 (0)