4
4
5
5
use League \Flysystem \Adapter \Local ;
6
6
use League \Flysystem \Filesystem ;
7
+ use PHPUnit \Framework \TestCase ;
7
8
8
- class CakeResponseFactoryTest extends \PHPUnit_Framework_TestCase
9
+ class CakeResponseFactoryTest extends TestCase
9
10
{
10
11
public function testCreateInstance ()
11
12
{
13
+ $ cakeResponseFactory = new CakeResponseFactory ();
12
14
$ this ->assertInstanceOf (
13
15
'League\Glide\Responses\CakeResponseFactory ' ,
14
- new CakeResponseFactory ()
16
+ $ cakeResponseFactory
15
17
);
16
18
}
17
19
20
+ /**
21
+ * @throws \League\Flysystem\FileNotFoundException
22
+ */
18
23
public function testCreate ()
19
24
{
20
25
$ cache = new Filesystem (
@@ -25,10 +30,12 @@ public function testCreate()
25
30
/** @var \Cake\Http\Response|\Cake\Network\Response $response */
26
31
$ response = $ factory ->create ($ cache , 'kayaks.jpg ' );
27
32
28
- $ this ->assertInstanceOf ('Cake\Network\Response ' , $ response );
29
- $ this ->assertEquals ('image/jpeg ' , $ response ->type ());
30
- $ this ->assertEquals ('5175 ' , $ response ->getHeaderLine ('Content-Length ' ));
31
- $ this ->assertContains (gmdate ('D, d M Y H:i ' , strtotime ('+1 years ' )), $ response ->getHeaderLine ('Expires ' ));
32
- $ this ->assertEquals ('max-age=31536000, public ' , $ response ->getHeaderLine ('Cache-Control ' ));
33
+ $ headers = $ response ->getHeaders ();
34
+
35
+ $ this ->assertInstanceOf ('Cake\Http\Response ' , $ response );
36
+ $ this ->assertEquals ('image/jpeg ' , $ headers ['Content-Type ' ][0 ]);
37
+ $ this ->assertEquals ('5175 ' , $ headers ['Content-Length ' ][0 ]);
38
+ $ this ->assertStringContainsString (gmdate ('D, j M Y H:i:s ' , strtotime ('+1 years ' )).' GMT ' , $ headers ['Expires ' ][0 ]);
39
+ $ this ->assertEquals ('max-age=31536000, public ' , $ headers ['Cache-Control ' ][0 ]);
33
40
}
34
41
}
0 commit comments