FOSSology  4.4.0
Open Source License Compliance by Open Source Software
UrlBuilderTest.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\Lib\View;
9 
11 use Mockery as M;
12 
13 function Traceback_uri()
14 {
15  return "http://localhost/repo";
16 }
17 
18 class UrlBuilderTest extends \PHPUnit\Framework\TestCase
19 {
21  private $urlBuilder;
22 
23  protected function setUp() : void
24  {
25  $this->urlBuilder = new UrlBuilder();
26  }
27 
28  public function testGetLicenseTextLink()
29  {
30  $id = 432;
31  $shortName = "<shortName>";
32  $fullName = "<fullName>";
33 
34  $licenseRef = M::mock(LicenseRef::class);
35  $licenseRef->shouldReceive("getId")->once()->withNoArgs()->andReturn($id);
36  $licenseRef->shouldReceive("getShortName")->once()->withNoArgs()->andReturn($shortName);
37  $licenseRef->shouldReceive("getFullName")->once()->withNoArgs()->andReturn($fullName);
38 
39  $linkUrl = $this->urlBuilder->getLicenseTextUrl($licenseRef);
40 
41  assertThat($linkUrl, is("<a title=\"$fullName\" href=\"javascript:;\" " .
42  "onclick=\"javascript:window.open('http://localhost/repo?mod=popup-license&rf=$id'," .
43  "'License text','width=600,height=400,toolbar=no,scrollbars=yes,resizable=yes');\">$shortName</a>"));
44  }
45 }
Traceback_uri()
Get the URI without query to this location.
Definition: common-parm.php:97