FOSSology  4.4.0
Open Source License Compliance by Open Source Software
SimpleElementTest.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014 Siemens AG
4  Author: Andreas Würl
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
9 namespace Fossology\Lib\Html;
10 
11 class SimpleElementTest extends \PHPUnit\Framework\TestCase
12 {
13 
14  public function testElementWithoutAttributes()
15  {
16  $element = new SimpleHtmlElement("p");
17 
18  assertThat($element->getOpeningText(), is("<p>"));
19  assertThat($element->getClosingText(), is("</p>"));
20  }
21 
22  public function testElementWithSingleAttribute()
23  {
24  $element = new SimpleHtmlElement("p", array("class" => "extra"));
25 
26  assertThat($element->getOpeningText(), is("<p class=\"extra\">"));
27  assertThat($element->getClosingText(), is("</p>"));
28  }
29 
30  public function testElementWithSingleAttributeSetAfterConstruction()
31  {
32  $element = new SimpleHtmlElement("p");
33  $element->setAttribute("class", "other");
34 
35  assertThat($element->getOpeningText(), is("<p class=\"other\">"));
36  assertThat($element->getClosingText(), is("</p>"));
37  }
38 
39  public function testElementWithTwoAttributes()
40  {
41  $element = new SimpleHtmlElement("p", array("class" => "extra", "style" => "font-size: 10pt;"));
42 
43  assertThat($element->getOpeningText(), is("<p class=\"extra\" style=\"font-size: 10pt;\">"));
44  assertThat($element->getClosingText(), is("</p>"));
45  }
46 }