Skip to content

Commit

Permalink
Test deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
uuf6429 committed Nov 3, 2024
1 parent 02da744 commit 97f1e3e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/Custom/TimeoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
use Behat\Mink\Exception\DriverException;
use Behat\Mink\Tests\Driver\TestCase;
use Mink\WebdriverClassicDriver\WebdriverClassicDriver;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;

class TimeoutTest extends TestCase
{
use ExpectDeprecationTrait;

/**
* @after
*/
Expand Down Expand Up @@ -76,6 +79,32 @@ public function testShortPageLoadTimeoutThrowsException(): void

$this->expectException(DriverException::class);
$this->expectExceptionMessage('Page failed to load: ');

$session->visit($this->pathTo('/page_load.php?sleep=2'));
}

/**
* @group legacy
* @dataProvider deprecatedPageLoadDataProvider
*/
public function testDeprecatedShortPageLoadTimeoutThrowsException(string $type): void
{
$session = $this->getSession();
$driver = $session->getDriver();
\assert($driver instanceof WebdriverClassicDriver);

$driver->setTimeouts([$type => 500]);

$this->expectDeprecation('Using "' . $type . '" timeout type is deprecated, please use "page" instead');
$this->expectException(DriverException::class);
$this->expectExceptionMessage('Page failed to load: ');

$session->visit($this->pathTo('/page_load.php?sleep=2'));
}

public static function deprecatedPageLoadDataProvider(): iterable
{
yield ['type' => 'pageLoad'];
yield ['type' => 'page load'];
}
}

0 comments on commit 97f1e3e

Please sign in to comment.