/**
  * Test TWIG command usage.
  *
  * @param array  $cookieSettings
  * @param string $testSettingName
  * @param bool   $shouldAuthorize
  * @param bool   $expectedResult
  * @param bool   $authorizedCommand
  *
  * @dataProvider getExtensionInTemplateCases()
  */
 public function testExtensionInTemplate($cookieSettings, $testSettingName, $shouldAuthorize, $expectedResult, $authorizedCommand = true)
 {
     if ($shouldAuthorize) {
         $this->client = $this->loginHelper->loginAction('test', 'test');
     }
     CookieTestHelper::setSettingsCookie($this->client, $cookieSettings);
     // Call controller with params to generate twig.
     $authorizedCommandStr = $authorizedCommand ? 'true' : 'false';
     $this->client->request('GET', "/test/twigGeneral/{$testSettingName}/{$authorizedCommandStr}");
     $this->assertContains($expectedResult ? 'foo_true' : 'foo_false', $this->client->getResponse()->getContent());
 }
 /**
  * Cookie should not be accepted if it has expired.
  */
 public function testCookieExpiration()
 {
     // Set old authentication cookie.
     CookieTestHelper::setAuthenticationCookie($this->client, time() - 360 * 24 * 3600);
     // Visit login page.
     $crawler = $this->client->request('GET', '/settings/login');
     // Assert there is a form.
     $buttonNode = $crawler->selectButton('login_submit');
     $this->assertSame(1, $buttonNode->count(), 'There should be a form');
 }
 /**
  * When user is logged in, and he selects profile, then settings container must receive that choice.
  */
 public function testSettingsSelected()
 {
     // Set authentication cookie.
     CookieTestHelper::setAuthenticationCookie($this->client);
     // Retrieve content.
     $crawler = $this->client->request('GET', '/settings/settings');
     // Submit domain selection.
     $buttonNode = $crawler->selectButton('settings_submit');
     $form = $buttonNode->form();
     /** @noinspection PhpUndefinedMethodInspection */
     $form['settings[ongr_settings_profile_profile_foo-2e-com]']->tick();
     $this->client->submit($form);
     // Load any url and check that user selected domains are loaded.
     $this->client->request('GET', '/settings/setting/name0/edit');
     $settingsContainer = $this->client->getContainer()->get('ongr_settings.settings_container');
     $selectedDomains = $settingsContainer->getProfiles();
     $this->assertEquals(['default', 'profile_foo.com'], $selectedDomains);
 }