GridTest.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\UrlRewrite\Block\Cms\Page;
  7. /**
  8. * Test for \Magento\UrlRewrite\Block\Cms\Page\Grid
  9. * @magentoAppArea adminhtml
  10. */
  11. class GridTest extends \PHPUnit\Framework\TestCase
  12. {
  13. /**
  14. * Test prepare grid
  15. */
  16. public function testPrepareGrid()
  17. {
  18. /** @var \Magento\UrlRewrite\Block\Cms\Page\Grid $gridBlock */
  19. $gridBlock = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  20. \Magento\Framework\View\LayoutInterface::class
  21. )->createBlock(
  22. \Magento\UrlRewrite\Block\Cms\Page\Grid::class
  23. );
  24. $gridBlock->toHtml();
  25. foreach (['title', 'identifier', 'is_active'] as $key) {
  26. $this->assertInstanceOf(
  27. \Magento\Backend\Block\Widget\Grid\Column::class,
  28. $gridBlock->getColumn($key),
  29. 'Column with key "' . $key . '" is invalid'
  30. );
  31. }
  32. $this->assertStringStartsWith('http://localhost/index.php', $gridBlock->getGridUrl(), 'Grid URL is invalid');
  33. $row = new \Magento\Framework\DataObject(['id' => 1]);
  34. $this->assertStringStartsWith(
  35. 'http://localhost/index.php/backend/admin/index/edit/cms_page/1',
  36. $gridBlock->getRowUrl($row),
  37. 'Grid row URL is invalid'
  38. );
  39. $this->assertEmpty(0, $gridBlock->getMassactionBlock()->getItems(), 'Grid should not have mass action items');
  40. $this->assertTrue($gridBlock->getUseAjax(), '"use_ajax" value of grid is incorrect');
  41. }
  42. /**
  43. * Test prepare grid when there is more than one store
  44. *
  45. * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
  46. */
  47. public function testPrepareGridForMultipleStores()
  48. {
  49. /** @var \Magento\UrlRewrite\Block\Cms\Page\Grid $gridBlock */
  50. $gridBlock = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  51. \Magento\Framework\View\LayoutInterface::class
  52. )->createBlock(
  53. \Magento\UrlRewrite\Block\Cms\Page\Grid::class
  54. );
  55. $gridBlock->toHtml();
  56. $this->assertInstanceOf(
  57. \Magento\Backend\Block\Widget\Grid\Column::class,
  58. $gridBlock->getColumn('store_id'),
  59. 'When there is more than one store column with key "store_id" should be present'
  60. );
  61. }
  62. }