FOSSology  4.5.1
Open Source License Compliance by Open Source Software
ScanCodeTest.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2024 Valens Niyonsenga <valensniyonsenga2003@gmail.com>
4  SPDX-License-Identifier: GPL-2.0-only
5 */
6 
12 
14 use Monolog\Test\TestCase;
15 
16 class ScanCodeTest extends TestCase
17 {
19 
25  public function testConstructor()
26  {
27  $scanCode = new ScanCode();
28  $this->assertInstanceOf(ScanCode::class, $scanCode);
29  }
30 
38  private function getScanCodeInfo()
39  {
40  $expectedArray = [
41  "license" => false,
42  "copyright" => false,
43  "email" => false,
44  "url" => false
45  ];
46  $obj = new Scancode();
47  return [
48  'expectedArray' => $expectedArray,
49  'obj' => $obj
50  ];
51  }
52 
58  public function testDataFormat()
59  {
60  $expectedArray = $this->getScanCodeInfo()['expectedArray'];
61  $scanCode = $this->getScanCodeInfo()['obj'];
62  $this->assertEquals($expectedArray, $scanCode->getArray());
63  }
64 
71  public function testSetAndGetLicense()
72  {
73  $info = $this->getScanCodeInfo();
74  $obj = $info['obj'];
75  $obj->setScanLicense(true);
76  $this->assertTrue($obj->getScanLicense());
77  }
78 
85  public function testSetAndGetCopyright()
86  {
87  $info = $this->getScanCodeInfo();
88  $obj = $info['obj'];
89  $obj->setScanCopyright(true);
90  $this->assertTrue($obj->getScanCopyright());
91  }
92 
99  public function testSetAndGetEmail()
100  {
101  $info = $this->getScanCodeInfo();
102  $obj = $info['obj'];
103  $obj->setScanEmail(true);
104  $this->assertTrue($obj->getScanEmail());
105  }
106 
113  public function testSetAndGetUrl()
114  {
115  $info = $this->getScanCodeInfo();
116  $obj = $info['obj'];
117  $obj->setScanUrl(true);
118  $this->assertTrue($obj->getScanUrl());
119  }
120 }