Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @param array $collection
- * @param array $lists
- * @param array $mappers
- * @param boolean $allowDuplications
- */
- public function assertContainsCombinations($collection, array $lists, array $mappers, $allowDuplications = TRUE)
- {
- $mappers = array_map('callback', $mappers);
- $this->assertSame(count($lists), count($mappers), "Count of given lists equals to count of given mappers");
- $found = array_fill_keys(range(0, count($mappers)), array());
- foreach ($collection as $item) {
- foreach ($mappers as $i => $mapper) {
- $found[$i][] = $mapper($item);
- }
- }
- $combinations = array();
- // $counts = array_map('array_count_values', $found);
- // dump($counts);
- }
- // použití
- $actions = array('access', 'view', 'edit', 'create', 'delete');
- $resources = array('identity', 'article', 'comment', 'thread');
- $this->assertContainsCombinations($permissions, array($actions, $resources),
- array(
- function (BasePermission $permission) {
- return $permission->getPrivilege()->getAction()->getName();
- },
- function (BasePermission $permission) {
- return $permission->getPrivilege()->getResource()->getName();
- }
- ),
- FALSE
- );
Advertisement
Add Comment
Please, Sign In to add comment