Skip to content

Commit b3127e9

Browse files
committed
Added unit tests
1 parent 25cf2d9 commit b3127e9

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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\Tests\Unit\SymfonyCache;
13+
14+
use FOS\HttpCache\SymfonyCache\CacheEvent;
15+
use FOS\HttpCache\SymfonyCache\CacheInvalidation;
16+
use PHPUnit\Framework\TestCase;
17+
use Symfony\Component\HttpFoundation\Request;
18+
use Symfony\Component\HttpFoundation\Response;
19+
use Symfony\Component\HttpKernel\HttpKernelInterface;
20+
use Symfony\Component\HttpKernel\KernelInterface;
21+
22+
class CacheEventTest extends TestCase
23+
{
24+
/**
25+
* @var CacheInvalidation|\PHPUnit_Framework_MockObject_MockObject
26+
*/
27+
private $kernel;
28+
29+
public function setUp()
30+
{
31+
$this->kernel = $this->createMock(CacheInvalidation::class);
32+
}
33+
34+
public function testEventGetters()
35+
{
36+
$request = Request::create('/');
37+
38+
$event = new CacheEvent($this->kernel, $request);
39+
40+
$this->assertSame($this->kernel, $event->getKernel());
41+
$this->assertSame($request, $event->getRequest());
42+
$this->assertNull($event->getResponse());
43+
$this->assertSame(KernelInterface::MASTER_REQUEST, $event->getRequestType());
44+
45+
$response = new Response();
46+
47+
$event = new CacheEvent($this->kernel, $request, $response, HttpKernelInterface::SUB_REQUEST);
48+
49+
$this->assertSame($this->kernel, $event->getKernel());
50+
$this->assertSame($request, $event->getRequest());
51+
$this->assertSame($response, $event->getResponse());
52+
$this->assertSame(KernelInterface::SUB_REQUEST, $event->getRequestType());
53+
}
54+
}

0 commit comments

Comments
 (0)