Skip to content

Commit c5046ba

Browse files
committed
Merge pull request #116 from FriendsOfSymfony/test-naming
Make test naming more consistent with bundle
2 parents 4d6ec3b + c578871 commit c5046ba

File tree

6 files changed

+30
-14
lines changed

6 files changed

+30
-14
lines changed

doc/testing-your-application.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ By having your test classes extend ``VarnishTestCase``, you get:
1919
* ``$this->varnish`` referring to an instance of this library’s Varnish client
2020
that is configured to talk to your Varnish server
2121
* convenience methods for executing HTTP requests to your application:
22-
``$this->getClient()`` and ``$this->getResponse()``
22+
``$this->getHttpClient()`` and ``$this->getResponse()``
2323
* custom assertions ``assertHit`` and ``assertMiss`` for validating a cache hit/miss.
2424

2525
Configuration

src/Test/NginxTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* NGINX_FILE NGINX configuration file (required if not passed to setUp)
3333
* NGINX_CACHE_PATH NGINX configuration file (required if not passed to setUp)
3434
*/
35-
abstract class NginxTestCase extends AbstractProxyClientTestCase
35+
abstract class NginxTestCase extends ProxyTestCase
3636
{
3737
/**
3838
* @var NginxProxy

src/Test/AbstractProxyClientTestCase.php renamed to src/Test/ProxyTestCase.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
* Abstract caching proxy test case
2121
*
2222
*/
23-
abstract class AbstractProxyClientTestCase extends \PHPUnit_Framework_TestCase
23+
abstract class ProxyTestCase extends \PHPUnit_Framework_TestCase
2424
{
2525
/**
2626
* A Guzzle HTTP client.
2727
*
2828
* @var Client
2929
*/
30-
protected $client;
30+
protected $httpClient;
3131

3232
/**
3333
* Assert a cache miss
@@ -72,24 +72,24 @@ public static function isCacheMiss()
7272
*/
7373
public function getResponse($url, array $headers = array(), $options = array())
7474
{
75-
return $this->getClient()->get($url, $headers, $options)->send();
75+
return $this->getHttpClient()->get($url, $headers, $options)->send();
7676
}
7777

7878
/**
7979
* Get HTTP client for your application
8080
*
8181
* @return Client
8282
*/
83-
public function getClient()
83+
public function getHttpClient()
8484
{
85-
if (null === $this->client) {
86-
$this->client = new Client(
85+
if (null === $this->httpClient) {
86+
$this->httpClient = new Client(
8787
'http://' . $this->getHostName() . ':' . $this->getCachingProxyPort(),
8888
array('curl.options' => array(CURLOPT_FORBID_REUSE => true))
8989
);
9090
}
9191

92-
return $this->client;
92+
return $this->httpClient;
9393
}
9494

9595
/**
@@ -125,12 +125,23 @@ protected function getHostName()
125125
}
126126

127127
/**
128+
* Get proxy server
129+
*
128130
* @return \FOS\HttpCache\Test\Proxy\ProxyInterface
129131
*/
130132
abstract protected function getProxy();
131133

132134
/**
135+
* Get proxy client
136+
*
133137
* @return \FOS\HttpCache\ProxyClient\ProxyClientInterface
134138
*/
135139
abstract protected function getProxyClient();
140+
141+
/**
142+
* Get port that caching proxy listens on
143+
*
144+
* @return int
145+
*/
146+
abstract protected function getCachingProxyPort();
136147
}

src/Test/VarnishTestCase.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use FOS\HttpCache\ProxyClient\Varnish;
1515
use FOS\HttpCache\Test\Proxy\VarnishProxy;
16-
use Symfony\Component\Process\Process;
1716

1817
/**
1918
* A phpunit base class to write functional tests with varnish.
@@ -39,7 +38,7 @@
3938
* (default /tmp/foshttpcache-test)
4039
* WEB_SERVER_HOSTNAME name of the webserver varnish has to talk to (required)
4140
*/
42-
abstract class VarnishTestCase extends AbstractProxyClientTestCase
41+
abstract class VarnishTestCase extends ProxyTestCase
4342
{
4443
/**
4544
* @var Varnish

tests/Functional/Varnish/UserContextFailureTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ public function testUserContextNotUsed()
7878
$this->getResponse('/user_context.php', array(), array('cookies' => array('foo')));
7979

8080
//Second request in head or post
81-
$postResponse = $this->getClient()->post('/user_context.php', array(), null, array('cookies' => array('foo')))->send();
81+
$postResponse = $this->getHttpClient()
82+
->post('/user_context.php', array(), null, array('cookies' => array('foo')))
83+
->send();
8284

8385
$this->assertEquals('POST', $postResponse->getBody(true));
8486
$this->assertEquals('MISS', $postResponse->getHeader('X-HashCache'));

tests/Functional/Varnish/UserContextTestCase.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,17 @@ public function testUserContextHash()
4747
$this->assertContextCache($cachedResponse2->getHeader('X-HashCache'));
4848
$this->assertHit($cachedResponse2);
4949

50-
$headResponse1 = $this->getClient()->head('/user_context.php', array(), array('cookies' => array('foo')))->send();
50+
$headResponse1 = $this->getHttpClient()
51+
->head('/user_context.php', array(), array('cookies' => array('foo')))
52+
->send();
5153

5254
$this->assertEquals('foo', $headResponse1->getHeader('X-HashTest'));
5355
$this->assertContextCache($headResponse1->getHeader('X-HashCache'));
5456
$this->assertHit($headResponse1);
5557

56-
$headResponse2 = $this->getClient()->head('/user_context.php', array(), array('cookies' => array('bar')))->send();
58+
$headResponse2 = $this->getHttpClient()
59+
->head('/user_context.php', array(), array('cookies' => array('bar')))
60+
->send();
5761

5862
$this->assertEquals('bar', $headResponse2->getHeader('X-HashTest'));
5963
$this->assertContextCache($headResponse2->getHeader('X-HashCache'));

0 commit comments

Comments
 (0)