File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
app/code/Magento/Catalog/view/frontend/templates/product/view
dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 15
15
<?php
16
16
$ _helper = $ this ->helper ('Magento\Catalog\Helper\Output ' );
17
17
$ _product = $ block ->getProduct ();
18
+
19
+ if (!$ _product instanceof \Magento \Catalog \Model \Product) {
20
+ return ;
21
+ }
22
+
18
23
$ _call = $ block ->getAtCall ();
19
24
$ _code = $ block ->getAtCode ();
20
25
$ _className = $ block ->getCssClass ();
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ namespace Magento \Catalog \Block \Product ;
7
+
8
+ use Magento \Framework \Registry ;
9
+ use Magento \TestFramework \Helper \Bootstrap ;
10
+
11
+ /**
12
+ * @magentoAppArea frontend
13
+ */
14
+ class DescriptionTest extends \PHPUnit_Framework_TestCase
15
+ {
16
+ /**
17
+ * @var View\Description
18
+ */
19
+ private $ block ;
20
+
21
+ /**
22
+ * @var Registry
23
+ */
24
+ private $ registry ;
25
+
26
+ protected function setUp ()
27
+ {
28
+ $ objectManager = Bootstrap::getObjectManager ();
29
+ $ this ->block = $ objectManager ->create (View \Description::class, [
30
+ 'data ' => [
31
+ 'template ' => 'Magento_Catalog::product/view/attribute.phtml '
32
+ ]
33
+ ]);
34
+
35
+ $ this ->registry = $ objectManager ->get (Registry::class);
36
+ $ this ->registry ->unregister ('product ' );
37
+ }
38
+
39
+ public function testGetProductWhenNoProductIsRegistered ()
40
+ {
41
+ $ html = $ this ->block ->toHtml ();
42
+ $ this ->assertEmpty ($ html );
43
+ }
44
+
45
+ public function testGetProductWhenInvalidProductIsRegistered ()
46
+ {
47
+ $ this ->registry ->register ('product ' , new \stdClass ());
48
+ $ html = $ this ->block ->toHtml ();
49
+ $ this ->assertEmpty ($ html );
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments