This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony
Fabien Potencier 17a3ccf4b3 feature #30813 New PHPUnit assertions for the WebTestCase (Pierstoval, fabpot)
This PR was merged into the 4.3-dev branch.

Discussion
----------

New PHPUnit assertions for the WebTestCase

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | replaces #29990
| License       | MIT
| Doc PR        | n/a

While reviewing #29990, and working on some tests, I realized that we could do better by adding PHPUnit constraint classes in various components that are then used in WebTextCase.

**Before**

```php
<?php

namespace App\Tests;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class DefaultControllerTest extends WebTestCase
{
    public function testSomething()
    {
        $client = static::createClient();
        $crawler = $client->request('GET', '/test');

        $this->assertSame(200, $client->getResponse()->getStatusCode());
        $this->assertContains('Hello World', $crawler->filter('h1')->text());
    }
}
```

**After**

```php
<?php

namespace App\Tests;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class DefaultControllerTest extends WebTestCase
{
    public function testSomething()
    {
        $client = static::createClient();
        $client->request('GET', '/test');

        $this->assertResponseIsSuccessful();
        $this->assertSelectorTextContains('h1', 'Hello World');
    }
}
```

Commits
-------

4f91020c8d added PHPUnit assertions in various components
2f8040ee84 Create new PHPUnit assertions for the WebTestCase
2019-04-01 18:54:09 +02:00
..
Bridge feature #30320 [Form][TwigBridge] Add row_attr to form theme (alexander-schranz) 2019-03-31 13:48:32 +02:00
Bundle feature #30813 New PHPUnit assertions for the WebTestCase (Pierstoval, fabpot) 2019-04-01 18:54:09 +02:00
Component feature #30813 New PHPUnit assertions for the WebTestCase (Pierstoval, fabpot) 2019-04-01 18:54:09 +02:00
Contracts fixed typo 2019-03-31 15:49:16 +02:00