public function testGetAuthorisedCategories()
 {
     $user = new JUser(44);
     $notAllowed = array(22, 34, 64, 65, 66, 67, 75);
     $allowed = $user->getAuthorisedCategories('com_content', 'core.create');
     $this->assertEquals(array(), array_intersect($allowed, $notAllowed), 'Line: ' . __LINE__ . ' User 44 in Group 6 not allowed in these categories');
     $this->assertEquals(19, count($allowed), 'Line: ' . __LINE__ . ' User 44 in Group 6 allowed create for 19 categories');
     $user = new JUser(45);
     $notAllowed = array(22, 34, 64, 65, 66, 67, 75, 23, 68, 69, 70, 71);
     $allowed = $user->getAuthorisedCategories('com_content', 'core.create');
     $this->assertEquals(array(), array_intersect($allowed, $notAllowed), 'Line: ' . __LINE__ . ' User 45 in Groups 5,6 not allowed in these categories');
     $this->assertEquals(14, count($allowed), 'Line: ' . __LINE__ . ' User 44 in Group 6 allowed create for 14 categories');
     $user = new JUser(46);
     $this->assertThat($user->getAuthorisedCategories('com_content', 'core.create'), $this->equalTo(array(67)), 'Line: ' . __LINE__ . ' User 46 in Group 2 only has create for category 67');
     $user = new JUser(42);
     $allowed = $user->getAuthorisedCategories('com_content', 'core.create');
     $this->assertEquals(26, count($allowed), 'Line: ' . __LINE__ . ' User 42 should be allowed all categories');
 }
 /**
  * Method to check if you can add a new record.
  *
  * Extended classes can override this if necessary.
  *
  * @param   array  $data  An array of input data.
  *
  * @return  boolean
  */
 protected function allowAdd($data = array())
 {
     return $this->user->authorise('core.create', $this->option) || count($this->user->getAuthorisedCategories($this->option, 'core.create'));
 }