19 use Monolog\Test\TestCase;
27 protected function setup():
void
30 $container = M::mock(
'ContainerBuilder');
31 $this->dbHelper = M::mock(DbHelper::class);
32 $this->restHelper = M::mock(RestHelper::class);
33 $this->userDao = M::mock(UserDao::class);
35 $this->restHelper->shouldReceive(
'getDbHelper')->andReturn($this->dbHelper);
37 $container->shouldReceive(
'get')->withArgs(array(
38 'helper.restHelper'))->andReturn($this->restHelper);
39 $this->restHelper->shouldReceive(
'getUserDao')->andReturn($this->userDao);
51 $user =
new User(1,
"fossy",
"Admin user",
"fossy@gmail.com",
"admin", 4,
"fossy@gmail.com",
"monk", 3,
null);
52 if ($version == ApiVersion::V1) {
54 'user' => $user->getArray($version),
59 'user' => $user->getArray($version),
66 'expectedArray' => $expectedArray,
72 public function testGetUser()
74 $user =
new User(1,
"fossy",
"Admin user",
"fossy@gmail.com",
"admin", 4,
"fossy@gmail.com",
"monk", 3,
null);
76 $this->assertEquals($user, $userGroupMember->getUser());
79 public function testGetGroupPerm()
81 $user =
new User(1,
"fossy",
"Admin user",
"fossy@gmail.com",
"admin", 4,
"fossy@gmail.com",
"monk", 3,
null);
82 $userGroupMember =
new UserGroupMember($user, 3);
83 $this->assertEquals(3, $userGroupMember->getGroupPerm());
87 public function testSetUser()
89 $user1 =
new User(1,
"fossy",
"Admin user",
"fossy@gmail.com",
"admin", 4,
"fossy@gmail.com",
'monk', 3,
null);
90 $user2 =
new User(2,
"newuser",
"New user",
"newuser@gmail.com",
"user", 5,
"newuser@gmail.com",
'monk', 4,
null);
91 $userGroupMember =
new UserGroupMember($user1, 3);
93 $userGroupMember->setUser($user2);
94 $this->assertEquals($user2, $userGroupMember->getUser());
97 public function testSetGroupPerm()
99 $user =
new User(1,
"fossy",
"Admin user",
"fossy@gmail.com",
"admin", 4,
"fossy@gmail.com",
"monk", 3,
null);
100 $userGroupMember =
new UserGroupMember($user, 3);
102 $userGroupMember->setGroupPerm(5);
103 $this->assertEquals(5, $userGroupMember->getGroupPerm());
107 public function testGetJSON()
110 $this->assertJsonStringEqualsJsonString(
111 json_encode($data[
'expectedArray']),
112 $data[
'obj']->getJSON()
117 public function testGetArrayV1()
120 $this->assertEquals($data[
'expectedArray'], $data[
'obj']->getArray(ApiVersion::V1));
Provides helper methods to access database for REST api.
Provides various DAO helper functions for REST api.
Model to hold user information.
getUserGroupMemberInfo($version=ApiVersion::V2)