[FrameworkBundle] Fix BrowserKit assertions to make them compatible with Panther

This commit is contained in:
Kévin Dunglas 2019-08-21 14:46:38 +02:00
parent 58439e3166
commit 2316dc36fb
No known key found for this signature in database
GPG Key ID: 4D04EBEF06AAF3A6
2 changed files with 4 additions and 4 deletions

View File

@ -13,7 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Test;
use PHPUnit\Framework\Constraint\LogicalAnd; use PHPUnit\Framework\Constraint\LogicalAnd;
use PHPUnit\Framework\Constraint\LogicalNot; 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\BrowserKit\Test\Constraint as BrowserKitConstraint;
use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\DomCrawler\Test\Constraint as DomCrawlerConstraint; use Symfony\Component\DomCrawler\Test\Constraint as DomCrawlerConstraint;
@ -186,7 +186,7 @@ trait WebTestAssertionsTrait
self::assertThat(self::getRequest(), $constraint, $message); self::assertThat(self::getRequest(), $constraint, $message);
} }
private static function getClient(KernelBrowser $newClient = null): ?KernelBrowser private static function getClient(AbstractBrowser $newClient = null): ?AbstractBrowser
{ {
static $client; static $client;
@ -194,7 +194,7 @@ trait WebTestAssertionsTrait
return $client = $newClient; 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__)); static::fail(sprintf('A client must be set to make assertions on it. Did you forget to call "%s::createClient()"?', __CLASS__));
} }

View File

@ -47,7 +47,7 @@ final class CrawlerSelectorAttributeValueSame extends Constraint
return false; return false;
} }
return $this->expectedText === trim($crawler->getNode(0)->getAttribute($this->attribute)); return $this->expectedText === trim($crawler->attr($this->attribute));
} }
/** /**