Skip to content
This repository was archived by the owner on Aug 21, 2026. It is now read-only.

Commit b3a8852

Browse files
committed
add test
1 parent c3c10e0 commit b3a8852

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

src/View/Helper/ViteUrl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private function hotServer(): string | null
9999
return null;
100100
}
101101

102-
$content = file_get_contents($this->publicDir . '/hot');
102+
$content = @file_get_contents($this->publicDir . '/hot');
103103

104104
if (!$content) {
105105
return null;

tests/View/Helper/ViteUrlTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,43 @@ public function testFileWithHotRelaoding3(): void
188188
$object->file($name);
189189
}
190190

191+
/**
192+
* @throws Exception
193+
* @throws RuntimeException
194+
* @throws NoPreviousThrowableException
195+
* @throws \PHPUnit\Framework\MockObject\Exception
196+
*/
197+
public function testFileWithHotRelaoding4(): void
198+
{
199+
$root = vfsStream::setup('root');
200+
$name = 'test.js';
201+
$buildDir = 'test-build-dir';
202+
203+
$file1 = vfsStream::newFile('hot', 0333);
204+
$file1->setContent('');
205+
206+
$root->addChild($file1);
207+
208+
$manifestPathV4 = $root->url() . '/' . $buildDir . '/manifest.json';
209+
$manifestPathV5 = $root->url() . '/' . $buildDir . '/.vite/manifest.json';
210+
211+
$object = new ViteUrl($root->url(), $buildDir);
212+
213+
$view = $this->createMock(PhpRenderer::class);
214+
$view->expects(self::never())
215+
->method('__call');
216+
217+
$object->setView($view);
218+
219+
$this->expectException(RuntimeException::class);
220+
$this->expectExceptionCode(0);
221+
$this->expectExceptionMessage(
222+
sprintf('Vite manifest not found at %s or at %s', $manifestPathV4, $manifestPathV5),
223+
);
224+
225+
$object->file($name);
226+
}
227+
191228
/**
192229
* @throws Exception
193230
* @throws RuntimeException

0 commit comments

Comments
 (0)