Files
monica/tests/Unit/GiftTest.php
T
Régis FreydandGitHub 7e1cd96bf5 Add API (#606)
This is the first part of the API. It supports most of contacts, as well as the
journal. This PR also brings Monica to Laravel 5.5, as the API required it with
the new concept of resources. It needs to run `php artisan migrate` as well as
`php artisan passport:keys` to generate the access tokens needed for the API.
2017-10-30 08:38:15 -04:00

93 lines
1.8 KiB
PHP

<?php
namespace Tests\Unit;
use App\Gift;
use Carbon\Carbon;
use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class GiftTest extends TestCase
{
use DatabaseTransactions;
public function testGetNameReturnsNullIfUndefined()
{
$gift = new Gift;
$this->assertNull($gift->getName());
}
public function testGetNameReturnsName()
{
$gift = new Gift;
$gift->name = 'This is a test';
$this->assertEquals(
'This is a test',
$gift->getName()
);
}
public function testGetUrlReturnsNullIfUndefined()
{
$gift = new Gift;
$this->assertNull($gift->getUrl());
}
public function testGetURLReturnsURL()
{
$gift = new Gift;
$gift->url = 'https://test.com';
$this->assertEquals(
'https://test.com',
$gift->getUrl()
);
}
public function testGetCommentReturnsNullIfUndefined()
{
$gift = new Gift;
$this->assertNull($gift->getComment());
}
public function testGetCommentReturnsComment()
{
$gift = new Gift;
$gift->comment = 'this is a test';
$this->assertEquals(
'this is a test',
$gift->getComment()
);
}
public function testGetValueReturnsNullIfUndefined()
{
$gift = new Gift;
$this->assertNull($gift->getValue());
}
public function testGetValueReturnsValue()
{
$gift = new Gift;
$gift->value = '220.00';
$this->assertEquals(
'220.00',
$gift->getValue()
);
}
public function testGetCreatedAtReturnsCarbonObject()
{
$gift = factory(\App\Gift::class)->make();
$this->assertInstanceOf(Carbon::class, $gift->getCreatedAt());
}
}