-
Notifications
You must be signed in to change notification settings - Fork 10
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
1 parent
fc6b934
commit 64c06fb
Showing
3 changed files
with
79 additions
and
7 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
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,7 @@ | ||
<?php | ||
|
||
namespace App\Event; | ||
|
||
class UserRegisteredEvent | ||
{ | ||
} |
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 |
---|---|---|
|
@@ -4,13 +4,20 @@ | |
|
||
namespace App\Tests\Functional; | ||
|
||
use App\Event\UserRegisteredEvent; | ||
use App\Tests\FunctionalTester; | ||
use Sensio\Bundle\FrameworkExtraBundle\EventListener\SecurityListener; | ||
use Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector; | ||
use Symfony\Component\Console\ConsoleEvents; | ||
use Symfony\Component\Console\EventListener\ErrorListener; | ||
use Symfony\Component\HttpKernel\EventListener\LocaleListener; | ||
use Symfony\Component\HttpKernel\EventListener\RouterListener; | ||
use Symfony\Component\HttpKernel\KernelEvents; | ||
|
||
final class EventsCest | ||
{ | ||
/** | ||
* @deprecated in favor of dontSeeEventListenerIsCalled | ||
*/ | ||
public function dontSeeEventTriggered(FunctionalTester $I) | ||
{ | ||
$I->amOnPage('/'); | ||
|
@@ -19,6 +26,17 @@ public function dontSeeEventTriggered(FunctionalTester $I) | |
$I->dontSeeEventTriggered([ErrorListener::class, ErrorListener::class]); | ||
} | ||
|
||
public function dontSeeEventListenerIsCalled(FunctionalTester $I) | ||
{ | ||
$I->amOnPage('/'); | ||
$I->dontSeeEventListenerIsCalled(ErrorListener::class); | ||
$I->dontSeeEventListenerIsCalled(new ErrorListener()); | ||
$I->dontSeeEventListenerIsCalled([ErrorListener::class, ErrorListener::class]); | ||
// with events | ||
$I->dontSeeEventListenerIsCalled(RouterListener::class, KernelEvents::EXCEPTION); | ||
$I->dontSeeEventListenerIsCalled(RouterListener::class, [KernelEvents::RESPONSE, KernelEvents::EXCEPTION]); | ||
} | ||
|
||
public function dontSeeOrphanEvent(FunctionalTester $I) | ||
{ | ||
$I->amOnPage('/login'); | ||
|
@@ -27,25 +45,62 @@ public function dontSeeOrphanEvent(FunctionalTester $I) | |
'password' => '123456', | ||
'_remember_me' => false | ||
]); | ||
$I->dontseeOrphanEvent(); | ||
$I->dontSeeOrphanEvent(); | ||
} | ||
|
||
public function dontSeeEvent(FunctionalTester $I) | ||
{ | ||
$I->markTestSkipped(); | ||
$I->amOnPage('/'); | ||
$I->dontSeeEvent(KernelEvents::EXCEPTION); | ||
$I->dontSeeEvent([new UserRegisteredEvent(), ConsoleEvents::COMMAND]); | ||
} | ||
|
||
/** | ||
* @deprecated in favor of seeEventListenerIsCalled | ||
*/ | ||
public function seeEventTriggered(FunctionalTester $I) | ||
{ | ||
$I->amOnPage('/'); | ||
$I->seeEventTriggered(RouterListener::class); | ||
$I->seeEventTriggered(new RouterDataCollector()); | ||
$I->seeEventTriggered([RouterDataCollector::class]); | ||
$I->seeEventTriggered([RouterListener::class, RouterDataCollector::class]); | ||
} | ||
|
||
public function seeEventListenerIsCalled(FunctionalTester $I) | ||
{ | ||
$I->amOnPage('/'); | ||
$I->seeEventListenerIsCalled(RouterListener::class); | ||
$I->seeEventListenerIsCalled(new RouterDataCollector()); | ||
$I->seeEventListenerIsCalled([RouterListener::class, RouterDataCollector::class]); | ||
// with events | ||
$I->seeEventListenerIsCalled(RouterListener::class, KernelEvents::REQUEST); | ||
$I->seeEventListenerIsCalled(LocaleListener::class, [KernelEvents::REQUEST, KernelEvents::FINISH_REQUEST]); | ||
} | ||
|
||
public function seeOrphanEvent(FunctionalTester $I) | ||
{ | ||
$I->markTestIncomplete('To do: use a new event for this assertion'); | ||
$I->amOnPage('/register'); | ||
$I->stopFollowingRedirects(); | ||
$I->submitSymfonyForm('registration_form', [ | ||
'[email]' => '[email protected]', | ||
'[plainPassword]' => '123456', | ||
'[agreeTerms]' => true | ||
]); | ||
$I->seeOrphanEvent(UserRegisteredEvent::class); | ||
} | ||
|
||
public function seeEvent(FunctionalTester $I) | ||
{ | ||
$I->markTestSkipped(); | ||
$I->amOnPage('/register'); | ||
$I->stopFollowingRedirects(); | ||
$I->submitSymfonyForm('registration_form', [ | ||
'[email]' => '[email protected]', | ||
'[plainPassword]' => '123456', | ||
'[agreeTerms]' => true | ||
]); | ||
$I->seeOrphanEvent('security.authentication.success'); | ||
$I->seeEvent(UserRegisteredEvent::class); | ||
$I->seeEvent(KernelEvents::REQUEST, KernelEvents::FINISH_REQUEST); | ||
} | ||
} |