7 public $fixtures = array(
8 'personalisationAttributes' =>
'PersonalisationAttribute',
9 'userPersonalisationAttributes' =>
'UserPersonalisationAttribute',
13 public static function setUpBeforeClass()
15 Yii::app()->getModule(
'personalisation');
21 public function testGetChildren()
25 $this->assertCount(4, $parent->getChildren());
26 $this->assertCount(4, $parent->getChildrenIds());
30 $this->assertCount(0, $parent->getChildren());
31 $this->assertCount(0, $parent->getChildrenIds());
34 public function testUserFlatList()
41 public function testGetTree()
45 $this->assertCount(4, $tree[
'item']);
46 $this->assertNotEmpty(array_filter($tree[
'item'],
function($var){
return $var[
'text'] ==
'CEO';}));
47 $this->assertNotEmpty(array_filter($tree[
'item'],
function($var){
return $var[
'text'] ==
'development';}));
51 public function testGetTreeWithUserState()
54 $filteredTree = array_filter($tree[
'item'],
function($var){
return $var[
'text'] ==
'Personal';});
55 $this->assertArrayHasKey(
'checked', array_pop($filteredTree));
58 public function testFlatListForUser()
62 $this->assertCount(4, $flatList);
63 $this->assertTrue(in_array(
'Personal', $flatList));
64 $this->assertTrue(in_array(
'Programmer', $flatList));
65 $this->assertTrue(in_array(
'Manager', $flatList));
66 $this->assertTrue(in_array(
'Cleaner', $flatList));
69 $this->assertCount(0, $flatList);