| Total Complexity | 3 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | class ResponseTest extends TestCase |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * @var Response |
||
| 10 | */ |
||
| 11 | private $response; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Bootstrap the test environment. |
||
| 15 | */ |
||
| 16 | public function setUp() |
||
| 17 | { |
||
| 18 | parent::setUp(); |
||
| 19 | |||
| 20 | $this->response = new Response(); |
||
| 21 | } |
||
| 22 | |||
| 23 | /** @test */ |
||
| 24 | public function it_should_not_add_a_link_header_or_cookie_without_pushable_resources() |
||
| 25 | { |
||
| 26 | $this->response->pushes($this->builder, $this->nonPushable); |
||
| 27 | |||
| 28 | $headers = $this->response->headers; |
||
| 29 | |||
| 30 | $this->assertFalse($headers->has('Link')); |
||
| 31 | $this->assertCount(0, $headers->getCookies()); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** @test */ |
||
| 35 | public function it_should_add_a_link_header_and_cookie_when_given_pushable_resources() |
||
| 46 | ); |
||
| 47 | } |
||
| 48 | } |
||
| 49 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: