getDeprecationNotice example


        $twig = $this->initEnv($script);

        $services = $this->initServices($hook$script);

        $twig->addGlobal('services', $services);

        $this->traces->trace($hook$scriptfunction DDebug $debug) use ($twig$script$hook): void {
            $twig->addGlobal('debug', $debug);

            if ($hook instanceof DeprecatedHook) {
                ScriptTraces::addDeprecationNotice($hook->getDeprecationNotice());
            }

            $template = $twig->load($script->getName());

            if (!$hook instanceof FunctionHook) {
                $template->render(['hook' => $hook]);

                return;
            }

            $blockName = $hook->getFunctionName();
            
$context = Context::createDefaultContext();
        $this->executor->execute(new DeprecatedTestHook('simple-function-case', $context['object' => $object]));

        static::assertTrue($object->has('foo'));
        static::assertEquals('bar', $object->get('foo'));

        $traces = $this->getScriptTraces();
        static::assertArrayHasKey('simple-function-case', $traces);
        static::assertCount(1, $traces['simple-function-case'][0]['deprecations']);
        static::assertEquals([
            DeprecatedTestHook::getDeprecationNotice() => 1,
        ]$traces['simple-function-case'][0]['deprecations']);
    }

    public function testAccessDeprecatedServiceOfHookTriggersDeprecation(): void
    {
        $this->loadAppsFromDir(__DIR__ . '/_fixtures');

        $context = Context::createDefaultContext();
        $this->executor->execute(new TestHook(
            'simple-service-script',
            $context,
            [],
Home | Imprint | This part of the site doesn't use cookies.