You are here

class ErrorHandlingTest in Zircon Profile 8

Same name in this branch
  1. 8 vendor/behat/mink-browserkit-driver/tests/Custom/ErrorHandlingTest.php \Behat\Mink\Tests\Driver\Custom\ErrorHandlingTest
  2. 8 vendor/behat/mink/driver-testsuite/tests/Basic/ErrorHandlingTest.php \Behat\Mink\Tests\Driver\Basic\ErrorHandlingTest
Same name and namespace in other branches
  1. 8.0 vendor/behat/mink-browserkit-driver/tests/Custom/ErrorHandlingTest.php \Behat\Mink\Tests\Driver\Custom\ErrorHandlingTest

Hierarchy

  • class \Behat\Mink\Tests\Driver\Custom\ErrorHandlingTest extends \Behat\Mink\Tests\Driver\Custom\PHPUnit_Framework_TestCase

Expanded class hierarchy of ErrorHandlingTest

File

vendor/behat/mink-browserkit-driver/tests/Custom/ErrorHandlingTest.php, line 9

Namespace

Behat\Mink\Tests\Driver\Custom
View source
class ErrorHandlingTest extends \PHPUnit_Framework_TestCase {

  /**
   * @var TestClient
   */
  private $client;
  protected function setUp() {
    $this->client = new TestClient();
  }
  public function testGetClient() {
    $this
      ->assertSame($this->client, $this
      ->getDriver()
      ->getClient());
  }

  /**
   * @expectedException \Behat\Mink\Exception\DriverException
   * @expectedExceptionMessage Unable to access the response before visiting a page
   */
  public function testGetResponseHeaderWithoutVisit() {
    $this
      ->getDriver()
      ->getResponseHeaders();
  }

  /**
   * @expectedException \Behat\Mink\Exception\DriverException
   * @expectedExceptionMessage Unable to access the response content before visiting a page
   */
  public function testFindWithoutVisit() {
    $this
      ->getDriver()
      ->find('//html');
  }

  /**
   * @expectedException \Behat\Mink\Exception\DriverException
   * @expectedExceptionMessage Unable to access the request before visiting a page
   */
  public function testGetCurrentUrlWithoutVisit() {
    $this
      ->getDriver()
      ->getCurrentUrl();
  }

  /**
   * @expectedException \Behat\Mink\Exception\DriverException
   * @expectedExceptionMessage The selected node has an invalid form attribute (foo)
   */
  public function testNotMatchingHtml5FormId() {
    $html = <<<'HTML'
<html>
<body>
    <form id="test">
        <input name="test" value="foo" form="foo">
        <input type="submit">
    </form>
</body>
</html>
HTML;
    $this->client
      ->setNextResponse(new Response($html));
    $driver = $this
      ->getDriver();
    $driver
      ->visit('/index.php');
    $driver
      ->setValue('//input[./@name="test"]', 'bar');
  }

  /**
   * @expectedException \Behat\Mink\Exception\DriverException
   * @expectedExceptionMessage The selected node has an invalid form attribute (foo)
   */
  public function testInvalidHtml5FormId() {
    $html = <<<'HTML'
<html>
<body>
    <form id="test">
        <input name="test" value="foo" form="foo">
        <input type="submit">
    </form>
    <div id="foo"></div>
</body>
</html>
HTML;
    $this->client
      ->setNextResponse(new Response($html));
    $driver = $this
      ->getDriver();
    $driver
      ->visit('/index.php');
    $driver
      ->setValue('//input[./@name="test"]', 'bar');
  }

  /**
   * @expectedException \Behat\Mink\Exception\DriverException
   * @expectedExceptionMessage The selected node does not have a form ancestor.
   */
  public function testManipulateInputWithoutForm() {
    $html = <<<'HTML'
<html>
<body>
    <form id="test">
        <input type="submit">
    </form>
    <div id="foo">
        <input name="test" value="foo">
    </div>
</body>
</html>
HTML;
    $this->client
      ->setNextResponse(new Response($html));
    $driver = $this
      ->getDriver();
    $driver
      ->visit('/index.php');
    $driver
      ->setValue('//input[./@name="test"]', 'bar');
  }

  /**
   * @expectedException \Behat\Mink\Exception\DriverException
   * @expectedExceptionMessage Behat\Mink\Driver\BrowserKitDriver supports clicking on links and submit or reset buttons only. But "div" provided
   */
  public function testClickOnUnsupportedElement() {
    $html = <<<'HTML'
<html>
<body>
    <div></div>
</body>
</html>
HTML;
    $this->client
      ->setNextResponse(new Response($html));
    $driver = $this
      ->getDriver();
    $driver
      ->visit('/index.php');
    $driver
      ->click('//div');
  }
  private function getDriver() {
    return new BrowserKitDriver($this->client);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ErrorHandlingTest::$client private property
ErrorHandlingTest::getDriver private function
ErrorHandlingTest::setUp protected function
ErrorHandlingTest::testClickOnUnsupportedElement public function @expectedException \Behat\Mink\Exception\DriverException @expectedExceptionMessage Behat\Mink\Driver\BrowserKitDriver supports clicking on links and submit or reset buttons only. But "div" provided
ErrorHandlingTest::testFindWithoutVisit public function @expectedException \Behat\Mink\Exception\DriverException @expectedExceptionMessage Unable to access the response content before visiting a page
ErrorHandlingTest::testGetClient public function
ErrorHandlingTest::testGetCurrentUrlWithoutVisit public function @expectedException \Behat\Mink\Exception\DriverException @expectedExceptionMessage Unable to access the request before visiting a page
ErrorHandlingTest::testGetResponseHeaderWithoutVisit public function @expectedException \Behat\Mink\Exception\DriverException @expectedExceptionMessage Unable to access the response before visiting a page
ErrorHandlingTest::testInvalidHtml5FormId public function @expectedException \Behat\Mink\Exception\DriverException @expectedExceptionMessage The selected node has an invalid form attribute (foo)
ErrorHandlingTest::testManipulateInputWithoutForm public function @expectedException \Behat\Mink\Exception\DriverException @expectedExceptionMessage The selected node does not have a form ancestor.
ErrorHandlingTest::testNotMatchingHtml5FormId public function @expectedException \Behat\Mink\Exception\DriverException @expectedExceptionMessage The selected node has an invalid form attribute (foo)