FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
PagedTextResultTest.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\View;
21 
22 if (! function_exists('')) {
23  require_once (__DIR__ . "/../../common-string.php");
24 }
25 
26 class PagedTextResultTest extends \PHPUnit\Framework\TestCase
27 {
28 
29  const START_OFFSET = 15;
30 
32  private $pagedTextResult;
33 
34  protected function setUp()
35  {
36  $this->pagedTextResult = new PagedTextResult(self::START_OFFSET);
37  }
38 
39  public function testRenderContentTextEscapesForHtml()
40  {
41  $this->pagedTextResult->appendContentText("&");
42 
43  assertThat($this->pagedTextResult->getText(), is("&amp;"));
44  $this->addToAssertionCount(1);
45  }
46 
47  public function testRenderContentTextConvertsToUtf8()
48  {
49  $this->pagedTextResult->appendContentText("äöü");
50  $expected = htmlspecialchars("äöü", ENT_SUBSTITUTE, 'UTF-8');
51  assertThat($this->pagedTextResult->getText(), is(equalTo($expected)));
52  $this->addToAssertionCount(1);
53  }
54 }