FOSSology  4.4.0
Open Source License Compliance by Open Source Software
UserTest.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2020 Siemens AG
4  Author: Gaurav Mishra <mishra.gaurav@siemens.com>
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
14 
16 
17 require_once dirname(dirname(dirname(dirname(__DIR__)))) .
18  '/lib/php/Plugin/FO_Plugin.php';
19 
24 class UserTest extends \PHPUnit\Framework\TestCase
25 {
30  public function testDataFormat()
31  {
32  $expectedCurrentUser = [
33  "id" => 2,
34  "name" => 'fossy',
35  "description" => 'super user',
36  "email" => 'fossy@localhost',
37  "accessLevel" => 'admin',
38  "rootFolderId" => 2,
39  "defaultGroup" => 0,
40  "emailNotification" => true,
41  "agents" => [
42  "bucket" => true,
43  "copyright_email_author" => true,
44  "ecc" => false,
45  "keyword" => false,
46  "mimetype" => false,
47  "monk" => false,
48  "nomos" => true,
49  "ojo" => true,
50  "package" => false,
51  "reso" => false
52  ]
53  ];
54  $expectedNonAdminUser = [
55  "id" => 8,
56  "name" => 'userii',
57  "description" => 'very useri',
58  "defaultGroup" => 0,
59  ];
60 
61  $actualCurrentUser = new User(2, 'fossy', 'super user', 'fossy@localhost',
62  PLUGIN_DB_ADMIN, 2, true, "bucket,copyright,nomos,ojo", 0);
63  $actualNonAdminUser = new User(8, 'userii', 'very useri', null, null, null,
64  null, null, 0);
65 
66  $this->assertEquals($expectedCurrentUser, $actualCurrentUser->getArray());
67  $this->assertEquals($expectedNonAdminUser, $actualNonAdminUser->getArray());
68  }
69 }
Model to hold user information.
Definition: User.php:21
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
Definition: libfossology.h:39