Browse Source

Add pic relation on issue model

pull/37/head
Nafies Luthfi 7 years ago
parent
commit
96d38afe75
  1. 5
      app/Entities/Projects/Issue.php
  2. 10
      tests/Unit/Models/IssueTest.php

5
app/Entities/Projects/Issue.php

@ -15,6 +15,11 @@ class Issue extends Model
return $this->belongsTo(Project::class);
}
public function pic()
{
return $this->belongsTo(User::class);
}
public function creator()
{
return $this->belongsTo(User::class);

10
tests/Unit/Models/IssueTest.php

@ -22,6 +22,16 @@ class IssueTest extends TestCase
}
/** @test */
public function an_issue_has_belongs_to_pic_relation()
{
$pic = $this->createUser('worker');
$issue = factory(Issue::class)->make(['pic_id' => $pic->id]);
$this->assertInstanceOf(User::class, $issue->pic);
$this->assertEquals($issue->pic_id, $issue->pic->id);
}
/** @test */
public function an_issue_has_belongs_to_creator_relation()
{
$issue = factory(Issue::class)->make();

Loading…
Cancel
Save