Version 1
[yaffs-website] / web / core / modules / views / tests / src / Kernel / Plugin / StyleTestBase.php
1 <?php
2
3 namespace Drupal\Tests\views\Kernel\Plugin;
4
5 use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
6 use Masterminds\HTML5;
7
8 /**
9  * Tests some general style plugin related functionality.
10  */
11 abstract class StyleTestBase extends ViewsKernelTestBase {
12
13   /**
14    * Stores the SimpleXML representation of the output.
15    *
16    * @var \SimpleXMLElement
17    */
18   protected $elements;
19
20   /**
21    * Stores a view output in the elements.
22    */
23   public function storeViewPreview($output) {
24     $html5 = new HTML5();
25     $htmlDom = $html5->loadHTML('<html><body>' . $output . '</body></html>');
26     if ($htmlDom) {
27       // It's much easier to work with simplexml than DOM, luckily enough
28       // we can just simply import our DOM tree.
29       $this->elements = simplexml_import_dom($htmlDom);
30     }
31   }
32
33 }