aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/front/ShaarliMiddlewareTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/front/ShaarliMiddlewareTest.php')
-rw-r--r--tests/front/ShaarliMiddlewareTest.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/front/ShaarliMiddlewareTest.php b/tests/front/ShaarliMiddlewareTest.php
index 81ea1344..20090d8b 100644
--- a/tests/front/ShaarliMiddlewareTest.php
+++ b/tests/front/ShaarliMiddlewareTest.php
@@ -19,6 +19,8 @@ use Slim\Http\Uri;
19 19
20class ShaarliMiddlewareTest extends TestCase 20class ShaarliMiddlewareTest extends TestCase
21{ 21{
22 protected const TMP_MOCK_FILE = '.tmp';
23
22 /** @var ShaarliContainer */ 24 /** @var ShaarliContainer */
23 protected $container; 25 protected $container;
24 26
@@ -29,12 +31,21 @@ class ShaarliMiddlewareTest extends TestCase
29 { 31 {
30 $this->container = $this->createMock(ShaarliContainer::class); 32 $this->container = $this->createMock(ShaarliContainer::class);
31 33
34 touch(static::TMP_MOCK_FILE);
35
32 $this->container->conf = $this->createMock(ConfigManager::class); 36 $this->container->conf = $this->createMock(ConfigManager::class);
37 $this->container->conf->method('getConfigFileExt')->willReturn(static::TMP_MOCK_FILE);
38
33 $this->container->loginManager = $this->createMock(LoginManager::class); 39 $this->container->loginManager = $this->createMock(LoginManager::class);
34 40
35 $this->middleware = new ShaarliMiddleware($this->container); 41 $this->middleware = new ShaarliMiddleware($this->container);
36 } 42 }
37 43
44 public function tearDown()
45 {
46 unlink(static::TMP_MOCK_FILE);
47 }
48
38 /** 49 /**
39 * Test middleware execution with valid controller call 50 * Test middleware execution with valid controller call
40 */ 51 */
@@ -179,6 +190,7 @@ class ShaarliMiddlewareTest extends TestCase
179 $this->container->conf->method('get')->willReturnCallback(function (string $key): string { 190 $this->container->conf->method('get')->willReturnCallback(function (string $key): string {
180 return $key; 191 return $key;
181 }); 192 });
193 $this->container->conf->method('getConfigFileExt')->willReturn(static::TMP_MOCK_FILE);
182 194
183 $this->container->pageCacheManager = $this->createMock(PageCacheManager::class); 195 $this->container->pageCacheManager = $this->createMock(PageCacheManager::class);
184 $this->container->pageCacheManager->expects(static::once())->method('invalidateCaches'); 196 $this->container->pageCacheManager->expects(static::once())->method('invalidateCaches');