22 require_once dirname(dirname(dirname(dirname(__DIR__)))) .
23 '/lib/php/Plugin/FO_Plugin.php';
29 class UserTest extends \PHPUnit\Framework\TestCase
56 protected function setUp() : void
59 $container = M::mock(
'ContainerBuilder');
60 $this->restHelper = M::mock(RestHelper::class);
61 $this->userDao = M::mock(UserDao::class);
63 $this->restHelper->shouldReceive(
'getDbHelper')->andReturn($this->dbHelper);
64 $this->restHelper->shouldReceive(
'getUserDao')
65 ->andReturn($this->userDao);
67 $container->shouldReceive(
'get')->withArgs(array(
68 'helper.restHelper'))->andReturn($this->restHelper);
77 $this->addToAssertionCount(
78 \Hamcrest\MatcherAssert::getCount() - $this->assertCountBefore);
119 if($version==ApiVersion::V1){
120 $expectedCurrentUser = [
123 "description" =>
'super user',
124 "email" =>
'fossy@localhost',
125 "accessLevel" =>
'admin',
128 "emailNotification" =>
true,
131 "copyright_email_author" =>
true,
140 "compatibility" => false
144 $expectedCurrentUser = [
147 "description" =>
'super user',
148 "email" =>
'fossy@localhost',
149 "accessLevel" =>
'admin',
151 "defaultGroup" =>
"fossy",
152 "emailNotification" =>
true,
155 "copyrightEmailAuthor" =>
true,
164 "compatibility" => false
168 $expectedNonAdminUser = [
171 "description" =>
'very useri',
175 $actualCurrentUserV1 =
new User(2,
'fossy',
'super user',
'fossy@localhost',
178 $this->userDao->shouldReceive(
'getGroupNameById')->withArgs([0])->andReturn(
"fossy");
180 $actualCurrentUserV2 =
new User(2,
'fossy',
'super user',
'fossy@localhost',
182 $actualNonAdminUser =
new User(8,
'userii',
'very useri',
null,
null,
null,
184 if ($version == ApiVersion::V2) {
185 $this->assertEquals($expectedCurrentUser, $actualCurrentUserV2->getArray($version));
187 $this->assertEquals($expectedCurrentUser, $actualCurrentUserV1->getArray($version));
189 $this->assertEquals($expectedNonAdminUser, $actualNonAdminUser->getArray());
Provides helper methods to access database for REST api.
Provides various DAO helper functions for REST api.
Model to hold user information.
tearDown()
Remove test objects.
setUp()
Setup test objects.
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.