/**
  * Have to be called after get the MultipleElement to find all its siblings
  * @param  \Behat\Mink\Element\Element $parent
  * @return $this
  */
 public function setParent(\Behat\Mink\Element\Element $parent)
 {
     $selectorType = key($this->selector);
     $locator = $this->selector[$selectorType];
     $this->siblings = $parent->findAll($selectorType, $locator);
     if ($this->valid()) {
         $this->setInstance();
     }
     return $this;
 }
Пример #2
0
 /**
  * Check whether an element containing the specified text exists.
  *
  * @param Element $page     Page element
  * @param string  $selector CSS selector
  * @param string  $text     Expected text
  *
  * @return bool
  */
 protected function hasElementsMatchingText(Element $page, $selector, $text)
 {
     foreach ($page->findAll('css', $selector) as $current) {
         if ($text === $current->getText()) {
             return true;
         }
     }
     return false;
 }
 /**
  * Asserts a particular row from the cache purge rules overview.
  *
  * @param Element $row
  *   The table row.
  * @param array $expected_rule
  *   The expected values for the cache purge rule.
  */
 protected function assertOverviewCachePurgeRule(Element $row, array $expected_rule)
 {
     /** @var Element[] $cells */
     $cells = $row->findAll('css', 'td');
     assert($cells[0]->getText(), equals($expected_rule['Content Type']));
     assert($cells[1]->getText(), equals($expected_rule['Paths to Purge']));
 }
Пример #4
0
 /**
  * Retrieve a table row containing specified text from a given element.
  *
  * @param \Behat\Mink\Element\Element
  * @param string
  *   The text to search for in the table row.
  *
  * @return \Behat\Mink\Element\NodeElement
  *
  * @throws \Exception
  */
 public function getTableRow(Element $element, $search)
 {
     $rows = $element->findAll('css', 'tr');
     if (empty($rows)) {
         throw new \Exception(sprintf('No rows found on the page %s', $this->getSession()->getCurrentUrl()));
     }
     foreach ($rows as $row) {
         if (strpos($row->getText(), $search) !== FALSE) {
             return $row;
         }
     }
     throw new \Exception(sprintf('Failed to find a row containing "%s" on the page %s', $search, $this->getSession()->getCurrentUrl()));
 }
Пример #5
0
 /**
  * Helper function for facets lists
  *
  * @param \Behat\Mink\Element\Element $page            Mink page object
  * @param int                         $limit           Configured lightbox length
  * @param bool                        $exclusionActive Is facet exclusion on?
  *
  * @return void
  */
 protected function facetListProcedure($page, $limit, $exclusionActive = false)
 {
     $this->snooze();
     $items = $page->findAll('css', '#modal #facet-list-count .js-facet-item');
     $this->assertEquals($limit, count($items));
     $excludes = $page->findAll('css', '#modal #facet-list-count .badge .fa-times');
     $this->assertEquals($exclusionActive ? $limit : 0, count($excludes));
     // more
     $this->findCss($page, '#modal .js-facet-next-page')->click();
     $this->snooze();
     $items = $page->findAll('css', '#modal #facet-list-count .js-facet-item');
     $this->assertEquals($limit * 2, count($items));
     $this->assertEquals('Weird IDs 9 ' . 'Fiction 7 ' . 'The Study Of P|pes 1 ' . 'The Study and Scor_ng of Dots.and-Dashes:Colons 1 ' . 'The Study of "Important" Things 1 ' . 'The Study of %\'s? 1 ' . 'The Study of +\'s? 1 ' . 'The Study of @Twitter #test 1 ' . 'more ...', $this->findCss($page, '#modal #facet-list-count')->getText());
     $excludes = $page->findAll('css', '#modal #facet-list-count .badge .fa-times');
     $this->assertEquals($exclusionActive ? $limit * 2 : 0, count($excludes));
     // sort by title
     $this->findCss($page, '[data-sort="index"]')->click();
     $this->snooze();
     $items = $page->findAll('css', '#modal #facet-list-index .js-facet-item');
     $this->assertEquals($limit, count($items));
     // reset number of items
     $this->assertEquals('Fiction 7 ' . 'The Study Of P|pes 1 ' . 'The Study and Scor_ng of Dots.and-Dashes:Colons 1 ' . 'The Study of "Important" Things 1 ' . 'more ...', $this->findCss($page, '#modal #facet-list-index')->getText());
     $excludes = $page->findAll('css', '#modal #facet-list-index .badge .fa-times');
     $this->assertEquals($exclusionActive ? $limit : 0, count($excludes));
     // sort by index again
     $this->findCss($page, '[data-sort="count"]')->click();
     $this->snooze();
     $items = $page->findAll('css', '#modal #facet-list-count .js-facet-item');
     $this->assertEquals($limit * 2, count($items));
     // maintain number of items
     // When exclusion is active, the result count is outside of the link tag:
     $expectedLinkText = $exclusionActive ? 'Weird IDs' : 'Weird IDs 9';
     $weirdIDs = $this->findAndAssertLink($page->findById('modal'), $expectedLinkText);
     $this->assertEquals($expectedLinkText, $weirdIDs->getText());
     // apply US facet
     $weirdIDs->click();
     $this->snooze();
 }