AssetMapperTestAppKernel example

namespace Command;

use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\AssetMapper\Tests\fixtures\AssetMapperTestAppKernel;
use Symfony\Component\Console\Tester\CommandTester;

class DebugAssetsMapperCommandTest extends TestCase
{
    public function testCommandDumpsInformation()
    {
        $application = new Application(new AssetMapperTestAppKernel('test', true));

        $command = $application->find('debug:asset-map');
        $tester = new CommandTester($command);
        $res = $tester->execute([]);
        $this->assertSame(0, $res);

        $this->assertStringContainsString('dir1', $tester->getDisplay());
        $this->assertStringContainsString('subdir/file6.js', $tester->getDisplay());
        $this->assertStringContainsString('dir2'.\DIRECTORY_SEPARATOR.'subdir'.\DIRECTORY_SEPARATOR.'file6.js', $tester->getDisplay());
    }
}
namespace Symfony\Component\AssetMapper\Tests;

use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Asset\Packages;
use Symfony\Component\AssetMapper\Tests\fixtures\AssetMapperTestAppKernel;

class MapperAwareAssetPackageIntegrationTest extends KernelTestCase
{
    public function testDefaultAssetPackageIsDecorated()
    {
        $kernel = new AssetMapperTestAppKernel('test', true);
        $kernel->boot();

        $packages = $kernel->getContainer()->get('public.assets.packages');
        \assert($packages instanceof Packages);
        $this->assertSame('/assets/file1-b3445cb7a86a0795a7af7f2004498aef.css', $packages->getUrl('file1.css'));
        $this->assertSame('/non-existent.css', $packages->getUrl('non-existent.css'));
    }
}
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;

class AssetsMapperCompileCommandTest extends TestCase
{
    private AssetMapperTestAppKernel $kernel;
    private Filesystem $filesystem;

    protected function setUp(): void
    {
        $this->filesystem = new Filesystem();
        $this->kernel = new AssetMapperTestAppKernel('test', true);
        $this->filesystem->mkdir($this->kernel->getProjectDir().'/public');
    }

    protected function tearDown(): void
    {
        $this->filesystem->remove($this->kernel->getProjectDir().'/public');
        $this->filesystem->remove($this->kernel->getProjectDir().'/var');
    }

    public function testAssetsAreCompiled()
    {
        
Home | Imprint | This part of the site doesn't use cookies.