Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BlockNamesTest.php
Go to the documentation of this file.
1 <?php
10 
11 class BlockNamesTest extends \PHPUnit\Framework\TestCase
12 {
13  public function testBlocksHasName()
14  {
15  $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
16  $invoker(
22  function ($layoutFile) {
23  $dom = new \DOMDocument();
24  $dom->load($layoutFile);
25  $xpath = new \DOMXpath($dom);
26  $count = $xpath->query('//block[not(@name)]')->length;
27 
28  if ($count) {
29  $this->fail('Following file contains ' . $count . ' blocks without name. ' .
30  'File Path:' . "\n" . $layoutFile);
31  }
32  },
34  );
35  }
36 }
$count
Definition: recent.phtml:13