Skip to content

Commit

Permalink
Merge pull request #15 from MadCat34/fix/deprecated_tests
Browse files Browse the repository at this point in the history
Fix/deprecated tests
  • Loading branch information
visto9259 authored Apr 26, 2024
2 parents 7b6b3cd + bb53d37 commit 6e7dafc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"malukenho/docheader": "^0.1.7",
"phpunit/phpunit": "^9.5.0",
"phpspec/prophecy": "^1.10",
"phpspec/prophecy-phpunit": "^2.0",
"friendsofphp/php-cs-fixer": "^2.9.3",

"php-coveralls/php-coveralls": "^2.0"
},
"autoload": {
Expand Down
17 changes: 11 additions & 6 deletions test/Assertion/AssertionSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ public function testWhenNoConditionIsGivenAndIsUsed()
$assertionContainer = $this->getMockBuilder(AssertionContainerInterface::class)->getMock();
$assertionSet = new AssertionSet($assertionContainer, ['fooFactory', 'barFactory']);

$assertionContainer->expects($this->at(0))->method('get')->with('fooFactory')->willReturn($fooAssertion);
$assertionContainer->expects($this->at(1))->method('get')->with('barFactory')->willReturn($barAssertion);
$assertionContainer->expects($this->exactly(2))
->method('get')
->withConsecutive(
['fooFactory'], ['barFactory'])
->willReturnOnConsecutiveCalls($fooAssertion, $barAssertion);

$this->assertFalse($assertionSet->assert('permission'));

Expand All @@ -98,7 +101,7 @@ public function testAndConditionWillBreakEarlyWithFailure()
$assertionContainer = $this->getMockBuilder(AssertionContainerInterface::class)->getMock();
$assertionSet = new AssertionSet($assertionContainer, ['fooFactory', 'barFactory', 'condition' => AssertionSet::CONDITION_AND]);

$assertionContainer->expects($this->at(0))->method('get')->with('fooFactory')->willReturn($fooAssertion);
$assertionContainer->expects($this->once())->method('get')->with('fooFactory')->willReturn($fooAssertion);

$this->assertFalse($assertionSet->assert('permission'));

Expand All @@ -114,7 +117,7 @@ public function testOrConditionWillBreakEarlyWithSuccess()
$assertionContainer = $this->getMockBuilder(AssertionContainerInterface::class)->getMock();
$assertionSet = new AssertionSet($assertionContainer, ['fooFactory', 'barFactory', 'condition' => AssertionSet::CONDITION_OR]);

$assertionContainer->expects($this->at(0))->method('get')->with('fooFactory')->willReturn($fooAssertion);
$assertionContainer->expects($this->once())->method('get')->with('fooFactory')->willReturn($fooAssertion);

$this->assertTrue($assertionSet->assert('permission'));

Expand Down Expand Up @@ -189,8 +192,10 @@ public function testUsesAssertionsAsArrays()
$assertionContainer = $this->getMockBuilder(AssertionContainerInterface::class)->getMock();
$assertionSet = new AssertionSet($assertionContainer, ['fooFactory', ['barFactory']]);

$assertionContainer->expects($this->at(0))->method('get')->with('fooFactory')->willReturn($fooAssertion);
$assertionContainer->expects($this->at(1))->method('get')->with('barFactory')->willReturn($barAssertion);
$assertionContainer->expects($this->exactly(2))
->method('get')
->withConsecutive(['fooFactory'], ['barFactory'])
->willReturnOnConsecutiveCalls($fooAssertion, $barAssertion);

$this->assertTrue($assertionSet->assert('permission'));

Expand Down
3 changes: 3 additions & 0 deletions test/Container/AuthorizationServiceFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@
use LmcRbac\Service\AuthorizationService;
use LmcRbac\Service\RoleServiceInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Container\ContainerInterface;

/**
* @covers \LmcRbac\Container\AuthorizationServiceFactory
*/
class AuthorizationServiceFactoryTest extends TestCase
{
use ProphecyTrait;

public function testCanCreateAuthorizationService(): void
{
$container = $this->prophesize(ContainerInterface::class);
Expand Down
3 changes: 3 additions & 0 deletions test/Service/RoleServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@
use LmcRbacTest\Asset\Identity;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* @covers \LmcRbac\Service\RoleService
*/
class RoleServiceTest extends TestCase
{
use ProphecyTrait;

public function testReturnGuestRoleIfNoIdentityIsGiven(): void
{
$roleService = new RoleService(new InMemoryRoleProvider([]), 'guest');
Expand Down

0 comments on commit 6e7dafc

Please sign in to comment.