Skip to content

Commit

Permalink
Update the doc
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGuilloux committed Feb 3, 2020
1 parent 995af4a commit 4c25911
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
28 changes: 24 additions & 4 deletions Docs/TestCases.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ In the following TestCase, it is recommanded to avoid overriding `setUp()` and `

Moreover, each test case uses from the MockeryPHPUnitIntegration so no need to use the integration trait.


### MockeryTestCase

The MockeryTestCase is almost the same as the initial except the `setUp()` and `tearDown()` management which is replaced in the test by `beforeTest()` and `afterTest()`.
To use a container or fixtures, please follow this [documentation](Annotations.md).


### CommandTestCase
Expand Down Expand Up @@ -75,6 +72,26 @@ The ControllerTestCase provides a set of useful functions. Note that for this te

- `getJsonContent()`: Returns an array or object corresponding to the JSON response linked to the client.

```php
/**
* @WithFixtures
*/
class ExampleControllerTest extends ControllerTestCase
{
public function testRoute(): void
{
$client = self::createClient();
$client->request('POST', '/post/route', [
'_token' => self::getCsrfToken('csrf_token_id', $client),
// ...
]);

self::assertStatusCode(Response::HTTP_CREATED, $client);
self::assertArrayKeyExists('id', self::getJsonContent($client));
}
}
```


### RepositoryTestCase

Expand All @@ -83,6 +100,9 @@ The entity linked to repository must be set using the `public const ENTITY`. Mor
```php
use RichCongress\Bundle\UnitBundle\TestCase\RepositoryTestCase;

/**
* @WithFixtures
*/
class UserRepositoryTest extends RepositoryTestCase
{
public const ENTITY = User::class;
Expand Down
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,17 @@ As a reminder, all contributors are expected to follow our [Code of Conduct](COD
You might use Docker and `docker-compose` to hack the project. Check out the following commands.

```bash
# Create the proxy
docker network create proxy
# Create a nginx-proxy (makes sure the port 80 is available)
docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro --name nginx-proxy --net proxy --privileged --userns=host richcongress/nginx-proxy
# Start the project
docker-compose up -d
# Install dependencies
composer install
docker-compose exec application composer install
# Run tests
bin/phpunit
docker-compose exec application bin/phpunit
# Run a bash within the container
docker-compose exec application bash
```


Expand Down

0 comments on commit 4c25911

Please sign in to comment.