Skip to content

Commit

Permalink
Merge pull request #70 from prolic/guards
Browse files Browse the repository at this point in the history
add guard factory tests
  • Loading branch information
codeliner committed Sep 13, 2015
2 parents 638d31f + f2db10a commit 07ad2fb
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -35,7 +35,8 @@
},
"suggest": {
"prooph/event-store": "Let the EventBus dispatch persisted DomainEvents",
"zendframework/zend-servicemanager": "Use Zf2 ServiceManager to lazy load your handlers and listeners"
"zendframework/zend-servicemanager": "Use Zf2 ServiceManager to lazy load your handlers and listeners",
"prooph/service-bus-zfc-rbac-bridge": "Use ZfcRbac as authorization service for route and finalize guard"
},
"autoload": {
"psr-4": {
Expand Down
42 changes: 42 additions & 0 deletions tests/Container/Plugin/Guard/FinalizeGuardFactoryTest.php
@@ -0,0 +1,42 @@
<?php
/*
* This file is part of the prooph/service-bus.
* (c) 2014-2015 prooph software GmbH <contact@prooph.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Date: 09/13/15 -7:47 PM
*/

namespace Prooph\ServiceBusTest\Container\Plugin\Guard;

use Interop\Container\ContainerInterface;
use PHPUnit_Framework_TestCase as TestCase;
use Prooph\ServiceBus\Container\Plugin\Guard\FinalizeGuardFactory;
use Prooph\ServiceBus\Plugin\Guard\AuthorizationService;
use Prooph\ServiceBus\Plugin\Guard\FinalizeGuard;

/**
* Class FinalizeGuardFactoryTest
* @package Prooph\ServiceBusTest\Container\Plugin\Guard
*/
final class FinalizeGuardFactoryTest extends TestCase
{
/**
* @test
*/
public function it_creates_route_guard()
{
$authorizationService = $this->prophesize(AuthorizationService::class);

$container = $this->prophesize(ContainerInterface::class);
$container->get(AuthorizationService::class)->willReturn($authorizationService->reveal());

$factory = new FinalizeGuardFactory();

$guard = $factory($container->reveal());

$this->assertInstanceOf(FinalizeGuard::class, $guard);
}
}
42 changes: 42 additions & 0 deletions tests/Container/Plugin/Guard/RouteGuardFactoryTest.php
@@ -0,0 +1,42 @@
<?php
/*
* This file is part of the prooph/service-bus.
* (c) 2014-2015 prooph software GmbH <contact@prooph.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Date: 09/13/15 -7:47 PM
*/

namespace Prooph\ServiceBusTest\Container\Plugin\Guard;

use Interop\Container\ContainerInterface;
use PHPUnit_Framework_TestCase as TestCase;
use Prooph\ServiceBus\Container\Plugin\Guard\RouteGuardFactory;
use Prooph\ServiceBus\Plugin\Guard\AuthorizationService;
use Prooph\ServiceBus\Plugin\Guard\RouteGuard;

/**
* Class RouteGuardFactoryTest
* @package Prooph\ServiceBusTest\Container\Plugin\Guard
*/
final class RouteGuardFactoryTest extends TestCase
{
/**
* @test
*/
public function it_creates_route_guard()
{
$authorizationService = $this->prophesize(AuthorizationService::class);

$container = $this->prophesize(ContainerInterface::class);
$container->get(AuthorizationService::class)->willReturn($authorizationService->reveal());

$factory = new RouteGuardFactory();

$guard = $factory($container->reveal());

$this->assertInstanceOf(RouteGuard::class, $guard);
}
}

0 comments on commit 07ad2fb

Please sign in to comment.