https://github.com/cba85/teach-notes-token-auth-api-tests
⚙️ Tests for Token Authentication Notes API project.
https://github.com/cba85/teach-notes-token-auth-api-tests
phpunit10
Last synced: 8 months ago
JSON representation
⚙️ Tests for Token Authentication Notes API project.
- Host: GitHub
- URL: https://github.com/cba85/teach-notes-token-auth-api-tests
- Owner: cba85
- Created: 2023-04-21T08:10:45.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-25T10:07:41.000Z (almost 3 years ago)
- Last Synced: 2025-03-11T21:43:53.160Z (12 months ago)
- Topics: phpunit10
- Language: PHP
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Token Authentication Notes API Test
Tests for Token Authentication Notes API project.
## Install
```
$ composer install
```
Set up your API url in a env variable by copying and setting `.env.example` file contents in a `.env` file.
```
API_URL="http://127.0.0.1:8000"
```
### Add a reset endpoint in your Laravel Sanctum API
Create a `DELETE /api/reset` endpoint to reset your database in your Laravel Sanctum project.
This endpoint will be call at the beginning of tests in `tests/bootstrap.php` file.
#### Example code
In `routes/api/php`, add:
```php
Route::delete('reset', [\App\Http\Controllers\ResetController::class, 'reset']);
```
In `app/Http/ResetController.php`, add:
```php
truncate();
return response(null, 204);
}
}
```
> Don't copy and paste blindly, adapt the code to your project.
## Usage
```bash
$ ./vendor/bin/phpunit
```