FrameworkBundle example

public function boot(): void
    {
        parent::boot();
        $this->ensureComposerHomeVarIsSet();
    }

    /** * @return \Generator<BundleInterface> */
    public function registerBundles(): \Generator
    {
        yield new FrameworkBundle();
        yield new TwigBundle();
        yield new Installer();
    }

    public function getProjectDir(): string
    {
        $r = new \ReflectionObject($this);

        /** @var string $dir */
        $dir = $r->getFileName();
        if (!file_exists($dir)) {
            

        $elasticsearch = new Elasticsearch();

        static::assertEquals(-1, $elasticsearch->getTemplatePriority());
    }

    public function testBundle(): void
    {
        $container = new ContainerBuilder();
        $container->setParameter('kernel.environment', 'prod');

        $framework = new FrameworkBundle();
        $frameworkExtension = $framework->getContainerExtension();
        static::assertNotNull($frameworkExtension);
        $container->registerExtension($frameworkExtension);

        $bundle = new Elasticsearch();
        $extension = $bundle->getContainerExtension();
        static::assertInstanceOf(ExtensionInterface::class$extension);
        $container->registerExtension($extension);
        $bundle->build($container);

        static::assertTrue($container->hasDefinition(ElasticsearchIndexer::class));
    }
#[Package('core')] class Kernel extends BaseKernel
{
    use MicroKernelTrait;

    /** * @return BundleInterface[] */
    public function registerBundles(): array
    {
        return [
            new FrameworkBundle(),
            new TwigBundle(),
        ];
    }

    public function getProjectDir(): string
    {
        return __DIR__;
    }

    public function getLogDir(): string
    {
        
use Shopware\Core\Framework\Test\Plugin\_fixture\bundles\FooBarBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;

class SwagTestWithBundle extends Plugin
{
    public function getAdditionalBundles(AdditionalBundleParameters $parameters): array
    {
        require_once __DIR__ . '/../../../bundles/FooBarBundle.php';

        return [
            // is already provided externally and should not be loaded             new FrameworkBundle(),
            // is already provided by SwagTest and should not be loaded twice             new FooBarBundle(),
        ];
    }
}
/** * @internal * * @covers \Shopware\Administration\Command\DeleteExtensionLocalPublicFilesCommand */
class DeleteExtensionLocalPublicFilesCommandTest extends TestCase
{
    public function testSymfonyBundle(): void
    {
        $kernel = $this->createMock(KernelInterface::class);
        $kernel->method('getBundles')->willReturn([
            new FrameworkBundle(),
        ]);

        $command = new DeleteExtensionLocalPublicFilesCommand($kernel);
        $tester = new CommandTester($command);

        $tester->execute([]);
        $tester->assertCommandIsSuccessful();
        static::assertSame('', $tester->getDisplay());
    }

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