Skip to content

Commit

Permalink
be compatible with Symfony 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
garak committed Jun 7, 2019
1 parent af68658 commit 4580cab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -8,6 +8,9 @@ This bundle contains just an opinionated extension of Symfony `WebTestCase`.
Documentation
-------------

>**WARNING** if you're using version 3 of this bundle with Symfony 4.2 and you want to upgrade to
>Symfony 4.3, you need to require version 4 of this bundle. See also [UPGRADE file](UPGRADE.md).
[Read the documentation](docs/index.md)

License
Expand Down
7 changes: 6 additions & 1 deletion UPGRADE.md
Expand Up @@ -6,7 +6,12 @@ From 3.0 to 4.0

Since Symfony Test class introduced a static `$client` property, we had to move our
own non-static property. So, you need to change every occurrence of `$this->client`
to `static::$client` in your tests.
to `self::$client` (or `static::$client`) in your tests.

You cannot pass `$crawler` as first parameter of method `getFormValue` anymore.
Such use of parameter was deprecated in version 3, so it has been removed now.

Method `ajax` is now static. Instead of `$this->ajax(...)`, you need to use `self::ajax(...)`

From 2.x to 3.0
---------------
Expand Down
16 changes: 1 addition & 15 deletions docs/index.md
Expand Up @@ -9,21 +9,7 @@ Run from terminal:
$ composer require --dev beelab/test-bundle
```

Enable bundle in the kernel:

```php
<?php
// app/AppKernel.php

public function registerBundles()
{
// ...
if ('test' === $this->getEnvironment()) {
// ...
$bundles[] = new Beelab\TestBundle\BeelabTestBundle();
}
}
```
Bundle should be enabled automatically by Flex.

## Usage

Expand Down
11 changes: 2 additions & 9 deletions src/Test/WebTestCase.php
Expand Up @@ -244,21 +244,14 @@ protected function assertMailSent(int $num, string $message = ''): void
* Get a form field value, from its id
* Useful for POSTs.
*
* @param Crawler|null $crawler
* @param string $fieldId
* @param int $position
*
* @return string
*/
protected function getFormValue(?Crawler $crawler, string $fieldId, int $position = 0): string
protected function getFormValue(string $fieldId, int $position = 0): string
{
if (null !== $crawler) {
$msg = 'Passing Crawler is deprecated. Pass null for now, in next major version parameter will be removed.';
@\trigger_error($msg, E_USER_DEPRECATED);
}
$crawler = $crawler ?? self::$client->getCrawler();

return $crawler->filter('#'.$fieldId)->eq($position)->attr('value');
return self::$client->getCrawler()->filter('#'.$fieldId)->eq($position)->attr('value');
}

/**
Expand Down

0 comments on commit 4580cab

Please sign in to comment.