mirror of https://github.com/kcal-app/kcal.git
				
				
				
			
		
			
				
	
	
		
			55 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
| <?php
 | |
| 
 | |
| namespace Tests\Feature\JsonApi;
 | |
| 
 | |
| use App\Models\Food;
 | |
| use App\Models\IngredientAmount;
 | |
| use App\Models\JournalEntry;
 | |
| use App\Models\Recipe;
 | |
| use Database\Factories\IngredientAmountFactory;
 | |
| 
 | |
| class IngredientAmountApiTest extends JsonApiTestCase
 | |
| {
 | |
| 
 | |
|     /**
 | |
|      * @inheritdoc
 | |
|      */
 | |
|     public function factory(): IngredientAmountFactory
 | |
|     {
 | |
|         return IngredientAmount::factory();
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @inheritdoc
 | |
|      */
 | |
|     public function resourceName(): string
 | |
|     {
 | |
|         return 'ingredient-amounts';
 | |
|     }
 | |
| 
 | |
|     public function testCanGetRelatedIngredient(): void {
 | |
|         $ingredient = Food::factory()->create();
 | |
|         $record = $this->factory()->ingredient($ingredient)->create();
 | |
|         $this->getRelatedData($record, 'ingredient', 'foods');
 | |
|     }
 | |
| 
 | |
|     public function testCanIncludeRelatedIngredient(): void {
 | |
|         $ingredient = Recipe::factory()->create();
 | |
|         $record = $this->factory()->ingredient($ingredient)->create();
 | |
|         $this->getRelatedData($record, 'ingredient', 'recipes');
 | |
|     }
 | |
| 
 | |
|     public function testCanGetRelatedParent(): void {
 | |
|         $parent = Recipe::factory()->create();
 | |
|         $record = $this->factory()->parent($parent)->create();
 | |
|         $this->getRelatedData($record, 'parent', 'recipes');
 | |
|     }
 | |
| 
 | |
|     public function testCanIncludeRelatedParent(): void {
 | |
|         $parent = JournalEntry::factory()->create();
 | |
|         $record = $this->factory()->parent($parent)->create();
 | |
|         $this->getRelatedData($record, 'parent', 'journal-entries');
 | |
|     }
 | |
| 
 | |
| }
 |