Skip to content

Commit

Permalink
Add findActionGroupById
Browse files Browse the repository at this point in the history
  • Loading branch information
austenmc committed Sep 17, 2016
1 parent 5b0dcb7 commit 798490f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Models/CharacterViewpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ public function setActionGroups(array $actionGroups)
$this->actionGroups = $actionGroups;
}

/**
* Finds an action group by id.
* @param $actionGroupId
* @return ActionGroup|null
*/
public function findActionGroupById(string $actionGroupId)
{
$groups = $this->getActionGroups();
foreach ($groups as $g) {
if ($g->getId() == $actionGroupId) {
return $g;
}
}
return null;
}

/**
* Returns all attachments.
* @return array
Expand Down
3 changes: 3 additions & 0 deletions tests/Models/CharacterViewpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public function testActions()

$output = $em->getRepository(CharacterViewpoint::class)->find(2);
$this->assertEquals($actionGroups, $output->getActionGroups());

$this->assertEquals($ag2, $input->findActionGroupById('id2'));
$this->assertNull($input->findActionGroupById('not-there'));
}

public function testAttachments()
Expand Down

0 comments on commit 798490f

Please sign in to comment.