@@ -20,25 +20,25 @@ class ListTest extends \PHPUnit_Framework_TestCase
20
20
21
21
protected function setUp ()
22
22
{
23
- \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->get (' Magento\Framework\App\State ' )
23
+ \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->get (\ Magento \Framework \App \State::class )
24
24
->setAreaCode ('frontend ' );
25
25
$ this ->_block = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->get (
26
- ' Magento\Framework\View\LayoutInterface '
26
+ \ Magento \Framework \View \LayoutInterface::class
27
27
)->createBlock (
28
- ' Magento\Catalog\Block\Product\ListProduct '
28
+ \ Magento \Catalog \Block \Product \ListProduct::class
29
29
);
30
30
}
31
31
32
32
public function testGetLayer ()
33
33
{
34
- $ this ->assertInstanceOf (' Magento\Catalog\Model\Layer ' , $ this ->_block ->getLayer ());
34
+ $ this ->assertInstanceOf (\ Magento \Catalog \Model \Layer::class , $ this ->_block ->getLayer ());
35
35
}
36
36
37
37
public function testGetLoadedProductCollection ()
38
38
{
39
39
$ this ->_block ->setShowRootCategory (true );
40
40
$ collection = $ this ->_block ->getLoadedProductCollection ();
41
- $ this ->assertInstanceOf (' Magento\Catalog\Model\ResourceModel\Product\Collection ' , $ collection );
41
+ $ this ->assertInstanceOf (\ Magento \Catalog \Model \ResourceModel \Product \Collection::class , $ collection );
42
42
/* Check that root category was defined for Layer as current */
43
43
$ this ->assertEquals (2 , $ this ->_block ->getLayer ()->getCurrentCategory ()->getId ());
44
44
}
@@ -52,11 +52,11 @@ public function testGetLoadedProductCollection()
52
52
public function testToolbarCoverage ()
53
53
{
54
54
/** @var $parent \Magento\Catalog\Block\Product\ListProduct */
55
- $ parent = $ this ->_getLayout ()->createBlock (' Magento\Catalog\Block\Product\ListProduct ' , 'parent ' );
55
+ $ parent = $ this ->_getLayout ()->createBlock (\ Magento \Catalog \Block \Product \ListProduct::class , 'parent ' );
56
56
57
57
/* Prepare toolbar block */
58
58
$ toolbar = $ parent ->getToolbarBlock ();
59
- $ this ->assertInstanceOf (' Magento\Catalog\Block\Product\ProductList\Toolbar ' , $ toolbar , 'Default Toolbar ' );
59
+ $ this ->assertInstanceOf (\ Magento \Catalog \Block \Product \ProductList \Toolbar::class , $ toolbar , 'Default Toolbar ' );
60
60
61
61
$ parent ->setChild ('toolbar ' , $ toolbar );
62
62
/* In order to initialize toolbar collection block toHtml should be called before toolbar toHtml */
@@ -65,6 +65,29 @@ public function testToolbarCoverage()
65
65
$ this ->assertNotEmpty ($ parent ->getToolbarHtml (), 'Toolbar HTML ' ); /* toolbar for one simple product */
66
66
}
67
67
68
+ /**
69
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
70
+ * @magentoDataFixture Magento/Catalog/_files/product_simple_search_visibility.php
71
+ * @covers \Magento\Catalog\Block\Product\ListProduct::toHtml
72
+ */
73
+ public function testToolbarCoverageWithSearchOnlyProducts ()
74
+ {
75
+ /** @var $parent \Magento\Catalog\Block\Product\ListProduct */
76
+ $ parent = $ this ->_getLayout ()->createBlock (\Magento \Catalog \Block \Product \ListProduct::class, 'productList ' );
77
+
78
+ /* Prepare toolbar block */
79
+ $ toolbar = $ parent ->getToolbarBlock ();
80
+
81
+ $ parent ->setChild ('toolbar ' , $ toolbar );
82
+ /* In order to initialize toolbar collection block toHtml should be called */
83
+ $ this ->assertEmpty ($ parent ->toHtml (), 'Block HTML ' ); /* Template not specified */
84
+ $ this ->assertEquals (
85
+ 1 ,
86
+ $ parent ->getLoadedProductCollection ()->getSize (),
87
+ 'Search only products are invisible in catalog '
88
+ ); /* Search only products are invisible in catalog*/
89
+ }
90
+
68
91
public function testGetAdditionalHtmlEmpty ()
69
92
{
70
93
$ this ->_block ->setLayout ($ this ->_getLayout ());
@@ -75,9 +98,9 @@ public function testGetAdditionalHtml()
75
98
{
76
99
$ layout = $ this ->_getLayout ();
77
100
/** @var $parent \Magento\Catalog\Block\Product\ListProduct */
78
- $ parent = $ layout ->createBlock (' Magento\Catalog\Block\Product\ListProduct ' );
101
+ $ parent = $ layout ->createBlock (\ Magento \Catalog \Block \Product \ListProduct::class );
79
102
$ childBlock = $ layout ->createBlock (
80
- ' Magento\Framework\View\Element\Text ' ,
103
+ \ Magento \Framework \View \Element \Text::class ,
81
104
'test ' ,
82
105
['data ' => ['text ' => 'test ' ]]
83
106
);
@@ -102,7 +125,7 @@ public function testPrepareSortableFieldsByCategory()
102
125
{
103
126
/** @var $category \Magento\Catalog\Model\Category */
104
127
$ category = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
105
- ' Magento\Catalog\Model\Category '
128
+ \ Magento \Catalog \Model \Category::class
106
129
);
107
130
$ category ->setDefaultSortBy ('name ' );
108
131
$ this ->_block ->prepareSortableFieldsByCategory ($ category );
@@ -112,7 +135,7 @@ public function testPrepareSortableFieldsByCategory()
112
135
protected function _getLayout ()
113
136
{
114
137
return \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->get (
115
- ' Magento\Framework\View\LayoutInterface '
138
+ \ Magento \Framework \View \LayoutInterface::class
116
139
);
117
140
}
118
141
}
0 commit comments