FOSSology  4.5.1
Open Source License Compliance by Open Source Software
GroupTest.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 
13 
15 use PHPUnit\Framework\TestCase;
16 
17 class GroupTest extends TestCase
18 {
20 
26  public function testConstructor()
27  {
28  $group = new Group(4, "fossy");
29  $this->assertInstanceOf(Group::class, $group);
30  }
31 
39  private function getGroupInfo()
40  {
41  $expectedArray = [
42  "id" => 4,
43  "name" => "fossy",
44  ];
45  $obj = new Group(4,"fossy");
46  return [
47  'expectedArray' => $expectedArray,
48  'obj' => $obj
49  ];
50  }
51 
57  public function testDataFormat()
58  {
59  $expectedArray = $this->getGroupInfo()['expectedArray'];
60  $group = $this->getGroupInfo()['obj'];
61  $this->assertEquals($expectedArray, $group->getArray());
62  }
63 
69  public function testGetId()
70  {
71  $group = new Group(4, "fossy");
72  $this->assertEquals(4, $group->getId());
73  }
74 
80  public function testSetId()
81  {
82  $group = new Group(4, "fossy");
83  $group->setId(10);
84  $this->assertEquals(10, $group->getId());
85  }
86 
92  public function testGetName()
93  {
94  $group = new Group(4, "fossy");
95  $this->assertEquals("fossy", $group->getName());
96  }
97 
103  public function testSetName()
104  {
105  $group = new Group(4, "fossy");
106  $group->setName("newName");
107  $this->assertEquals("newName", $group->getName());
108  }
109 }