Skip to content

Commit

Permalink
Merge pull request #67 from jolicode/fix-readme-issues
Browse files Browse the repository at this point in the history
Fix some issues in the README
  • Loading branch information
joelwurtz authored May 7, 2024
2 parents 3c82793 + 6641423 commit e6c74d8
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class ApiTest
Then you can add some tests that will use the API of the TestCase class:

```php
use Asynit\TestCase;
use Asynit\Test;
use Asynit\Attribute\Test;
use Asynit\Attribute\TestCase;

#[TestCase]
class ApiTest
Expand All @@ -52,8 +52,8 @@ A test fail when an exception occurs during the test
Asynit provide trait to ease the writing of test. You can use the `Asynit\AssertCaseTrait` trait to use the assertion.

```php
use Asynit\TestCase;
use Asynit\Test;
use Asynit\Attribute\Test;
use Asynit\Attribute\TestCase;

#[TestCase]
class ApiTest
Expand Down Expand Up @@ -93,6 +93,9 @@ Asynit provide an optional `Asynit\HttpClient\HttpClientWebCaseTrait` trait that
`nyholm/psr7` to use it.

```php
use Asynit\Attribute\TestCase;
use Asynit\HttpClient\HttpClientWebCaseTrait;

#[TestCase]
class FunctionalHttpTests
{
Expand All @@ -112,6 +115,9 @@ You can also use a more oriented API trait `Asynit\HttpClient\HttpClientApiCaseT


```php
use Asynit\Attribute\TestCase;
use Asynit\HttpClient\HttpClientApiCaseTrait;

#[TestCase]
class FunctionalHttpTests
{
Expand Down Expand Up @@ -143,6 +149,10 @@ successful, `C` will be run with the result from `A`.
Let's see an example:

```php
use Asynit\Attribute\Depend;
use Asynit\Attribute\TestCase;
use Asynit\HttpClient\HttpClientApiCaseTrait;

#[TestCase]
class SecurityTest extends TestCase
{
Expand Down Expand Up @@ -173,6 +183,10 @@ test case is under the `Application\ApiTest` namespace and thus we can write
another test case like this:

```php
use Asynit\Attribute\Depend;
use Asynit\Attribute\TestCase;
use Asynit\HttpClient\HttpClientApiCaseTrait;

#[TestCase]
class PostTest
{
Expand All @@ -196,7 +210,7 @@ So you could write a `TokenFetcherClass` that will fetch the token and then use
```php
namespace App\Tests;

use Asynit\TestCase;
use Asynit\HttpClient\HttpClientApiCaseTrait;

class TokenFetcher
{
Expand Down Expand Up @@ -226,11 +240,17 @@ Then in your test class you will be able to call this method:
```php
namespace App\Tests;

use Asynit\Attribute\Depend;
use Asynit\Attribute\TestCase;
use Asynit\HttpClient\HttpClientApiCaseTrait;

#[TestCase]
class OrganizationTest
{
use HttpClientApiCaseTrait;

#[Depend("App\Tests\TokenFetcher::fetchUserToken")]
public function test_api_method_with_token()
public function test_api_method_with_token(string $token)
{
$response = $this->get('/api', headers: ['X-Auth-Token' => $token]);

Expand Down

0 comments on commit e6c74d8

Please sign in to comment.