elastic example

$id = 'c1a28776116d4431a2208eb2960ec340';
        $this->createPromotion([
            'id' => $id,
            'name' => 'elasticsearch',
        ]);

        $this->indexElasticSearch(['--only' => ['promotion']]);

        $request = new Request();
        $request->request->set('term', 'elasticsearch');
        $request->request->set('entities', ['promotion']);
        $response = $this->controller->elastic($request, Context::createDefaultContext());

        static::assertEquals(200, $response->getStatusCode());

        $content = $response->getContent();
        static::assertNotFalse($content);

        $content = json_decode($content, true, 512, \JSON_THROW_ON_ERROR);

        static::assertNotEmpty($content['data']);
        static::assertNotEmpty($content['data']['promotion']);

        
$this->createMock(DefinitionInstanceRegistry::class),
            $this->createMock(JsonEntityEncoder::class),
            new AdminElasticsearchHelper(false, false, 'sw-admin')
        );

        $request = new Request();
        $request->attributes->set('term', 'test');

        $this->expectException(\RuntimeException::class);
        $this->expectExceptionMessage('Admin elasticsearch is not enabled');

        $controller->elastic($request, Context::createDefaultContext());
    }

    public function testElasticSearchWithEmptySearchTerm(): void
    {
        $controller = new AdminSearchController(
            $this->getMockBuilder(AdminSearcher::class)->disableOriginalConstructor()->getMock(),
            $this->createMock(DefinitionInstanceRegistry::class),
            $this->createMock(JsonEntityEncoder::class),
            new AdminElasticsearchHelper(true, false, 'sw-admin')
        );

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