From 2316dc36fba04bcf53cd7543130c375010f52c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 21 Aug 2019 14:46:38 +0200 Subject: [PATCH] [FrameworkBundle] Fix BrowserKit assertions to make them compatible with Panther --- .../Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php | 6 +++--- .../Test/Constraint/CrawlerSelectorAttributeValueSame.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php index f820e8d080..f7c4818dcb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php @@ -13,7 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Test; use PHPUnit\Framework\Constraint\LogicalAnd; use PHPUnit\Framework\Constraint\LogicalNot; -use Symfony\Bundle\FrameworkBundle\KernelBrowser; +use Symfony\Component\BrowserKit\AbstractBrowser; use Symfony\Component\BrowserKit\Test\Constraint as BrowserKitConstraint; use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Test\Constraint as DomCrawlerConstraint; @@ -186,7 +186,7 @@ trait WebTestAssertionsTrait self::assertThat(self::getRequest(), $constraint, $message); } - private static function getClient(KernelBrowser $newClient = null): ?KernelBrowser + private static function getClient(AbstractBrowser $newClient = null): ?AbstractBrowser { static $client; @@ -194,7 +194,7 @@ trait WebTestAssertionsTrait return $client = $newClient; } - if (!$client instanceof KernelBrowser) { + if (!$client instanceof AbstractBrowser) { static::fail(sprintf('A client must be set to make assertions on it. Did you forget to call "%s::createClient()"?', __CLASS__)); } diff --git a/src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorAttributeValueSame.php b/src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorAttributeValueSame.php index 962b6bf0b1..7008779e14 100644 --- a/src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorAttributeValueSame.php +++ b/src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorAttributeValueSame.php @@ -47,7 +47,7 @@ final class CrawlerSelectorAttributeValueSame extends Constraint return false; } - return $this->expectedText === trim($crawler->getNode(0)->getAttribute($this->attribute)); + return $this->expectedText === trim($crawler->attr($this->attribute)); } /**