|
19 | 19 |
|
20 | 20 | class RouterCacheWarmerTest extends TestCase |
21 | 21 | { |
22 | | - public function testWarmUpWithWarmebleInterface() |
| 22 | + public function testWarmUpWithWarmableInterfaceWithBuildDir() |
23 | 23 | { |
24 | 24 | $containerMock = $this->getMockBuilder(ContainerInterface::class)->onlyMethods(['get', 'has'])->getMock(); |
25 | 25 |
|
26 | | - $routerMock = $this->getMockBuilder(testRouterInterfaceWithWarmebleInterface::class)->onlyMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection', 'warmUp'])->getMock(); |
| 26 | + $routerMock = $this->getMockBuilder(testRouterInterfaceWithWarmableInterface::class)->onlyMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection', 'warmUp'])->getMock(); |
27 | 27 | $containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock); |
28 | 28 | $routerCacheWarmer = new RouterCacheWarmer($containerMock); |
29 | 29 |
|
30 | | - $routerCacheWarmer->warmUp('/tmp'); |
31 | | - $routerMock->expects($this->any())->method('warmUp')->with('/tmp')->willReturn([]); |
| 30 | + $routerCacheWarmer->warmUp('/tmp/cache', '/tmp/build'); |
| 31 | + $routerMock->expects($this->any())->method('warmUp')->with('/tmp/cache', '/tmp/build')->willReturn([]); |
32 | 32 | $this->addToAssertionCount(1); |
33 | 33 | } |
34 | 34 |
|
35 | | - public function testWarmUpWithoutWarmebleInterface() |
| 35 | + public function testWarmUpWithoutWarmableInterfaceWithBuildDir() |
36 | 36 | { |
37 | 37 | $containerMock = $this->getMockBuilder(ContainerInterface::class)->onlyMethods(['get', 'has'])->getMock(); |
38 | 38 |
|
39 | | - $routerMock = $this->getMockBuilder(testRouterInterfaceWithoutWarmebleInterface::class)->onlyMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection'])->getMock(); |
| 39 | + $routerMock = $this->getMockBuilder(testRouterInterfaceWithoutWarmableInterface::class)->onlyMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection'])->getMock(); |
40 | 40 | $containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock); |
41 | 41 | $routerCacheWarmer = new RouterCacheWarmer($containerMock); |
42 | 42 | $this->expectException(\LogicException::class); |
43 | 43 | $this->expectExceptionMessage('cannot be warmed up because it does not implement "Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface"'); |
44 | | - $routerCacheWarmer->warmUp('/tmp'); |
| 44 | + $routerCacheWarmer->warmUp('/tmp/cache', '/tmp/build'); |
| 45 | + } |
| 46 | + |
| 47 | + public function testWarmUpWithWarmableInterfaceWithoutBuildDir() |
| 48 | + { |
| 49 | + $containerMock = $this->getMockBuilder(ContainerInterface::class)->onlyMethods(['get', 'has'])->getMock(); |
| 50 | + |
| 51 | + $routerMock = $this->getMockBuilder(testRouterInterfaceWithWarmableInterface::class)->onlyMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection', 'warmUp'])->getMock(); |
| 52 | + $containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock); |
| 53 | + $routerCacheWarmer = new RouterCacheWarmer($containerMock); |
| 54 | + |
| 55 | + $preload = $routerCacheWarmer->warmUp('/tmp'); |
| 56 | + $routerMock->expects($this->never())->method('warmUp'); |
| 57 | + self::assertSame([], $preload); |
| 58 | + $this->addToAssertionCount(1); |
| 59 | + } |
| 60 | + |
| 61 | + public function testWarmUpWithoutWarmableInterfaceWithoutBuildDir() |
| 62 | + { |
| 63 | + $containerMock = $this->getMockBuilder(ContainerInterface::class)->onlyMethods(['get', 'has'])->getMock(); |
| 64 | + |
| 65 | + $routerMock = $this->getMockBuilder(testRouterInterfaceWithoutWarmableInterface::class)->onlyMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection'])->getMock(); |
| 66 | + $containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock); |
| 67 | + $routerCacheWarmer = new RouterCacheWarmer($containerMock); |
| 68 | + $preload = $routerCacheWarmer->warmUp('/tmp'); |
| 69 | + self::assertSame([], $preload); |
45 | 70 | } |
46 | 71 | } |
47 | 72 |
|
48 | | -interface testRouterInterfaceWithWarmebleInterface extends RouterInterface, WarmableInterface |
| 73 | +interface testRouterInterfaceWithWarmableInterface extends RouterInterface, WarmableInterface |
49 | 74 | { |
50 | 75 | } |
51 | 76 |
|
52 | | -interface testRouterInterfaceWithoutWarmebleInterface extends RouterInterface |
| 77 | +interface testRouterInterfaceWithoutWarmableInterface extends RouterInterface |
53 | 78 | { |
54 | 79 | } |
0 commit comments