| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace App\Tests\Unit\Service\Twig;
- use App\Entity\Core\File;
- use App\Service\File\FileManager;
- use App\Service\Twig\AssetsExtension;
- use App\Service\Utils\Path;
- use PHPUnit\Framework\TestCase;
- class AssetsExtensionTest extends TestCase
- {
- private FileManager $fileManager;
- public function setUp(): void {
- $this->fileManager = $this->getMockBuilder(FileManager::class)->disableOriginalConstructor()->getMock();
- }
- public function testGetFunctions(): void {
- $assetsExtension = $this
- ->getMockBuilder(AssetsExtension::class)
- ->setConstructorArgs([$this->fileManager])
- ->setMethodsExcept(['getFunctions'])
- ->getMock();
- $functions = $assetsExtension->getFunctions();
- $this->assertCount(2, $functions);
- $this->assertEquals('absPath', $functions[0]->getName());
- $this->assertEquals('fileImagePath', $functions[1]->getName());
- }
- public function testAbsPath(): void {
- $assetsExtension = $this
- ->getMockBuilder(AssetsExtension::class)
- ->setConstructorArgs([$this->fileManager])
- ->setMethodsExcept(['absPath'])
- ->getMock();
- $publicDir = Path::getProjectDir();
- $this->assertEquals(
- $publicDir . '/public/foo',
- $assetsExtension->absPath('foo')
- );
- $this->assertEquals(
- $publicDir . '/public/foo/bar',
- $assetsExtension->absPath('foo/bar')
- );
- $this->assertEquals(
- $publicDir . '/public',
- $assetsExtension->absPath('')
- );
- }
- }
|