You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

32 lines
957 B

<?php
namespace Tests\Unit\Models;
use Tests\TestCase;
use App\Entities\Users\User;
use App\Entities\Projects\Comment;
use Illuminate\Foundation\Testing\RefreshDatabase;
class CommentTest extends TestCase
{
use RefreshDatabase;
/** @test */
public function a_comment_has_belongs_to_creator_relation()
{
$comment = factory(Comment::class)->make();
$this->assertInstanceOf(User::class, $comment->creator);
$this->assertEquals($comment->creator_id, $comment->creator->id);
}
/** @test */
public function a_comment_has_time_display_attribute()
{
$comment = factory(Comment::class)->create(['created_at' => now()->subHour()]);
$this->assertEquals($comment->created_at->diffForHumans(), $comment->time_display);
$comment = factory(Comment::class)->create(['created_at' => now()->subDays(3)]);
$this->assertEquals($comment->created_at, $comment->time_display);
}
}