Skip to content

Commit 9913d46

Browse files
committed
修復測試環境視圖快取權限問題
1 parent 89ff3ca commit 9913d46

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

tests/Feature/WikiMaintenanceControllerTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ protected function setUp(): void
2929
'prefix' => '',
3030
]);
3131

32+
// 指定可以寫入的編譯視圖目錄,避免預設目錄權限問題
33+
$compiledViewPath = storage_path('framework/testing-views');
34+
if (!is_dir($compiledViewPath)) {
35+
mkdir($compiledViewPath, 0777, true);
36+
}
37+
config(['view.compiled' => $compiledViewPath]);
38+
3239
// 设置缓存为数组驱动
3340
config(['cache.default' => 'array']);
3441

@@ -257,4 +264,4 @@ protected function tearDown(): void
257264
{
258265
parent::tearDown();
259266
}
260-
}
267+
}

tests/TestCase.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,16 @@
77
abstract class TestCase extends BaseTestCase
88
{
99
use CreatesApplication;
10+
11+
protected function setUp(): void
12+
{
13+
parent::setUp();
14+
15+
// Ensure Blade compiled views are written to a writable directory in the test sandbox.
16+
$compiledViewPath = storage_path('framework/testing-views');
17+
if (!is_dir($compiledViewPath)) {
18+
mkdir($compiledViewPath, 0777, true);
19+
}
20+
config(['view.compiled' => $compiledViewPath]);
21+
}
1022
}

0 commit comments

Comments
 (0)