1. Go to this page and download the library: Download ysato/spectator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ysato / spectator example snippets
namespace Tests\Feature;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Ysato\Spectator\Spectatable;
abstract class TestCase extends BaseTestCase
{
use Spectatable;
}
namespace Tests\Feature;
class UserTest extends TestCase
{
public function test_can_list_users()
{
// Regular Feature test - automatically monitored
$response = $this->get('/api/users');
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => [
'*' => ['id', 'name', 'email']
]
]);
}
public function test_can_create_user()
{
$userData = [
'name' => 'Test User',
'email' => '[email protected]',
'password' => 'password123'
];
$response = $this->post('/api/users', $userData);
$response->assertStatus(201);
}
public function test_returns_404_for_nonexistent_user()
{
$response = $this->get('/api/users/9999');
$response->assertStatus(404);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.