-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a test for AssetPathExtractor service
- Ensured build/index.html exists in constructor
- Loading branch information
Showing
4 changed files
with
50 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\Tests\Service; | ||
|
||
use App\Service\AssetPathExtractor; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class AssetPathExtractorTest extends TestCase | ||
{ | ||
private LoggerInterface $loggerMock; | ||
private string $indexPath = 'tests/mock/index.html'; | ||
private string $buildDir = '/build/'; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->loggerMock = $this->createMock(LoggerInterface::class); | ||
} | ||
|
||
public function testGetScriptPath(): void | ||
{ | ||
$extractor = new AssetPathExtractor($this->indexPath, $this->buildDir, $this->loggerMock); | ||
$this->assertEquals($this->buildDir . 'runtime.abcdef.js', $extractor->getScriptPath('runtime')); | ||
$this->assertEquals($this->buildDir . 'main.789012.js', $extractor->getScriptPath('main')); | ||
} | ||
|
||
public function testGetCssPath(): void | ||
{ | ||
$extractor = new AssetPathExtractor($this->indexPath, $this->buildDir, $this->loggerMock); | ||
$this->assertEquals($this->buildDir . 'styles.123456.css', $extractor->getCssPath('styles')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="styles.123456.css" /> | ||
</head> | ||
<body> | ||
<script src="runtime.abcdef.js" type="module"></script> | ||
<script src="main.789012.js" type="module"></script> | ||
</body> | ||
</html> |