You are here

public function CoreDriverTest::testCreateNodeElements in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/behat/mink/tests/Driver/CoreDriverTest.php \Behat\Mink\Tests\Driver\CoreDriverTest::testCreateNodeElements()

File

vendor/behat/mink/tests/Driver/CoreDriverTest.php, line 22

Class

CoreDriverTest

Namespace

Behat\Mink\Tests\Driver

Code

public function testCreateNodeElements() {
  $driver = $this
    ->getMockBuilder('Behat\\Mink\\Driver\\CoreDriver')
    ->setMethods(array(
    'findElementXpaths',
  ))
    ->getMockForAbstractClass();
  $session = $this
    ->getMockBuilder('Behat\\Mink\\Session')
    ->disableOriginalConstructor()
    ->getMock();
  $driver
    ->setSession($session);
  $driver
    ->expects($this
    ->once())
    ->method('findElementXpaths')
    ->with('xpath')
    ->willReturn(array(
    'xpath1',
    'xpath2',
  ));

  /** @var NodeElement[] $elements */
  $elements = $driver
    ->find('xpath');
  $this
    ->assertInternalType('array', $elements);
  $this
    ->assertCount(2, $elements);
  $this
    ->assertContainsOnlyInstancesOf('Behat\\Mink\\Element\\NodeElement', $elements);
  $this
    ->assertSame('xpath1', $elements[0]
    ->getXpath());
  $this
    ->assertSame('xpath2', $elements[1]
    ->getXpath());
}