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
- Host: GitHub
- URL: https://github.com/intaro/symfony-testing-tools
- Owner: intaro
- License: mit
- Created: 2016-03-25T06:31:16.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-25T08:43:38.000Z (over 10 years ago)
- Last Synced: 2024-05-14T12:03:34.224Z (about 2 years ago)
- Language: PHP
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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()
{
//...
}
}
```