FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
SimpleElementTest.php
1 <?php
2 /*
3 Copyright (C) 2014, Siemens AG
4 Author: Andreas Würl
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 version 2 as published by the Free Software Foundation.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 
20 namespace Fossology\Lib\Html;
21 
22 class SimpleHtmlElementTest extends \PHPUnit\Framework\TestCase
23 {
24 
25  public function testElementWithoutAttributes()
26  {
27  $element = new SimpleHtmlElement("p");
28 
29  assertThat($element->getOpeningText(), is("<p>"));
30  assertThat($element->getClosingText(), is("</p>"));
31  }
32 
33  public function testElementWithSingleAttribute()
34  {
35  $element = new SimpleHtmlElement("p", array("class" => "extra"));
36 
37  assertThat($element->getOpeningText(), is("<p class=\"extra\">"));
38  assertThat($element->getClosingText(), is("</p>"));
39  }
40 
41  public function testElementWithSingleAttributeSetAfterConstruction()
42  {
43  $element = new SimpleHtmlElement("p");
44  $element->setAttribute("class", "other");
45 
46  assertThat($element->getOpeningText(), is("<p class=\"other\">"));
47  assertThat($element->getClosingText(), is("</p>"));
48  }
49 
50  public function testElementWithTwoAttributes()
51  {
52  $element = new SimpleHtmlElement("p", array("class" => "extra", "style" => "font-size: 10pt;"));
53 
54  assertThat($element->getOpeningText(), is("<p class=\"extra\" style=\"font-size: 10pt;\">"));
55  assertThat($element->getClosingText(), is("</p>"));
56  }
57 }