get('Magento\Framework\App\State')->setAreaCode('adminhtml'); $this->coreRegistry = $objectManager->get('Magento\Framework\Registry'); $this->coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); $this->block = $objectManager->get( 'Magento\Framework\View\LayoutInterface' )->createBlock( 'Magento\Customer\Block\Adminhtml\Edit\Tab\Orders', '', ['coreRegistry' => $this->coreRegistry] ); $this->block->getPreparedCollection(); } /** * Execute post test cleanup. */ public function tearDown() { $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); $this->block->setCollection(null); } /** * Verify that a valid Url is returned for a given sales order row. */ public function testGetRowUrl() { $row = new \Magento\Framework\DataObject(['id' => 1]); $this->assertContains('sales/order/view/order_id/1', $this->block->getRowUrl($row)); } /** * Verify that a valid grid Url is returned. */ public function testGetGridUrl() { $this->assertContains('customer/index/orders', $this->block->getGridUrl()); } /** * Verify that the sales order grid Html is valid and contains no records. */ public function testToHtml() { $this->assertContains("We couldn't find any records.", $this->block->toHtml()); } }