mirror of https://github.com/kcal-app/kcal.git
Give test user some goals and journal entries
This commit is contained in:
parent
69701ee4d8
commit
f56fab3fd0
|
@ -32,6 +32,8 @@ class GoalApiTest extends JsonApiTestCase
|
|||
* @inheritdoc
|
||||
*/
|
||||
protected function createInstances(int $count = 1): Collection {
|
||||
// Remove random goals for accurate count tests.
|
||||
$this->user->goals()->delete();
|
||||
return $this->factory()->count($count)->for($this->user)->create();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Tests\Feature\JsonApi;
|
|||
|
||||
use App\Models\JournalEntry;
|
||||
use Database\Factories\JournalEntryFactory;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\Feature\JsonApi\Traits\BelongsToUser;
|
||||
|
||||
|
@ -27,6 +28,15 @@ class JournalEntryApiTest extends JsonApiTestCase
|
|||
return 'journal-entries';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function createInstances(int $count = 1): Collection {
|
||||
// Remove random entries for accurate count tests.
|
||||
$this->user->journalEntries()->delete();
|
||||
return $this->factory()->count($count)->for($this->user)->create();
|
||||
}
|
||||
|
||||
public function testCanGetRelatedFoods(): void {
|
||||
$record = $this->factory()->hasFoods(2)->create();
|
||||
$this->getRelatedData($record, 'foods');
|
||||
|
|
|
@ -13,7 +13,10 @@ trait LogsIn
|
|||
*/
|
||||
public function loginUser(): void
|
||||
{
|
||||
$this->user = User::factory()->create();
|
||||
$this->user = User::factory()
|
||||
->hasGoals(2)
|
||||
->hasJournalEntries(5)
|
||||
->create();
|
||||
$this->post('/login', [
|
||||
'username' => $this->user->username,
|
||||
'password' => 'password',
|
||||
|
|
Loading…
Reference in New Issue