Skip to content

Commit

Permalink
TASK: Some fixes towards getting tests green again
Browse files Browse the repository at this point in the history
  • Loading branch information
albe committed May 1, 2019
1 parent 5936757 commit e1fd747
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
5 changes: 5 additions & 0 deletions Neos.Flow/Classes/Security/AccountIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

namespace Neos\Flow\Security;

use Neos\Flow\Annotations as Flow;

/**
* @Flow\Proxy(false)
*/
final class AccountIdentifier
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@

namespace Neos\Flow\Security\Authentication;

use Neos\Flow\Annotations as Flow;

/**
* @Flow\Proxy(false)
*/
final class AuthenticationProviderName
{

/**
* @var string
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@

namespace Neos\Flow\Security\Authentication;

use Neos\Flow\Annotations as Flow;

/**
* @Flow\Proxy(false)
*/
final class CredentialsSource
{

/**
* @var string
*/
Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Security/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ protected function collectRolesAndParentRolesFromAccount(AccountInterface $accou
return $roles;
};

return array_reduce($account->getRoles(), $reducer, []);
return array_reduce(iterator_to_array($account->getRoles()->getIterator()), $reducer, []);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Neos.Flow/Classes/Security/Policy/Roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function jsonSerialize(): array

public function offsetSet($offset, $value)
{
if (is_null($offset)) {
if ($offset === null) {
$this->roles[] = $value;
} else {
$this->roles[$offset] = $value;
Expand All @@ -93,6 +93,6 @@ public function offsetUnset($offset)

public function offsetGet($offset)
{
return isset($this->roles[$offset]) ? $this->roles[$offset] : null;
return $this->roles[$offset] ?? null;
}
}
6 changes: 3 additions & 3 deletions Neos.Flow/Tests/Unit/Security/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function getRolesReturnsOnlyExistingRoles()

$roles = $this->account->getRoles();
$this->assertCount(1, $roles);
$this->assertArrayHasKey($this->administratorRole->getIdentifier(), $roles);
$this->assertTrue($roles->has($this->administratorRole));
}

/**
Expand All @@ -155,10 +155,10 @@ public function hasRoleReturnsFalseForAssignedButNonExistentRole()
public function setRolesWorks()
{
$roles = [$this->administratorRole, $this->customerRole];
$expectedRoles = [$this->administratorRole->getIdentifier() => $this->administratorRole, $this->customerRole->getIdentifier() => $this->customerRole];
$this->account->setRoles($roles);

$this->assertSame($expectedRoles, $this->account->getRoles());
$this->assertTrue($this->account->getRoles()->has($this->administratorRole));
$this->assertTrue($this->account->getRoles()->has($this->customerRole));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function setUp()
$this->tokenAndProviderFactory = $this->getMockBuilder(TokenAndProviderFactoryInterface::class)->getMock();
$this->authenticationProviderManager = $this->getAccessibleMock(AuthenticationProviderManager::class, ['dummy'], [$this->tokenAndProviderFactory], '', true);
$this->mockSession = $this->getMockBuilder(SessionInterface::class)->getMock();
$this->mockSecurityContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
$this->mockSecurityContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->setMethods(['initialize'])->getMock();

$this->mockSessionManager = $this->getMockBuilder(SessionManager::class)->getMock();
$this->mockSessionManager->expects(self::any())->method('getCurrentSession')->willReturn($this->mockSession);
Expand Down

0 comments on commit e1fd747

Please sign in to comment.