feature tests

This commit is contained in:
Artur Nowakowski 2020-01-19 20:21:41 +01:00
parent 54c8053323
commit 7b3854eb17
3 changed files with 40 additions and 2 deletions

View File

@ -0,0 +1,19 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ProductsTest extends TestCase
{
use RefreshDatabase;
public function testGetProducts()
{
$response = $this->get('http://localhost:8000/api/product');
$response->assertStatus(200);
$response->assertJsonStructure(['success', 'data' => ['products']]);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class RecipesTest extends TestCase
{
use RefreshDatabase;
public function testGetRecipes()
{
$response = $this->get('http://localhost:8000/api/recipe');
$response->assertStatus(200);
$response->assertJsonStructure(['success', 'data' => ['recipes']]);
}
}

View File

@ -9,9 +9,9 @@ class UsersTest extends TestCase
{ {
use RefreshDatabase; use RefreshDatabase;
private array $loginData = ['email' => 'artur.nowakowski@gmail.com', 'password' => 'test123']; protected $loginData = ['email' => 'artur.nowakowski@gmail.com', 'password' => 'test123'];
public function getToken() protected function getToken()
{ {
$response = $this->post('http://localhost:8000/api/user/login', $this->loginData)->decodeResponseJson(); $response = $this->post('http://localhost:8000/api/user/login', $this->loginData)->decodeResponseJson();