bug #33278 [FrameworkBundle] Fix BrowserKit assertions to make them compatible with Panther (dunglas)

This PR was merged into the 4.3 branch.

Discussion
----------

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

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | todo (remove the line telling that these assertions aren't compatible with Panther)

Backport of essential fixes provided by https://github.com/symfony/symfony/pull/32207. It allows most assertions to work with Panther even when using Symfony 4.3.

Commits
-------

2316dc36fb [FrameworkBundle] Fix BrowserKit assertions to make them compatible with Panther
This commit is contained in:
Fabien Potencier 2019-08-21 16:44:34 +02:00
commit 46b944f9a7
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\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__));
}

View File

@ -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));
}
/**