Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Nov 28, 2019
1 parent d0dfe4e commit 161d75e
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions spec/drupol/CasBundle/Controller/LogoutSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,51 @@
namespace spec\drupol\CasBundle\Controller;

use drupol\CasBundle\Controller\Logout;
use drupol\psrcas\Cas;
use Nyholm\Psr7\Factory\Psr17Factory;
use Nyholm\Psr7\ServerRequest;
use PhpSpec\ObjectBehavior;
use Psr\Log\NullLogger;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\HttpClient\Psr18Client;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;

class LogoutSpec extends ObjectBehavior
{
public function it_can_be_invoked(TokenStorageInterface $tokenStorage)
{
$serverRequest = new ServerRequest('GET', 'http://app');
$properties = \spec\drupol\CasBundle\Cas::getTestProperties();
$client = new Psr18Client(\spec\drupol\CasBundle\Cas::getHttpClientMock());
$cache = new ArrayAdapter();
$logger = new NullLogger();

$psr17Factory = new Psr17Factory();

$cas = new Cas(
$serverRequest,
$properties,
$client,
$psr17Factory,
$psr17Factory,
$psr17Factory,
$psr17Factory,
$cache,
$logger
);

$this
->__invoke($cas, $tokenStorage)
->shouldBeAnInstanceOf(RedirectResponse::class);

$this
->__invoke($cas, $tokenStorage)
->headers
->get('location')
->shouldReturn('http://local/cas/logout');
}

public function it_is_initializable()
{
$this->shouldHaveType(Logout::class);
Expand Down

0 comments on commit 161d75e

Please sign in to comment.