Release 2.59 (#5957)
This commit is contained in:
@@ -39,6 +39,27 @@ class WizardControllerTest extends AbstractControllerBaseTestCase
|
||||
$this->assertAccessIsGranted($client, '/wizard/profile');
|
||||
}
|
||||
|
||||
public function testPasswordWizard(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
$this->assertAccessIsGranted($client, '/wizard/password');
|
||||
}
|
||||
|
||||
public function testFinishWizard(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
// mark all wizards as seen so the WizardSubscriber does not interfere
|
||||
$user = $this->loadUserFromDatabase(UserFixtures::USERNAME_USER);
|
||||
$user->setWizardAsSeen('intro');
|
||||
$user->setWizardAsSeen('profile');
|
||||
$this->getEntityManager()->persist($user);
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$this->assertAccessIsGranted($client, '/wizard/finish');
|
||||
}
|
||||
|
||||
public function testWizardDoesNotAppearOnFirstLoginIfDisabled(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
@@ -72,12 +93,13 @@ class WizardControllerTest extends AbstractControllerBaseTestCase
|
||||
$this->assertIsRedirect($client, '/wizard/intro');
|
||||
}
|
||||
|
||||
public function testProfileWizardSubmitRedirectsToDoneAndMarksSeen(): void
|
||||
public function testProfileWizardSubmitMarksSeenAndRedirectsToNext(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
$user = $this->loadUserFromDatabase(UserFixtures::USERNAME_USER);
|
||||
$user->setPreferenceValue('__wizards__', null);
|
||||
$user->setWizardAsSeen('intro');
|
||||
$user->setRequiresPasswordReset(false);
|
||||
$this->getEntityManager()->persist($user);
|
||||
$this->getEntityManager()->flush();
|
||||
@@ -92,7 +114,11 @@ class WizardControllerTest extends AbstractControllerBaseTestCase
|
||||
$values['form'][UserPreference::SKIN] = 'auto';
|
||||
$client->submit($form, $values);
|
||||
|
||||
$this->assertIsRedirect($client, '/wizard/done');
|
||||
// After a successful profile submit, the controller always redirects to
|
||||
// the virtual /wizard/next/ route — the WizardManager decides where
|
||||
// that ultimately lands. The route name and the _locale query string
|
||||
// make for a stable assertion target.
|
||||
$this->assertIsRedirect($client, '/wizard/next/', false);
|
||||
|
||||
$this->getEntityManager()->clear();
|
||||
$user = $this->loadUserFromDatabase(UserFixtures::USERNAME_USER);
|
||||
@@ -112,7 +138,7 @@ class WizardControllerTest extends AbstractControllerBaseTestCase
|
||||
$this->assertIsRedirect($client, '/wizard/profile');
|
||||
}
|
||||
|
||||
public function testProfileWizardSubmitRedirectsToPasswordIfResetRequired(): void
|
||||
public function testPasswordWizardSubmitClearsResetFlagAndRedirectsToNext(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
@@ -121,19 +147,80 @@ class WizardControllerTest extends AbstractControllerBaseTestCase
|
||||
$this->getEntityManager()->persist($user);
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$crawler = $this->request($client, '/wizard/profile');
|
||||
$form = $crawler->filter('form[name=form]')->form();
|
||||
$crawler = $this->request($client, '/wizard/password');
|
||||
$form = $crawler->filter('form[name=user_password]')->form();
|
||||
$values = $form->getPhpValues();
|
||||
$values['form']['reload'] = '0';
|
||||
$values['user_password']['plainPassword']['first'] = 'new-pa$$word-123';
|
||||
$values['user_password']['plainPassword']['second'] = 'new-pa$$word-123';
|
||||
$client->submit($form, $values);
|
||||
|
||||
$this->assertIsRedirect($client, '/wizard/password');
|
||||
$this->assertIsRedirect($client, '/wizard/next/', false);
|
||||
|
||||
$this->getEntityManager()->clear();
|
||||
$user = $this->loadUserFromDatabase(UserFixtures::USERNAME_USER);
|
||||
self::assertFalse($user->requiresPasswordReset());
|
||||
}
|
||||
|
||||
public function testDoneWizard(): void
|
||||
public function testNextRedirectsToFirstUnseenStep(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
$this->assertAccessIsGranted($client, '/wizard/done');
|
||||
$user = $this->loadUserFromDatabase(UserFixtures::USERNAME_USER);
|
||||
$user->setPreferenceValue('__wizards__', null);
|
||||
$user->setRequiresPasswordReset(false);
|
||||
$this->getEntityManager()->persist($user);
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$this->request($client, '/wizard/next/');
|
||||
|
||||
// The WizardSubscriber intercepts /wizard/next/ on kernel.request and
|
||||
// redirects to the first unseen step (intro, since we just cleared it).
|
||||
$this->assertIsRedirect($client, '/wizard/intro');
|
||||
}
|
||||
|
||||
public function testNextRedirectsToFinishWhenAllStepsSeen(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
$user = $this->loadUserFromDatabase(UserFixtures::USERNAME_USER);
|
||||
$user->setWizardAsSeen('intro');
|
||||
$user->setWizardAsSeen('profile');
|
||||
$user->setRequiresPasswordReset(false);
|
||||
$this->getEntityManager()->persist($user);
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$this->request($client, '/wizard/next/');
|
||||
|
||||
// With nothing left to see the subscriber returns early and the
|
||||
// controller falls back to the finish page.
|
||||
$this->assertIsRedirect($client, '/wizard/finish');
|
||||
}
|
||||
|
||||
public function testPreviousRedirectsToPreviousStep(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
$this->request($client, '/wizard/previous/profile');
|
||||
|
||||
$this->assertIsRedirect($client, '/wizard/intro');
|
||||
}
|
||||
|
||||
public function testPreviousFallsBackToIntroWhenNoPreviousStep(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
// intro is the very first step, so there is nothing before it
|
||||
$this->request($client, '/wizard/previous/intro');
|
||||
|
||||
$this->assertIsRedirect($client, '/wizard/intro');
|
||||
}
|
||||
|
||||
public function testPreviousFallsBackToIntroForUnknownStep(): void
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
|
||||
$this->request($client, '/wizard/previous/does-not-exist');
|
||||
|
||||
$this->assertIsRedirect($client, '/wizard/intro');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user