GridTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Block\Dashboard\Orders;
  7. use Magento\Backend\Block\Template\Context;
  8. class GridTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var Grid
  12. */
  13. private $block;
  14. protected function setUp()
  15. {
  16. parent::setUp();
  17. $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  18. $block = $this->createMock(\Magento\Backend\Block\Dashboard\Orders\Grid::class);
  19. $layout = $this->createMock(\Magento\Framework\View\LayoutInterface::class);
  20. $layout->expects($this->atLeastOnce())->method('getChildName')->willReturn('test');
  21. $layout->expects($this->atLeastOnce())->method('getBlock')->willReturn($block);
  22. $context = $objectManager->create(Context::class, ['layout' => $layout]);
  23. $this->block = $objectManager->create(Grid::class, ['context' => $context]);
  24. }
  25. /**
  26. * @magentoDataFixture Magento/Sales/_files/order.php
  27. */
  28. public function testGetPreparedCollection()
  29. {
  30. $collection = $this->block->getPreparedCollection();
  31. foreach ($collection->getItems() as $item) {
  32. if ($item->getIncrementId() == '100000001') {
  33. $this->assertEquals('firstname lastname', $item->getCustomer());
  34. }
  35. }
  36. }
  37. }