Skip to content

Commit faecba4

Browse files
committed
adding back extending the phpunit test case
1 parent f62f79c commit faecba4

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpC
1212
* In ProxyTestCase, `getHttpClient()` has been replaced with `getHttpAdapter()`;
1313
added HTTP method parameter to `getResponse()`.
1414
* Changed default Varnish version to 4.
15+
* Added support and documentation for setting a custom TTL specifically for the
16+
caching proxy.
17+
* Refactored the proxy client test system into traits. Removed ProxyTestCase,
18+
use the traits `CacheAssertions` and `HttpCaller` instead.
1519

1620
1.4.0
1721
-----

doc/testing-your-application.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ rules that it defines.
1111
The FOSHttpCache library provides traits and base test classes to help you write
1212
functional tests. Using the traits, you can extend your own (or your
1313
framework’s) base test classes. For convenience, you can also extend the
14-
FOSHttpCache base test classes, as they include a sensible set of traits by
15-
default.
14+
FOSHttpCache base test class suitable for your caching proxy, which includes
15+
a sensible set of traits.
1616

1717
By using the traits, you get:
1818

@@ -185,8 +185,8 @@ integrated.
185185
======================= ========================= ================================================ ===========================================
186186
Constant Getter Default Description
187187
======================= ========================= ================================================ ===========================================
188-
``WEB_SERVER_HOSTNAME`` ``getHostName()`` hostname your application can be reached at
189-
``WEB_SERVER_PORT`` ``getConfigFile()`` The port on which the web server runs
188+
``WEB_SERVER_HOSTNAME`` ``getHostName()`` Hostname your application can be reached at
189+
``WEB_SERVER_PORT`` ``getCachingProxyPort()`` The port on which the web server runs
190190
``SYMFONY_CACHE_DIR`` ``getCacheDir()`` ``sys_get_temp_dir()`` + ``/foshttpcache-nginx`` directory to use for cache
191191
Must match the configuration of your
192192
HttpCache and must be writable by the user
@@ -204,6 +204,8 @@ proxy::
204204

205205
class YourTest extends \PHPUnit_Framework_TestCase
206206
{
207+
use HttpCaller;
208+
207209
public function testCachingHeaders()
208210
{
209211
// Get some response from your application
@@ -214,6 +216,10 @@ proxy::
214216
}
215217
}
216218

219+
This trait requires the methods ``getHostName()`` and ``getCachingProxyPort()``
220+
to exist. When using one of the caching proxy traits, these will be provided by
221+
the trait, otherwise you have to implement them.
222+
217223
CacheAssertions Trait
218224
~~~~~~~~~~~~~~~~~~~~~
219225

src/Test/NginxTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Abstract test that collects traits necessary for running tests against
1616
* NGINX
1717
*/
18-
abstract class NginxTestCase
18+
abstract class NginxTestCase extends \PHPUnit_Framework_TestCase
1919
{
2020
use CacheAssertions;
2121
use HttpCaller;

src/Test/SymfonyTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Abstract test that contains traits necessary for running tests against
1616
* Symfony HtptCache
1717
*/
18-
abstract class SymfonyTestCase
18+
abstract class SymfonyTestCase extends \PHPUnit_Framework_TestCase
1919
{
2020
use CacheAssertions;
2121
use HttpCaller;

src/Test/VarnishTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected function getCacheDir()
136136
*/
137137
protected function getVarnishVersion()
138138
{
139-
return getenv('VARNISH_VERSION') ?: 4;
139+
return getenv('VARNISH_VERSION') ?: '4.0';
140140
}
141141

142142
/**

src/Test/VarnishTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* Abstract test that contains traits necessary for running tests against Varnish
1616
*/
17-
abstract class VarnishTestCase
17+
abstract class VarnishTestCase extends \PHPUnit_Framework_TestCase
1818
{
1919
use CacheAssertions;
2020
use HttpCaller;

0 commit comments

Comments
 (0)