public function testSaveActions()
 {
     $test = new Action('test');
     $attempt = new Action('attempt');
     $department = new Department($this->unusedDepartment);
     $department->saveActions([$test->getId(), $attempt->getId()]);
     $department = new Department($this->unusedDepartment);
     $actions = $department->getActions();
     $this->assertEquals(2, count($actions));
     $this->assertTrue(in_array($test->getId(), array_keys($actions)));
     $this->assertTrue(in_array($attempt->getId(), array_keys($actions)));
     $department->saveActions([]);
     $department = new Department($this->unusedDepartment);
     $actions = $department->getActions();
     $this->assertEquals(0, count($actions));
 }
Esempio n. 2
0
 public function testSaveAndLoad()
 {
     $action = new Action();
     $action->setName('Test');
     $action->setDescription('Description');
     $action->save();
     $id = $action->getId();
     $this->assertNotEmpty($id);
     $action = new Action($id);
     $this->assertEquals('Test', $action->getName());
     $this->assertEquals('Description', $action->getDescription());
 }
Esempio n. 3
0
 /**
  * @param Action $action
  * @return bool
  */
 public function hasAction(Action $action)
 {
     return in_array($action->getId(), array_keys($this->getActions()));
 }