|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the FOSHttpCache package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) FriendsOfSymfony <http://friendsofsymfony.github.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 FOS\HttpCache\Test; |
|
13
|
|
|
|
|
14
|
|
|
use FOS\HttpCache\Test\PHPUnit\IsCacheHitConstraint; |
|
15
|
|
|
use FOS\HttpCache\Test\PHPUnit\IsCacheMissConstraint; |
|
16
|
|
|
use PHPUnit\Framework\TestCase; |
|
|
|
|
|
|
17
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Provides cache hit/miss assertions to PHPUnit tests. |
|
21
|
|
|
* |
|
22
|
|
|
* To enable the assertHit and assertMiss assertions, you need to configure your |
|
23
|
|
|
* caching proxy to set an X-Cache header with the cache status. |
|
24
|
|
|
* |
|
25
|
|
|
* Use this trait in conjunction with either the NginxTest, SymfonyTest or |
|
26
|
|
|
* VarnishTest trait to reset the cache between tests and properly isolate your |
|
27
|
|
|
* assertions. |
|
28
|
|
|
*/ |
|
29
|
|
|
trait CacheAssertions |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* Assert a cache miss. |
|
33
|
|
|
* |
|
34
|
|
|
* @param string $message Test failure message (optional) |
|
35
|
|
|
*/ |
|
36
|
22 |
|
public function assertMiss(ResponseInterface $response, $message = '') |
|
37
|
|
|
{ |
|
38
|
22 |
|
TestCase::assertThat($response, self::isCacheMiss(), $message); |
|
39
|
22 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Assert a cache hit. |
|
43
|
|
|
* |
|
44
|
|
|
* @param string $message Test failure message (optional) |
|
45
|
|
|
*/ |
|
46
|
25 |
|
public function assertHit(ResponseInterface $response, $message = '') |
|
47
|
|
|
{ |
|
48
|
25 |
|
TestCase::assertThat($response, self::isCacheHit(), $message); |
|
49
|
25 |
|
} |
|
50
|
|
|
|
|
51
|
25 |
|
public static function isCacheHit() |
|
52
|
|
|
{ |
|
53
|
25 |
|
return new IsCacheHitConstraint(); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
22 |
|
public static function isCacheMiss() |
|
57
|
|
|
{ |
|
58
|
22 |
|
return new IsCacheMissConstraint(); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths