MiniAsset\Test\TestCase\AssetMiddlewareTest::testInvokeCacheRead PHP Method

testInvokeCacheRead() public method

public testInvokeCacheRead ( )
    public function testInvokeCacheRead()
    {
        file_put_contents(sys_get_temp_dir() . '/all.css', 'cached data');
        $request = ServerRequestFactory::fromGlobals(['REQUEST_URI' => '/assets/all.css']);
        $response = new Response();
        $next = function ($req, $res) {
            return $res;
        };
        $res = $this->middleware->__invoke($request, $response, $next);
        $this->assertNotSame($res, $response, 'Should be a new response');
        $this->assertSame(200, $res->getStatusCode(), 'Is 200 on success');
        $this->assertSame('application/css', $res->getHeaderLine('Content-Type'));
        $this->assertContains('cached data', '' . $res->getBody(), 'Is cached data.');
        unlink(sys_get_temp_dir() . '/all.css');
    }