getScriptTraces example


        $this->loadAppsFromDir(__DIR__ . '/_fixtures');

        $this->kernelBrowser = null;
        $browser = $this->getBrowser();
        $browser->request('POST', '/api/script/simple-script');

        static::assertNotFalse($browser->getResponse()->getContent());
        $response = \json_decode($browser->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);
        static::assertSame(Response::HTTP_OK, $browser->getResponse()->getStatusCode()print_r($response, true));

        $traces = $this->getScriptTraces();
        static::assertArrayHasKey('api-simple-script', $traces);
        static::assertCount(1, $traces['api-simple-script']);
        static::assertSame('some debug information', $traces['api-simple-script'][0]['output'][0]);

        static::assertArrayHasKey('foo', $response);
        static::assertEquals('bar', $response['foo']);
    }

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

        
$browser = $this->getSalesChannelBrowser();
        $browser->request('POST', '/store-api/script/blog', $criteria);

        $response = \json_decode((string) $browser->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        $salesChannelId = $browser->getServerParameter('test-sales-channel-id');
        $this->getContainer()->get(Connection::class)->executeStatement('DELETE FROM sales_channel WHERE id = :id', ['id' => Uuid::fromHexToBytes($salesChannelId)]);

        static::assertSame(Response::HTTP_OK, $browser->getResponse()->getStatusCode()print_r($response, true));

        $traces = $this->getScriptTraces();
        static::assertArrayHasKey('store-api-blog::response', $traces);
        static::assertCount(1, $traces['store-api-blog::response']);
        static::assertSame('some debug information', $traces['store-api-blog::response'][0]['output'][0]);

        $expected = [
            'apiAlias' => 'store_api_blog_response',
            'blogs' => [
                'apiAlias' => 'dal_entity_search_result',
                'elements' => [
                    [
                        'id' => $ids->get('blog-3'),
                        
public function testGetApiEndpoint(): void
    {
        $this->loadAppsFromDir(__DIR__ . '/fixtures/Apps');

        $response = $this->request('GET', '/storefront/script/json-response', []);
        static::assertNotFalse($response->getContent());

        $body = \json_decode($response->getContent(), true, 512, \JSON_THROW_ON_ERROR);
        static::assertSame(Response::HTTP_OK, $response->getStatusCode()print_r($body, true));

        $traces = $this->getScriptTraces();
        static::assertArrayHasKey('storefront-json-response', $traces);
        static::assertCount(1, $traces['storefront-json-response']);
        static::assertSame('some debug information', $traces['storefront-json-response'][0]['output'][0]);

        static::assertArrayHasKey('foo', $body);
        static::assertEquals('bar', $body['foo']);
    }

    public function testGetApiEndpointWithSlashInHookName(): void
    {
        $this->loadAppsFromDir(__DIR__ . '/fixtures/Apps');

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

        $this->browser->request('POST', '/store-api/script/simple-script');
        static::assertNotFalse($this->browser->getResponse()->getContent());

        $response = \json_decode($this->browser->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);
        static::assertSame(Response::HTTP_OK, $this->browser->getResponse()->getStatusCode()$this->browser->getResponse()->getContent());

        $traces = $this->getScriptTraces();
        static::assertArrayHasKey('store-api-simple-script::response', $traces);
        static::assertCount(1, $traces['store-api-simple-script::response']);
        static::assertSame('some debug information', $traces['store-api-simple-script::response'][0]['output'][0]);

        static::assertArrayHasKey('apiAlias', $response);
        static::assertArrayHasKey('foo', $response);
        static::assertEquals('bar', $response['foo']);
        static::assertSame('store_api_simple_script_response', $response['apiAlias']);
    }

    public function testApiEndpointWithSlashInHookName(): void
    {

        $this->loadAppsFromDir(__DIR__ . '/_fixtures');

        $object = new ArrayStruct();

        $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');

        
Home | Imprint | This part of the site doesn't use cookies.