mirror of https://github.com/kcal-app/kcal.git
56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Http\Controllers;
|
|
|
|
use App\Http\Controllers\FoodController;
|
|
use App\Models\Food;
|
|
use Database\Factories\FoodFactory;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
class FoodControllerTest extends HttpControllerTestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function class(): string
|
|
{
|
|
return FoodController::class;
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function factory(): FoodFactory
|
|
{
|
|
return Food::factory();
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function routeKey(): string
|
|
{
|
|
return 'food';
|
|
}
|
|
|
|
public function testCanAddFoodWithoutNutrients(): void
|
|
{
|
|
/** @var \App\Models\Food $food */
|
|
$food = $this->factory()->make([
|
|
'calories' => NULL,
|
|
'fat' => NULL,
|
|
'cholesterol' => NULL,
|
|
'sodium' => NULL,
|
|
'carbohydrates' => NULL,
|
|
'protein' => NULL,
|
|
]);
|
|
$store_url = action([FoodController::class, 'store']);
|
|
$response = $this->followingRedirects()->post($store_url, $food->toArray());
|
|
$response->assertOk();
|
|
$response->assertSee("Food {$food->name} updated!");
|
|
}
|
|
|
|
}
|