| 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\Page;
class PageApiTest extends TestCase
{
use ApiTestTrait, WithoutMiddleware, DatabaseTransactions;
/**
* @test
*/
public function test_create_page()
{
$page = factory(Page::class)->make()->toArray();
$this->response = $this->json(
'POST',
'/api/pages', $page
);
$this->assertApiResponse($page);
}
/**
* @test
*/
public function test_read_page()
{
$page = factory(Page::class)->create();
$this->response = $this->json(
'GET',
'/api/pages/'.$page->id
);
$this->assertApiResponse($page->toArray());
}
/**
* @test
*/
public function test_update_page()
{
$page = factory(Page::class)->create();
$editedPage = factory(Page::class)->make()->toArray();
$this->response = $this->json(
'PUT',
'/api/pages/'.$page->id,
$editedPage
);
$this->assertApiResponse($editedPage);
}
/**
* @test
*/
public function test_delete_page()
{
$page = factory(Page::class)->create();
$this->response = $this->json(
'DELETE',
'/api/pages/'.$page->id
);
$this->assertApiSuccess();
$this->response = $this->json(
'GET',
'/api/pages/'.$page->id
);
$this->response->assertStatus(404);
}
}