ProductAdminSearchIndexer example

private AdminSearcher $searcher;

    private AdminSearchRegistry&MockObject $registry;

    protected function setUp(): void
    {
        $this->client = $this->createMock(Client::class);

        $this->registry = $this->getMockBuilder(AdminSearchRegistry::class)->disableOriginalConstructor()->getMock();

        $indexer = new ProductAdminSearchIndexer(
            $this->createMock(Connection::class),
            $this->createMock(IteratorFactory::class),
            $this->createMock(EntityRepository::class),
            100,
        );
        $this->registry->method('getIndexers')->willReturn(['product' => $indexer]);
        $this->registry->method('getIndexer')->willReturn($indexer);

        $searchHelper = new AdminElasticsearchHelper(true, false, 'sw-admin');
        $this->searcher = new AdminSearcher($this->client, $this->registry, $searchHelper, '5s', 20);
    }

    

class ProductAdminSearchIndexerTest extends TestCase
{
    private ProductAdminSearchIndexer $searchIndexer;

    protected function setUp(): void
    {
        $this->searchIndexer = new ProductAdminSearchIndexer(
            $this->createMock(Connection::class),
            $this->createMock(IteratorFactory::class),
            $this->createMock(EntityRepository::class),
            100
        );
    }

    public function testGetEntity(): void
    {
        static::assertSame(ProductDefinition::ENTITY_NAME, $this->searchIndexer->getEntity());
    }

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