GroupTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 3
c 3
b 1
f 0
lcom 1
cbo 3
dl 0
loc 74
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testBasicGroupStuff() 0 7 1
B testGroupRoles() 0 44 1
A testGroupUsers() 0 18 1
1
<?php
2
3
/*
4
 * This file is part of the Stinger Soft Platform package.
5
 *
6
 * (c) Oliver Kotte <[email protected]>
7
 * (c) Florian Meyer <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
namespace StingerSoft\PlatformBundle\Entity;
13
14
use StingerSoft\PlatformBundle\Tests\TestCase;
15
16
class GroupTest extends TestCase {
17
18
	public function testBasicGroupStuff() {
19
		$group = new Group('mygroup');
20
		
21
		$this->assertEquals('mygroup', $group->getName());
22
		$this->assertEmpty($group->getUsers());
23
		$this->assertEmpty($group->getRoles());
24
	}
25
26
	public function testGroupRoles() {
27
		$group = new Group('mygroup', array(
28
			'1',
29
			'2' 
30
		));
31
		$this->assertNotEmpty($group->getRoles());
32
		$this->assertContains('1', $group->getRoles());
33
		$this->assertContains('2', $group->getRoles());
34
		
35
		$group->addRole('3');
36
		$this->assertContains('3', $group->getRoles());
37
		
38
		$group->addRoles(array(
39
			'4',
40
			'5' 
41
		));
42
		$this->assertContains('4', $group->getRoles());
43
		$this->assertContains('5', $group->getRoles());
44
		
45
		$group->removeRole('5');
46
		$this->assertNotContains('5', $group->getRoles());
47
		
48
		$group->removeRoles(array(
49
			'5' 
50
		));
51
		$this->assertNotContains('5', $group->getRoles());
52
		
53
		$group->removeRoles(array(
54
			'5',
55
			'4',
56
			'3' 
57
		));
58
		$this->assertNotContains('5', $group->getRoles());
59
		$this->assertNotContains('4', $group->getRoles());
60
		$this->assertNotContains('3', $group->getRoles());
61
		
62
		$group->removeRoles(array(
63
			'2',
64
			'1' 
65
		));
66
		$this->assertNotContains('2', $group->getRoles());
67
		$this->assertNotContains('1', $group->getRoles());
68
		$this->assertEmpty($group->getRoles());
69
	}
70
71
	public function testGroupUsers() {
72
		$group = new Group('mygroup');
73
		
74
		$this->assertEmpty($group->getUsers());
75
		$this->assertEquals(0, $group->getUsersCount());
76
		$user = new User();
77
		$user->setFirstname('Peter')->setSurname('Mobb');
78
		
79
		$group->addUser($user);
80
		$this->assertNotEmpty($group->getUsers());
81
		$this->assertContains($user, $group->getUsers());
82
		$this->assertEquals(1, $group->getUsersCount());
83
		
84
		$group->removeUser($user);
85
		$this->assertNotContains($user, $group->getUsers());
86
		$this->assertEmpty($group->getUsers());
87
		$this->assertEquals(0, $group->getUsersCount());
88
	}
89
}
90