ExtendedTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Test class for \Magento\Backend\Model\Url
  8. */
  9. namespace Magento\Backend\Test\Unit\Block\Widget\Grid;
  10. class ExtendedTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
  14. */
  15. protected $_objectManager;
  16. protected function setUp()
  17. {
  18. $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  19. }
  20. public function testPrepareLoadedCollection()
  21. {
  22. $request = $this->createPartialMock(\Magento\Framework\App\Request\Http::class, ['has']);
  23. $request->expects($this->any())->method('has')->will($this->returnValue(null));
  24. $columnSet = $this->createMock(\Magento\Backend\Block\Widget\Grid\ColumnSet::class);
  25. $layout = $this->createMock(\Magento\Framework\View\Layout::class);
  26. $layout->expects($this->any())->method('getChildName')->will($this->returnValue('grid.columnSet'));
  27. $layout->expects($this->any())->method('getBlock')->will($this->returnValue($columnSet));
  28. $collection = $this->createMock(\Magento\Framework\Data\Collection::class);
  29. $collection->expects($this->atLeastOnce())->method('isLoaded')->will($this->returnValue(true));
  30. $collection->expects($this->atLeastOnce())->method('clear');
  31. $collection->expects($this->atLeastOnce())->method('load');
  32. /** @var \Magento\Backend\Block\Widget\Grid\Extended $block */
  33. $block = $this->_objectManager->getObject(
  34. \Magento\Backend\Block\Widget\Grid\Extended::class,
  35. ['request' => $request, 'layout' => $layout]
  36. );
  37. $block->setCollection($collection);
  38. $block->getPreparedCollection();
  39. }
  40. }