Files
monica/tests/Unit/TaskTest.php
T
Yamamoto Kadir 496d23e4a7 Separate PeopleController into smaller chunks (#253)
* Edit relation docblocks of Contact model
* Move activities to its own controller
* Move reminders to its own controller
* Move tasks to its own controller
* Refactor Gift in preparation for the move
* Move gifts into its own controller
* Fix failing tests
* Move debt to its own controllelr
* Fix tests failing on PHP7
* Move significant others to its own controller
* Move kids to its own controller
* Move notes to its own controller
* Some more adjustments & solving #277
And more query optimizations
2017-06-15 15:03:22 -04:00

89 lines
1.8 KiB
PHP

<?php
namespace Tests\Unit;
use App\Task;
use App\Contact;
use Carbon\Carbon;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class TaskTest extends TestCase
{
use DatabaseTransactions;
public function testGetTitleReturnsNullIfUndefined()
{
$task = new Task;
$this->assertNull($task->getTitle());
}
public function testGetTitleReturnsTitle()
{
$task = new Task;
$task->title = 'This is a test';
$this->assertEquals(
'This is a test',
$task->getTitle()
);
}
public function testGetDescriptionReturnsNullIfUndefined()
{
$task = new Task;
$this->assertNull($task->getDescription());
}
public function testGetDescriptionReturnsDescription()
{
$task = new Task;
$task->description = 'This is a test';
$this->assertEquals(
'This is a test',
$task->getDescription()
);
}
public function testGetCreatedAtReturnsCarbonObject()
{
$task = factory(\App\Task::class)->make();
$this->assertInstanceOf(Carbon::class, $task->getCreatedAt());
}
public function testToggle()
{
$contact = factory(\App\Contact::class)->create();
$task = factory(\App\Task::class)->make([
'contact_id' => $contact->id,
'status' => 'inprogress'
]);
$this->assertEquals(
'inprogress',
$task->status
);
$task->toggle();
$this->assertEquals(
'completed',
$task->status
);
$task->toggle();
$this->assertEquals(
'inprogress',
$task->status
);
}
}