Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PhtmlTemplateTest.php
Go to the documentation of this file.
1 <?php
8 namespace Magento\Test\Legacy;
9 
10 class PhtmlTemplateTest extends \PHPUnit\Framework\TestCase
11 {
13  {
14  $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
15  $invoker(
21  function ($file) {
22  $this->assertNotRegExp(
23  '/this->(?!helper)\S*/iS',
24  file_get_contents($file),
25  'Access to members and methods of Block class through $this is ' .
26  'obsolete in phtml templates. Use only $block instead of $this.'
27  );
28  },
30  );
31  }
32 
33  public function testObsoleteBlockMethods()
34  {
35  $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
36  $invoker(
48  function ($file) {
49  $this->assertNotRegexp(
50  '/block->_[^_]+\S*\(/iS',
51  file_get_contents($file),
52  'Access to protected and private members of Block class is ' .
53  'obsolete in phtml templates. Use only public members.'
54  );
55  },
57  );
58  }
59 
61  {
62  $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
63  $invoker(
70  function ($file) {
71  $this->assertNotRegexp(
72  '/type="text\/javascript"/',
73  file_get_contents($file),
74  'Please do not use "text/javascript" type attribute.'
75  );
76  },
78  );
79  }
80 }