Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Commit

Permalink
test: test cases for modal attributes (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
farhaninfyom authored and vishalinfyom committed Sep 26, 2019
1 parent 0d6d91f commit d140f39
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/Models/TimeEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TimeEntry ofCurrentUser()
*
* @property int $entry_type
* @property-read string $entry_type_string
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TimeEntry whereEntryType($value)
*/
Expand Down
33 changes: 33 additions & 0 deletions tests/Models/TaskAttachmentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Tests\Models;

use App\Models\TaskAttachment;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;

class TaskAttachmentTest extends TestCase
{
use DatabaseTransactions;

/** @test */
public function test_return_attachment_path()
{
$taskAttachment = factory(TaskAttachment::class)->create();

$taskAttachment = TaskAttachment::first();

$this->assertNotEmpty($taskAttachment->file_path);
$this->assertStringContainsString('attachments', $taskAttachment->file_path);
}

/** @test */
public function test_return_attachment_url()
{
$taskAttachment = factory(TaskAttachment::class)->create();

$taskAttachment = TaskAttachment::first();

$this->assertNotEmpty($taskAttachment->file_url);
}
}
22 changes: 22 additions & 0 deletions tests/Models/TaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,26 @@ public function get_task_of_specific_project()
$this->assertEquals($task2->id, $firstTask->id);
$this->assertEquals($project2->id, $firstTask->project_id);
}

/** @test */
public function test_return_due_date()
{
$task = factory(Task::class)->create();

$task = Task::first();

$this->assertNotEmpty($task->due_date);
}

/** @test */
public function test_return_task_prefix_number()
{
$task = factory(Task::class)->create();

$task = Task::first();

$this->assertNotEmpty($task->prefix_task_number);
$taskPrefixNumber = '#'.$task->project->prefix.'-'.$task->task_number;
$this->assertEquals($taskPrefixNumber, $task->prefix_task_number);
}
}
22 changes: 22 additions & 0 deletions tests/Models/TimeEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,26 @@ public function get_time_entry_of_logged_in_user()
$this->assertEquals($timeEntry2->id, $firstTimeEntry->id);
$this->assertEquals($user2->id, $firstTimeEntry->user_id);
}

/** @test */
public function test_return_time_entry_type_in_string()
{
$timeEntry = factory(TimeEntry::class)->create();

$timeEntry = TimeEntry::first();

$this->assertNotEmpty($timeEntry->entry_type_string);
$this->assertEquals('Stopwatch', $timeEntry->entry_type_string);
}

/** @test */
public function test_return_time_entry_type_via_form()
{
$timeEntry = factory(TimeEntry::class)->create(['entry_type' => TimeEntry::VIA_FORM]);

$timeEntry = TimeEntry::first();

$this->assertNotEmpty($timeEntry->entry_type_string);
$this->assertEquals('Via Form', $timeEntry->entry_type_string);
}
}
32 changes: 32 additions & 0 deletions tests/Models/UserTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Tests\Models;

use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;

class UserTest extends TestCase
{
use DatabaseTransactions;

/** @test */
public function test_return_user_image_avatar()
{
$user = factory(User::class)->create();

$user = User::first();

$this->assertNotEmpty($user->img_avatar);
}

/** @test */
public function test_return_user_image_path()
{
$user = factory(User::class)->create();

$user = User::first();

$this->assertNotEmpty($user->image_path);
}
}

0 comments on commit d140f39

Please sign in to comment.