createMock(\Magento\Backend\Block\Dashboard\Orders\Grid::class); $layout = $this->createMock(\Magento\Framework\View\LayoutInterface::class); $layout->expects($this->atLeastOnce())->method('getChildName')->willReturn('test'); $layout->expects($this->atLeastOnce())->method('getBlock')->willReturn($block); $context = $objectManager->create(Context::class, ['layout' => $layout]); $this->block = $objectManager->create(Grid::class, ['context' => $context]); } /** * @magentoDataFixture Magento/Sales/_files/order.php */ public function testGetPreparedCollection() { $collection = $this->block->getPreparedCollection(); foreach ($collection->getItems() as $item) { if ($item->getIncrementId() == '100000001') { $this->assertEquals('firstname lastname', $item->getCustomer()); } } } }