FOSSology  4.4.0
Open Source License Compliance by Open Source Software
PagedTextResultTest.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\View;
10 
11 if (! function_exists('')) {
12  require_once (__DIR__ . "/../../common-string.php");
13 }
14 
15 class PagedTextResultTest extends \PHPUnit\Framework\TestCase
16 {
17 
18  const START_OFFSET = 15;
19 
21  private $pagedTextResult;
22 
23  protected function setUp() : void
24  {
25  $this->pagedTextResult = new PagedTextResult(self::START_OFFSET);
26  }
27 
28  public function testRenderContentTextEscapesForHtml()
29  {
30  $this->pagedTextResult->appendContentText("&");
31 
32  assertThat($this->pagedTextResult->getText(), is("&amp;"));
33  $this->addToAssertionCount(1);
34  }
35 
36  public function testRenderContentTextConvertsToUtf8()
37  {
38  $this->pagedTextResult->appendContentText("äöü");
39  $expected = htmlspecialchars("äöü", ENT_SUBSTITUTE, 'UTF-8');
40  assertThat($this->pagedTextResult->getText(), is(equalTo($expected)));
41  $this->addToAssertionCount(1);
42  }
43 }