/** * 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()); }
/** * When accessing not a admin-user settings page, no ES requests must be made. * * No index has been created in this test, so there will be an uncaught exception, if any queries were executed. * * @see \ONGR\SettingsBundle\Settings\Personal\PersonalProfilesProvider::getSettings */ public function testRequest() { $client = static::createClient(); $loginHelper = new LoginTestHelper($client); $client = $loginHelper->loginAction('test', 'test'); $response = $client->getResponse(); $this->assertContains('already logged in', $response->getContent()); $this->assertContains('General Settings', $response->getContent()); }
/** * @return array */ private function setAuthCookieAndReturn() { // Set authentication cookie. $this->client = $this->loginHelper->loginAction('test', 'test'); // Get cookie value. $cookie = $this->client->getCookieJar()->get('ongr_settings_user_auth'); $valueJson = $cookie->getValue(); $value = json_decode($valueJson, true); return [$cookie, $value]; }