1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Dashboard\Orders;
use Magento\Backend\Block\Template\Context;
class GridTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Grid
*/
private $block;
protected function setUp()
{
parent::setUp();
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$block = $this->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());
}
}
}
}