Files
monica/tests/Unit/KidTest.php
T
Yamamoto KadirandRégis Freyd 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

55 lines
1.1 KiB
PHP

<?php
namespace Tests\Unit;
use App\Kid;
use Carbon\Carbon;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class KidTest extends TestCase
{
use DatabaseTransactions;
public function testGetAgeWithNoBirthdateSet()
{
$kid = new Kid;
$kid->birthdate = null;
$this->assertNull($kid->age);
}
public function testGetAgeWithBirthdateSet()
{
$dateFiveYearsAgo = Carbon::now()->subYears(5);
$kid = new Kid;
$kid->birthdate = $dateFiveYearsAgo;
$this->assertEquals(
5,
$kid->getAge()
);
}
public function testGetFirstnameReturnsNullWhenUndefined()
{
$kid = new Kid;
$this->assertNull($kid->getFirstName());
}
public function testGetFirstnameReturnsNameWhenDefined()
{
$kid = new Kid;
$kid->first_name = 'Peter';
$this->assertEquals(
'Peter',
$kid->getFirstName()
);
}
}