You are here

public function NodeElementTest::testWaitForSuccess in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/behat/mink/tests/Element/NodeElementTest.php \Behat\Mink\Tests\Element\NodeElementTest::testWaitForSuccess()

File

vendor/behat/mink/tests/Element/NodeElementTest.php, line 73

Class

NodeElementTest

Namespace

Behat\Mink\Tests\Element

Code

public function testWaitForSuccess() {
  $callCounter = 0;
  $node = new NodeElement('some xpath', $this->session);
  $result = $node
    ->waitFor(5, function ($givenNode) use (&$callCounter) {
    ++$callCounter;
    if (1 === $callCounter) {
      return null;
    }
    elseif (2 === $callCounter) {
      return false;
    }
    elseif (3 === $callCounter) {
      return array();
    }
    return $givenNode;
  });
  $this
    ->assertEquals(4, $callCounter, '->waitFor() tries to locate element several times before failing');
  $this
    ->assertSame($node, $result, '->waitFor() returns node found in callback');
}