You are here

protected function ElementTest::mockNamedFinder in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/behat/mink/tests/Element/ElementTest.php \Behat\Mink\Tests\Element\ElementTest::mockNamedFinder()
19 calls to ElementTest::mockNamedFinder()
DocumentElementTest::testAttachFileToField in vendor/behat/mink/tests/Element/DocumentElementTest.php
DocumentElementTest::testCheckField in vendor/behat/mink/tests/Element/DocumentElementTest.php
DocumentElementTest::testClickButton in vendor/behat/mink/tests/Element/DocumentElementTest.php
DocumentElementTest::testClickLink in vendor/behat/mink/tests/Element/DocumentElementTest.php
DocumentElementTest::testFillField in vendor/behat/mink/tests/Element/DocumentElementTest.php

... See full list

File

vendor/behat/mink/tests/Element/ElementTest.php, line 41

Class

ElementTest

Namespace

Behat\Mink\Tests\Element

Code

protected function mockNamedFinder($xpath, array $results, $locator, $times = 2) {
  if (!is_array($results[0])) {
    $results = array(
      $results,
      array(),
    );
  }

  // In case of empty results, a second call will be done using the partial selector
  $processedResults = array();
  foreach ($results as $result) {
    $processedResults[] = $result;
    if (empty($result)) {
      $processedResults[] = $result;
      ++$times;
    }
  }
  $returnValue = call_user_func_array(array(
    $this,
    'onConsecutiveCalls',
  ), $processedResults);
  $this->driver
    ->expects($this
    ->exactly($times))
    ->method('find')
    ->with('//html' . $xpath)
    ->will($returnValue);
  $this->selectors
    ->expects($this
    ->exactly($times))
    ->method('selectorToXpath')
    ->with($this
    ->logicalOr('named_exact', 'named_partial'), $locator)
    ->will($this
    ->returnValue($xpath));
}