Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 850d193

Browse files
committed
Allow to use the assertions with Panther
1 parent ee25339 commit 850d193

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/Symfony/Bundle/FrameworkBundle/Test/BrowserKitAssertionsTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use PHPUnit\Framework\Constraint\LogicalAnd;
1515
use PHPUnit\Framework\Constraint\LogicalNot;
16-
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
16+
use Symfony\Component\BrowserKit\AbstractBrowser;
1717
use Symfony\Component\BrowserKit\Test\Constraint as BrowserKitConstraint;
1818
use Symfony\Component\HttpFoundation\Request;
1919
use Symfony\Component\HttpFoundation\Response;
@@ -124,15 +124,15 @@ public static function assertRouteSame($expectedRoute, array $parameters = [], s
124124
self::assertThat(self::getRequest(), $constraint, $message);
125125
}
126126

127-
private static function getClient(KernelBrowser $newClient = null): ?KernelBrowser
127+
private static function getClient(AbstractBrowser $newClient = null): ?AbstractBrowser
128128
{
129129
static $client;
130130

131131
if (0 < \func_num_args()) {
132132
return $client = $newClient;
133133
}
134134

135-
if (!$client instanceof KernelBrowser) {
135+
if (!$client instanceof AbstractBrowser) {
136136
static::fail(sprintf('A client must be set to make assertions on it. Did you forget to call "%s::createClient()"?', __CLASS__));
137137
}
138138

src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Test;
1313

14-
1514
/**
1615
* Ideas borrowed from Laravel Dusk's assertions.
1716
*

src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorAttributeValueSame.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\Constraint\Constraint;
1515
use Symfony\Component\DomCrawler\Crawler;
16+
use Symfony\Component\Panther\DomCrawler\Crawler as PantherCrawler;
1617

1718
final class CrawlerSelectorAttributeValueSame extends Constraint
1819
{
@@ -47,7 +48,13 @@ protected function matches($crawler): bool
4748
return false;
4849
}
4950

50-
return $this->expectedText === trim($crawler->getNode(0)->getAttribute($this->attribute));
51+
if ($crawler instanceof PantherCrawler) {
52+
$actualText = $crawler->getAttribute($this->attribute);
53+
} else {
54+
$actualText = $crawler->getNode(0)->getAttribute($this->attribute);
55+
}
56+
57+
return $this->expectedText === trim($actualText);
5158
}
5259

5360
/**

0 commit comments

Comments
 (0)