This is just causing too much headache, especially since I made the rookie mistake of not checking the max length of some entries when inserting the gift. That leads to errors in the decryption process. In production, out of the thousands of gifts already entered, only 5 are not decryptable. I have no other choice than resetting these 5 rows. I'm really sorry about this. If you do end up having problems running the migration in your own instance, you need to remove the rows that are un-decryptable in the Gifts table as well.
95 lines
1.9 KiB
PHP
95 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Gift;
|
|
use Carbon\Carbon;
|
|
use Tests\TestCase;
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
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_in_dollars = '220.00';
|
|
|
|
$this->assertEquals(
|
|
'220.00',
|
|
$gift->getValue()
|
|
);
|
|
}
|
|
|
|
public function testGetCreatedAtReturnsCarbonObject()
|
|
{
|
|
$gift = factory(\App\Gift::class)->make();
|
|
|
|
$this->assertInstanceOf(Carbon::class, $gift->getCreatedAt());
|
|
}
|
|
}
|