public function testSyncCustomerGrid() { $gridTable = 'customer_grid_flat'; $customerLogTable = 'customer_log'; $this->indexerRegistry->expects($this->once())->method('get')->with(\Magento\Customer\Model\Customer::CUSTOMER_GRID_INDEXER_ID)->willReturn($this->indexer); $this->resource->expects($this->once())->method('getConnection')->willReturn($this->connection); $this->flatScopeResolver->expects($this->once())->method('resolve')->with(\Magento\Customer\Model\Customer::CUSTOMER_GRID_INDEXER_ID, [])->willReturn($gridTable); $this->resource->expects($this->exactly(2))->method('getTableName')->willReturnMap([[$gridTable], [$customerLogTable]]); $this->connection->expects($this->exactly(2))->method('select')->willReturn($this->select); $this->select->expects($this->exactly(2))->method('from')->willReturnSelf(); $this->select->expects($this->once())->method('order')->with('last_visit_at DESC')->willReturnSelf(); $this->select->expects($this->once())->method('limit')->with(1)->willReturnSelf(); $this->connection->expects($this->atLeastOnce())->method('query')->with($this->select)->willReturn($this->queryResult); $this->queryResult->expects($this->once())->method('fetchColumn')->willReturn('2015-08-13 10:36:44'); $this->select->expects($this->once())->method('where')->with('last_login_at > ?', '2015-08-13 10:36:44')->willReturnSelf(); $this->queryResult->expects($this->once())->method('fetchAll')->willReturn([['customer_id' => 23], ['customer_id' => 65]]); $this->indexer->expects($this->once())->method('reindexList')->with(['23', '65']); $this->observer->syncCustomerGrid(); }
/** * @return void */ public function syncCustomerGrid() { $this->customerGrid->syncCustomerGrid(); }