initTwig example

use Twig\Loader\FilesystemLoader;

/** * @internal */
class TwigSwIncludeTest extends TestCase
{
    use KernelTestBehaviour;

    public function testMultipleInheritance(): void
    {
        $twig = $this->initTwig([
            new BundleFixture('Storefront', __DIR__ . '/fixtures/Storefront/'),
            new BundleFixture('TestPlugin1', __DIR__ . '/fixtures/Plugins/TestPlugin1'),
            new BundleFixture('TestPlugin2', __DIR__ . '/fixtures/Plugins/TestPlugin2'),
        ]);

        $template = $twig->loadTemplate($twig->getTemplateClass('storefront/frontend/index.html.twig'), 'storefront/frontend/index.html.twig');
        static::assertSame('innerblockplugin2innerblockplugin1innerblock', $template->render([]));
    }

    public function testInterpolatedInheritance(): void
    {
        
$this->testAccessibilityForField($definition$field->getPropertyName()$definition->getEntityClass());
                $this->testAccessibilityForField($definition$field->getPropertyName(), PartialEntity::class);
            }
        }
    }

    private function testAccessibilityForField(EntityDefinition $definition, string $propertyName, string $entityClass): void
    {
        $entity = new $entityClass();
        $entity->internalSetEntityData($definition->getEntityName()$definition->getFieldVisibility());

        $twig = $this->initTwig($propertyName);

        $result = $twig->render('json-encode.twig', ['object' => $entity]);
        static::assertStringNotContainsString('password', $result);

        $result = $twig->render('get-vars.twig', ['object' => $entity]);
        static::assertStringNotContainsString('password', $result);

        $innerException = null;

        try {
            $twig->render('offset-get.twig', ['object' => $entity]);
        }
Home | Imprint | This part of the site doesn't use cookies.