You are here

public function ScreenshotTest::testScreenshot in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/behat/mink/driver-testsuite/tests/Basic/ScreenshotTest.php \Behat\Mink\Tests\Driver\Basic\ScreenshotTest::testScreenshot()

File

vendor/behat/mink/driver-testsuite/tests/Basic/ScreenshotTest.php, line 9

Class

ScreenshotTest

Namespace

Behat\Mink\Tests\Driver\Basic

Code

public function testScreenshot() {
  if (!extension_loaded('gd')) {
    $this
      ->markTestSkipped('Testing screenshots requires the GD extension');
  }
  $this
    ->getSession()
    ->visit($this
    ->pathTo('/index.html'));
  $screenShot = $this
    ->getSession()
    ->getScreenshot();
  $this
    ->assertInternalType('string', $screenShot);
  $this
    ->assertFalse(base64_decode($screenShot, true), 'The returned screenshot should not be base64-encoded');
  $img = imagecreatefromstring($screenShot);
  if (false === $img) {
    $this
      ->fail('The screenshot should be a valid image');
  }
  imagedestroy($img);
}