Skip to content

Commit

Permalink
seeEvent fails with non-existent events.
Browse files Browse the repository at this point in the history
  • Loading branch information
TavoNiievez committed Jan 2, 2024
1 parent dc02745 commit e931df3
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/Functional/EventsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Event\UserRegisteredEvent;
use App\Tests\FunctionalTester;
use PHPUnit\Framework\ExpectationFailedException;
use Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\EventListener\ErrorListener;
Expand Down Expand Up @@ -43,14 +44,13 @@ public function dontSeeOrphanEvent(FunctionalTester $I)
$I->submitForm('form[name=login]', [
'email' => '[email protected]',
'password' => '123456',
'_remember_me' => false
'_remember_me' => false,
]);
$I->dontSeeOrphanEvent();
}

public function dontSeeEvent(FunctionalTester $I)
{
$I->markTestSkipped();
$I->amOnPage('/');
$I->dontSeeEvent(KernelEvents::EXCEPTION);
$I->dontSeeEvent([new UserRegisteredEvent(), ConsoleEvents::COMMAND]);
Expand Down Expand Up @@ -85,22 +85,28 @@ public function seeOrphanEvent(FunctionalTester $I)
$I->submitSymfonyForm('registration_form', [
'[email]' => '[email protected]',
'[plainPassword]' => '123456',
'[agreeTerms]' => true
'[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
'[agreeTerms]' => true,
]);
$I->seeEvent(UserRegisteredEvent::class);
$I->seeEvent(KernelEvents::REQUEST, KernelEvents::FINISH_REQUEST);
try {
$I->seeEvent('non-existent-event');
} catch (ExpectationFailedException $ex) {
$I->assertTrue(true, 'seeEvent assertion fails with non-existent events.');
return;
}
$I->fail('seeEvent assertion did not fail as expected');
}
}

0 comments on commit e931df3

Please sign in to comment.