示例#1
0
 /**
  * Вход в учетную запись по логину и паролю
  *
  * В этом методе заполняются поля: логин и пароль, после чего нажимается кнопка "Вход"
  *
  * @param string $username Имя пользователя
  * @param string $password Пароль учетной записи
  *
  * @Given /^я вхожу в учетную запись с именем "([^"]*)" и паролем "([^"]*)"$/
  */
 public function login($username, $password)
 {
     $this->minkContext->visit('/login');
     $this->minkContext->fillField('username', $username);
     $this->minkContext->fillField('password', $password);
     $this->minkContext->pressButton('Войти');
 }
示例#2
0
 /**
  * @Given I am authenticated as :username
  * @Given I am authenticated as :username on firewall :firewall
  */
 public function iAmAuthenticatedAs($username, $firewall = 'main')
 {
     /** @var \Behat\Mink\Session $session */
     $minkSession = $this->minkContext->getSession();
     /** @var \Behat\Symfony2Extension\Driver\KernelDriver $driver */
     $driver = $minkSession->getDriver();
     if (!$driver instanceof BrowserKitDriver) {
         throw new UnsupportedDriverActionException('This step is only supported by the BrowserKitDriver', $driver);
     }
     /** @var \Symfony\Component\Security\Core\User\UserProviderInterface $userProvider */
     $userProvider = $this->getContainer()->get('fos_user.user_manager');
     $user = $userProvider->loadUserByUsername($username);
     $token = new UsernamePasswordToken($user, null, $firewall, $user->getRoles());
     $client = $driver->getClient();
     $session = $client->getContainer()->get('session');
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $client->getCookieJar()->set($cookie);
 }
 /**
  * {@inheritdoc}
  */
 public function assertPageContainsText($text)
 {
     $this->spin(function () use($text) {
         parent::assertPageContainsText($text);
         return true;
     }, "Spining for asserting page contains text {$text}");
 }
 /**
  * @param string $path
  * @return string
  */
 public function locatePath($path)
 {
     return parent::locatePath($this->getSubcontext('flow')->resolvePath($path));
 }
示例#5
0
 /**
  * Presses button with specified id|name|title|alt|value.
  *
  * @When I press the :button button
  */
 public function pressButton($button)
 {
     // Wait for any open autocomplete boxes to finish closing.  They block
     // form-submission if they are still open.
     // Use a step 'I press the "Esc" key in the "LABEL" field' to close
     // autocomplete suggestion boxes with Mink.  "Click" events on the
     // autocomplete suggestion do not work.
     try {
         $this->getSession()->wait(1000, 'typeof(jQuery)=="undefined" || jQuery("#autocomplete").length === 0');
     } catch (UnsupportedDriverActionException $e) {
         // The jQuery probably failed because the driver does not support
         // javascript.  That is okay, because if the driver does not support
         // javascript, it does not support autocomplete boxes either.
     }
     // Use the Mink Extension step definition.
     return parent::pressButton($button);
 }
 /**
  * Selects option in select field with specified id|name|label|value.
  *
  * @override /^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
  */
 public function selectOption($select, $option)
 {
     // Find field
     $field = $this->getSession()->getPage()->findField($this->fixStepArgument($select));
     // If field is visible then select it as per normal
     if ($field && $field->isVisible()) {
         parent::selectOption($select, $option);
     } else {
         $this->selectOptionWithJavascript($select, $option);
     }
 }
 /**
  * Selects option in select field with specified id|name|label|value.
  *
  * @Overrrides /^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
  */
 public function selectOption($select, $option)
 {
     $this->substituteKeywords($option);
     parent::selectOption($select, $option);
 }
 /**
  * Override method to wait for Ajax requests to finish before continuing
  *
  * @param $text
  */
 public function assertPageContainsText($text)
 {
     $this->getSession()->wait(10000, '(typeof(jQuery)=="undefined" || (0 === jQuery.active && 0 === jQuery(\':animated\').length))');
     parent::assertPageContainsText($text);
 }
示例#9
0
 /**
  * @When /^(?:|I )follow the link containing "(?P<link>(?:[^"]|\\")*)"$/
  */
 public function clickLinkContaining($link)
 {
     parent::clickLink($link);
 }
 /**
  * Fills in form field with specified id|name|label|value
  * Example: When I fill in "admin_password2" with the command line global variable: "WORDPRESS_ADMIN_PASSWORD"
  *
  * @When I fill in :arg1 with the command line global variable: :arg2
  */
 public function fillFieldWithGlobal($field, $value)
 {
     $this->minkContext->fillField($field, getenv($value));
 }
示例#11
0
 public function locatePath($path)
 {
     return parent::locatePath($this->getPathTo($path));
 }
 /**
  * {@inheritdoc}
  */
 public function assertNumElements($num, $element)
 {
     $this->spin(function () use($num, $element) {
         parent::assertNumElements($num, $element);
         return true;
     });
 }
示例#13
0
 /**
  * Fills in form field with specified id|name|label|value.
  *
  * @When /^(?:|I )fill field "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/
  */
 public function fillField($field, $value)
 {
     if (!$this->_uniqid) {
         $content = $this->getSession()->getPage()->getContent();
         if (preg_match('/\\?uniqid=(.*?)\\&/is', $content, $match)) {
             $this->_uniqid = $match[1];
         }
     }
     parent::fillField($this->_uniqid . '_' . $field, $value);
 }
示例#14
0
 /**
  * @param null $name
  * @return Session
  */
 public function getSession($name = null)
 {
     return parent::getSession($name);
 }