5
5
*/
6
6
namespace Magento \Backend \Block \Widget \Grid ;
7
7
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
+
8
15
/**
9
16
* @magentoAppArea adminhtml
10
17
*/
11
- class ExtendedTest extends \ PHPUnit \ Framework \ TestCase
18
+ class ExtendedTest extends TestCase
12
19
{
13
20
/**
14
- * @var \Magento\Backend\Block\Widget\Grid\ Extended
21
+ * @var Extended
15
22
*/
16
23
protected $ _block ;
17
24
18
25
/**
19
- * @var \Magento\Framework\View\ LayoutInterface
26
+ * @var LayoutInterface
20
27
*/
21
28
protected $ _layoutMock ;
22
29
30
+ /**
31
+ * @inheritDoc
32
+ */
23
33
protected function setUp (): void
24
34
{
25
35
parent ::setUp ();
26
36
27
- $ this ->_layoutMock = \ Magento \ TestFramework \ Helper \ Bootstrap::getObjectManager ()->get (
28
- \ Magento \ Framework \ View \ LayoutInterface::class
37
+ $ this ->_layoutMock = Bootstrap::getObjectManager ()->get (
38
+ LayoutInterface::class
29
39
);
30
- $ context = \ Magento \ TestFramework \ Helper \ Bootstrap::getObjectManager ()->create (
31
- \ Magento \ Backend \ Block \ Template \ Context::class,
40
+ $ context = Bootstrap::getObjectManager ()->create (
41
+ Context::class,
32
42
['layout ' => $ this ->_layoutMock ]
33
43
);
34
44
$ this ->_block = $ this ->_layoutMock ->createBlock (
35
- \ Magento \ Backend \ Block \ Widget \ Grid \ Extended::class,
45
+ Extended::class,
36
46
'grid ' ,
37
47
['context ' => $ context ]
38
48
);
@@ -47,7 +57,7 @@ protected function setUp(): void
47
57
public function testAddColumnAddsChildToColumnSet ()
48
58
{
49
59
$ this ->assertInstanceOf (
50
- \ Magento \ Backend \ Block \ Widget \ Grid \ Column::class,
60
+ Column::class,
51
61
$ this ->_block ->getColumnSet ()->getChildBlock ('column1 ' )
52
62
);
53
63
$ this ->assertCount (2 , $ this ->_block ->getColumnSet ()->getChildNames ());
@@ -84,4 +94,32 @@ public function testGetMainButtonsHtmlReturnsEmptyStringIfFiltersArentVisible()
84
94
$ this ->_block ->setFilterVisibility (false );
85
95
$ this ->assertEquals ('' , $ this ->_block ->getMainButtonsHtml ());
86
96
}
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
+ }
87
125
}
0 commit comments