An open API service indexing awesome lists of open source software.

https://github.com/intaro/symfony-testing-tools

Symfony testing tools
https://github.com/intaro/symfony-testing-tools

Last synced: over 1 year ago
JSON representation

Symfony testing tools

Awesome Lists containing this project

README

          

# Symfony testing tools

The library contains improved classes of WebTestCase and Container for convenient testing.

## Features

### The Client local caching

Web Client is caching in WebTestCase. If you want to get a client you should use:
```php
$client = static::getClient();
```

If you want to get a new client you should use:
```php
$client = static::getClient(true);
```

Full example:
```php
get('some_service');
//...
}
}
```

### Checking a response HTTP code

You can check response result with the following methods:

```php
request('GET', '/foo/bar/index');
$this->assertResponseOk($client->getResponse(), 'Page opens');
$this->assertResponseRedirect($client->getResponse(), 'Page redirects to other page');
$this->assertResponseNotFound($client->getResponse(), 'Page not found');
$this->assertResponseForbidden($client->getResponse(), 'Page forbidden');
$this->assertResponseCode(201, $client->getResponse(), 'JSON returned', 'application/json');
}
}
```

### Fixtures appending

You can add fixtures before test running:

```php
true,
]);
}

public function testIndex()
{
//...
}
}
```