Skip to content

Commit a9714d8

Browse files
authored
Merge pull request #315 from FriendsOfSymfony/test-cleanup
Test cleanup
2 parents 8c624e6 + b522bb8 commit a9714d8

19 files changed

+209
-226
lines changed

.composer.lock.swp

16 KB
Binary file not shown.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"php-http/discovery": "^1.0"
3333
},
3434
"require-dev": {
35-
"mockery/mockery": "~0.9.1",
35+
"mockery/mockery": "~0.9.5",
3636
"monolog/monolog": "^1.0",
3737
"php-http/guzzle6-adapter": "^1.0.0",
3838
"php-http/mock-client": "^0.3.2",

src/Exception/ExceptionCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(array $exceptions = [])
3535
*/
3636
public function add(\Exception $e)
3737
{
38-
if (null == $this->message) {
38+
if (!$this->message) {
3939
$this->message = $e->getMessage();
4040
}
4141

src/ResponseTagger.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,26 @@ class ResponseTagger
3434
/**
3535
* @var TagsInterface
3636
*/
37-
private $client;
37+
private $proxyClient;
3838

3939
/**
4040
* @var array
4141
*/
4242
private $tags = [];
4343

4444
/**
45-
* Constructor.
45+
* Create the response tagger with a tag capable proxy client and options.
4646
*
47-
* @param TagsInterface $client
48-
* @param array $options supported options:
49-
* - strict (bool) Default: false. If set to true, throws exception when adding empty tags
47+
* Supported options are:
48+
*
49+
* - strict (bool) Default: false. If set to true, throws exception when adding empty tags
50+
*
51+
* @param TagsInterface $proxyClient
52+
* @param array $options
5053
*/
51-
public function __construct(TagsInterface $client, array $options = array())
54+
public function __construct(TagsInterface $proxyClient, array $options = array())
5255
{
53-
$this->client = $client;
56+
$this->proxyClient = $proxyClient;
5457

5558
$resolver = new OptionsResolver();
5659
$resolver->setDefaults(array(
@@ -69,7 +72,7 @@ public function __construct(TagsInterface $client, array $options = array())
6972
*/
7073
public function getTagsHeaderName()
7174
{
72-
return $this->client->getTagsHeaderName();
75+
return $this->proxyClient->getTagsHeaderName();
7376
}
7477

7578
/**
@@ -81,7 +84,7 @@ public function getTagsHeaderName()
8184
*/
8285
public function getTagsHeaderValue()
8386
{
84-
return $this->client->getTagsHeaderValue($this->tags);
87+
return $this->proxyClient->getTagsHeaderValue($this->tags);
8588
}
8689

8790
/**

src/Test/HttpCaller.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait HttpCaller
2323
*
2424
* @var HttpClient
2525
*/
26-
private $client;
26+
private $httpClient;
2727

2828
/**
2929
* Call a HTTP resource from your test.
@@ -36,11 +36,11 @@ trait HttpCaller
3636
*/
3737
protected function getResponse($uri, array $headers = [], $method = 'GET')
3838
{
39-
if (!$this->client) {
40-
$this->client = new HttpClient($this->getHostName(), $this->getCachingProxyPort());
39+
if (!$this->httpClient) {
40+
$this->httpClient = new HttpClient($this->getHostName(), $this->getCachingProxyPort());
4141
}
4242

43-
return $this->client->getResponse($uri, $headers, $method);
43+
return $this->httpClient->getResponse($uri, $headers, $method);
4444
}
4545

4646
/**

src/Test/Proxy/AbstractProxy.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function waitFor($ip, $port, $timeout)
3434
if (!$this->wait(
3535
$timeout,
3636
function () use ($ip, $port) {
37-
return true == @fsockopen($ip, $port);
37+
return false !== @fsockopen($ip, $port);
3838
}
3939
)) {
4040
throw new \RuntimeException(
@@ -61,8 +61,7 @@ protected function waitUntil($ip, $port, $timeout)
6161
if (!$this->wait(
6262
$timeout,
6363
function () use ($ip, $port) {
64-
// This doesn't seem to work
65-
return false == @fsockopen($ip, $port);
64+
return false === @fsockopen($ip, $port);
6665
}
6766
)) {
6867
throw new \RuntimeException(

tests/Functional/Fixtures/web/user_context.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@
2121
exit;
2222
}
2323

24-
if ('POST' == strtoupper($_SERVER['REQUEST_METHOD'])) {
24+
if ('POST' === strtoupper($_SERVER['REQUEST_METHOD'])) {
2525
echo 'POST';
2626
exit;
2727
}
2828

29-
if (!isset($_COOKIE[0]) || ($_COOKIE[0] != 'foo' && $_COOKIE[0] != 'bar')) {
29+
if (!isset($_COOKIE[0]) || ('foo' !== $_COOKIE[0] && 'bar' !== $_COOKIE[0])) {
3030
header('HTTP/1.1 403');
3131
exit;
3232
}
3333

3434
header('Cache-Control: max-age=3600');
3535
header('Vary: X-User-Context-Hash');
3636

37-
if ($_COOKIE[0] == 'foo') {
37+
if ('foo' === $_COOKIE[0]) {
3838
header('X-HashTest: foo');
3939
echo 'foo';
4040
} else {

tests/Functional/Fixtures/web/user_context_anon.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
if (!isset($_COOKIE[0])) {
1818
header('X-HashTest: anonymous');
1919
echo 'anonymous';
20-
} elseif ($_COOKIE[0] == 'foo') {
20+
} elseif ('foo' === $_COOKIE[0]) {
2121
header('X-HashTest: foo');
2222
echo 'foo';
2323
} else {

tests/Functional/Fixtures/web/user_context_hash_cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// The application listens for hash request (by checking the accept header)
1515
// and creates an X-User-Context-Hash based on parameters in the request.
1616
// In this case it's based on Cookie.
17-
if ('application/vnd.fos.user-context-hash' == strtolower($_SERVER['HTTP_ACCEPT'])) {
17+
if ('application/vnd.fos.user-context-hash' === strtolower($_SERVER['HTTP_ACCEPT'])) {
1818
header(sprintf('X-User-Context-Hash: %s', $_COOKIE[0]));
1919
header('Content-Type: application/vnd.fos.user-context-hash');
2020
header('Cache-Control: max-age=3600');

tests/Functional/Fixtures/web/user_context_hash_failure.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// The application listens for hash request (by checking the accept header)
1515
// and creates an X-User-Context-Hash based on parameters in the request.
1616
// In this case it's based on Cookie.
17-
if ('application/vnd.fos.user-context-hash' == strtolower($_SERVER['HTTP_ACCEPT'])) {
17+
if ('application/vnd.fos.user-context-hash' === strtolower($_SERVER['HTTP_ACCEPT'])) {
1818
header(sprintf('X-User-Context-Hash: %s', 'failed'));
1919
header('Content-Type: application/vnd.fos.user-context-hash');
2020
header('Cache-Control: max-age=3600');

0 commit comments

Comments
 (0)