Skip to content

Commit 621afe4

Browse files
author
Serhii Balko
committed
Merge remote-tracking branch 'origin/MC-39037' into 2.4-develop-pr48
2 parents 7a6f1d4 + fa76d92 commit 621afe4

File tree

2 files changed

+51
-10
lines changed
  • app/code/Magento/Backend/view/adminhtml/templates/widget/grid
  • dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid

2 files changed

+51
-10
lines changed

app/code/Magento/Backend/view/adminhtml/templates/widget/grid/extended.phtml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
* getPagerVisibility()
1515
* getVarNamePage()
1616
*/
17-
$numColumns = count($block->getColumns());
1817

1918
/**
2019
* @var \Magento\Backend\Block\Widget\Grid\Extended $block
2120
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
2221
*/
22+
$numColumns = count($block->getColumns());
23+
2324
?>
2425
<?php if ($block->getCollection()): ?>
2526
<?php if ($block->canDisplayContainer()): ?>
@@ -285,7 +286,9 @@ $numColumns = count($block->getColumns());
285286
</table>
286287

287288
</div>
289+
<?php if ($block->canDisplayContainer()): ?>
288290
</div>
291+
<?php endif; ?>
289292
<?php
290293
/** @var \Magento\Framework\Json\Helper\Data $jsonHelper */
291294
$jsonHelper = $block->getData('jsonHelper');

dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Grid/ExtendedTest.php

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,44 @@
55
*/
66
namespace 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

Comments
 (0)