-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
96 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
tests/bundle_tests/unit/EventListener/AuthenticationListenerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace DachcomBundle\Test\unit\EventListener; | ||
|
||
use MembersBundle\Event\FilterUserResponseEvent; | ||
use MembersBundle\EventListener\AuthenticationListener; | ||
use MembersBundle\MembersEvents; | ||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
use Codeception\TestCase\Test; | ||
|
||
class AuthenticationListenerTest extends Test | ||
{ | ||
const FIREWALL_NAME = 'foo'; | ||
|
||
/** | ||
* @var EventDispatcherInterface | ||
*/ | ||
private $eventDispatcher; | ||
|
||
/** | ||
* @var FilterUserResponseEvent | ||
*/ | ||
private $event; | ||
|
||
/** | ||
* @var AuthenticationListener | ||
*/ | ||
private $listener; | ||
|
||
public function setUp() | ||
{ | ||
$user = $this->getMockBuilder('MembersBundle\Adapter\User\UserInterface')->getMock(); | ||
$response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response')->getMock(); | ||
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); | ||
|
||
$this->event = new FilterUserResponseEvent($user, $request, $response); | ||
$this->eventDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')->getMock(); | ||
$this->eventDispatcher | ||
->expects($this->once()) | ||
->method('dispatch'); | ||
|
||
$loginManager = $this->getMockBuilder('MembersBundle\Manager\LoginManagerInterface')->getMock(); | ||
$this->listener = new AuthenticationListener($loginManager, self::FIREWALL_NAME); | ||
} | ||
|
||
public function testAuthenticate() | ||
{ | ||
$this->listener->authenticate($this->event, MembersEvents::REGISTRATION_COMPLETED, $this->eventDispatcher); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
tests/bundle_tests/unit/EventListener/FlashListenerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace DachcomBundle\Test\unit\EventListener; | ||
|
||
use MembersBundle\EventListener\FlashListener; | ||
use MembersBundle\MembersEvents; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\EventDispatcher\Event; | ||
|
||
class FlashListenerTest extends TestCase | ||
{ | ||
/** | ||
* @var Event | ||
*/ | ||
private $event; | ||
|
||
/** | ||
* @var FlashListener | ||
*/ | ||
private $listener; | ||
|
||
public function setUp() | ||
{ | ||
$this->event = new Event(); | ||
$flashBag = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Flash\FlashBag')->getMock(); | ||
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); | ||
$session | ||
->expects($this->once()) | ||
->method('getFlashBag') | ||
->willReturn($flashBag); | ||
|
||
$translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock(); | ||
$this->listener = new FlashListener($session, $translator); | ||
} | ||
|
||
public function testAddSuccessFlash() | ||
{ | ||
$this->listener->addSuccessFlash($this->event, MembersEvents::CHANGE_PASSWORD_COMPLETED); | ||
} | ||
} |