| Server IP : 77.68.25.176 / Your IP : 216.73.216.25 Web Server : Apache System : Linux plesk 4.15.0-159-generic #167-Ubuntu SMP Tue Sep 21 08:55:05 UTC 2021 x86_64 User : dwp ( 10001) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/dazzlingwebplanet.co.uk/rightway.dazzlingwebplanet.com/tests/APIs/ |
Upload File : |
<?php namespace Tests\APIs;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
use Tests\ApiTestTrait;
use App\Models\Blog;
class BlogApiTest extends TestCase
{
use ApiTestTrait, WithoutMiddleware, DatabaseTransactions;
/**
* @test
*/
public function test_create_blog()
{
$blog = factory(Blog::class)->make()->toArray();
$this->response = $this->json(
'POST',
'/api/blogs', $blog
);
$this->assertApiResponse($blog);
}
/**
* @test
*/
public function test_read_blog()
{
$blog = factory(Blog::class)->create();
$this->response = $this->json(
'GET',
'/api/blogs/'.$blog->id
);
$this->assertApiResponse($blog->toArray());
}
/**
* @test
*/
public function test_update_blog()
{
$blog = factory(Blog::class)->create();
$editedBlog = factory(Blog::class)->make()->toArray();
$this->response = $this->json(
'PUT',
'/api/blogs/'.$blog->id,
$editedBlog
);
$this->assertApiResponse($editedBlog);
}
/**
* @test
*/
public function test_delete_blog()
{
$blog = factory(Blog::class)->create();
$this->response = $this->json(
'DELETE',
'/api/blogs/'.$blog->id
);
$this->assertApiSuccess();
$this->response = $this->json(
'GET',
'/api/blogs/'.$blog->id
);
$this->response->assertStatus(404);
}
}