55 */
66namespace Magento \Backend \Block \Widget \Grid ;
77
8+ use Laminas \Stdlib \Parameters ;
9+ use Magento \Backend \Block \Template \Context ;
10+ use Magento \Framework \Data \Collection ;
11+ use Magento \Framework \View \LayoutInterface ;
12+ use Magento \TestFramework \Helper \Bootstrap ;
13+ use PHPUnit \Framework \TestCase ;
14+
815/**
916 * @magentoAppArea adminhtml
1017 */
11- class ExtendedTest extends \ PHPUnit \ Framework \ TestCase
18+ class ExtendedTest extends TestCase
1219{
1320 /**
14- * @var \Magento\Backend\Block\Widget\Grid\ Extended
21+ * @var Extended
1522 */
1623 protected $ _block ;
1724
1825 /**
19- * @var \Magento\Framework\View\ LayoutInterface
26+ * @var LayoutInterface
2027 */
2128 protected $ _layoutMock ;
2229
30+ /**
31+ * @inheritDoc
32+ */
2333 protected function setUp (): void
2434 {
2535 parent ::setUp ();
2636
27- $ this ->_layoutMock = \ Magento \ TestFramework \ Helper \ Bootstrap::getObjectManager ()->get (
28- \ Magento \ Framework \ View \ LayoutInterface::class
37+ $ this ->_layoutMock = Bootstrap::getObjectManager ()->get (
38+ LayoutInterface::class
2939 );
30- $ context = \ Magento \ TestFramework \ Helper \ Bootstrap::getObjectManager ()->create (
31- \ Magento \ Backend \ Block \ Template \ Context::class,
40+ $ context = Bootstrap::getObjectManager ()->create (
41+ Context::class,
3242 ['layout ' => $ this ->_layoutMock ]
3343 );
3444 $ this ->_block = $ this ->_layoutMock ->createBlock (
35- \ Magento \ Backend \ Block \ Widget \ Grid \ Extended::class,
45+ Extended::class,
3646 'grid ' ,
3747 ['context ' => $ context ]
3848 );
@@ -47,7 +57,7 @@ protected function setUp(): void
4757 public function testAddColumnAddsChildToColumnSet ()
4858 {
4959 $ this ->assertInstanceOf (
50- \ Magento \ Backend \ Block \ Widget \ Grid \ Column::class,
60+ Column::class,
5161 $ this ->_block ->getColumnSet ()->getChildBlock ('column1 ' )
5262 );
5363 $ this ->assertCount (2 , $ this ->_block ->getColumnSet ()->getChildNames ());
@@ -84,4 +94,32 @@ public function testGetMainButtonsHtmlReturnsEmptyStringIfFiltersArentVisible()
8494 $ this ->_block ->setFilterVisibility (false );
8595 $ this ->assertEquals ('' , $ this ->_block ->getMainButtonsHtml ());
8696 }
97+
98+ /**
99+ * Checks that template does not have redundant div close tag
100+ *
101+ * @return void
102+ */
103+ public function testExtendedTemplateMarkup (): void
104+ {
105+ $ mockCollection = $ this ->getMockBuilder (Collection::class)
106+ ->disableOriginalConstructor ()
107+ ->getMock ();
108+ $ this ->_block ->setCollection ($ mockCollection );
109+ $ this ->_block ->getRequest ()
110+ ->setQuery (
111+ Bootstrap::getObjectManager ()
112+ ->create (
113+ Parameters::class,
114+ [
115+ 'values ' => [
116+ 'ajax ' => true
117+ ]
118+ ]
119+ )
120+ );
121+ $ html = $ this ->_block ->getHtml ();
122+ $ html = str_replace (["\n" , " " ], '' , $ html );
123+ $ this ->assertStringEndsWith ("</table></div> " , $ html );
124+ }
87125}
0 commit comments