mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-05 21:53:08 -06:00
153 lines
4.6 KiB
PHP
153 lines
4.6 KiB
PHP
<?php
|
|
use Carbon\Carbon;
|
|
use FireflyIII\Repositories\Reminder\ReminderRepository;
|
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
|
|
|
/**
|
|
* Generated by PHPUnit_SkeletonGenerator on 2015-05-05 at 19:19:32.
|
|
*/
|
|
class ReminderRepositoryTest extends TestCase
|
|
{
|
|
/**
|
|
* @var ReminderRepository
|
|
*/
|
|
protected $object;
|
|
|
|
/**
|
|
* Sets up the fixture, for example, opens a network connection.
|
|
* This method is called before a test is executed.
|
|
*/
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
$helper = $this->mock('FireflyIII\Helpers\Reminders\ReminderHelperInterface');
|
|
$helper->shouldReceive('getReminderText')->andReturn('Hello!');
|
|
$this->object = new ReminderRepository;
|
|
|
|
}
|
|
|
|
/**
|
|
* Tears down the fixture, for example, closes a network connection.
|
|
* This method is called after a test is executed.
|
|
*/
|
|
public function tearDown()
|
|
{
|
|
parent::tearDown();
|
|
}
|
|
|
|
/**
|
|
* @covers FireflyIII\Repositories\Reminder\ReminderRepository::getActiveReminders
|
|
*/
|
|
public function testGetActiveReminders()
|
|
{
|
|
$yesterday = Carbon::now()->subDay();
|
|
$tomorrow = Carbon::now()->addDay();
|
|
|
|
$user = FactoryMuffin::create('FireflyIII\User');
|
|
for ($i = 0; $i < 3; $i++) {
|
|
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
|
$reminder->active = 1;
|
|
$reminder->notnow = 0;
|
|
$reminder->startdate = $yesterday;
|
|
$reminder->enddate = $tomorrow;
|
|
$reminder->user_id = $user->id;
|
|
$reminder->save();
|
|
|
|
}
|
|
|
|
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
|
$reminder->active = 0;
|
|
$reminder->notnow = 0;
|
|
$reminder->startdate = $yesterday;
|
|
$reminder->enddate = $tomorrow;
|
|
$reminder->user_id = $user->id;
|
|
$reminder->save();
|
|
$this->be($user);
|
|
|
|
$set = $this->object->getActiveReminders();
|
|
$this->assertCount(3, $set);
|
|
}
|
|
|
|
/**
|
|
* @covers FireflyIII\Repositories\Reminder\ReminderRepository::getDismissedReminders
|
|
*/
|
|
public function testGetDismissedReminders()
|
|
{
|
|
|
|
$user = FactoryMuffin::create('FireflyIII\User');
|
|
for ($i = 0; $i < 3; $i++) {
|
|
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
|
$reminder->notnow = 1;
|
|
$reminder->user_id = $user->id;
|
|
$reminder->save();
|
|
|
|
}
|
|
|
|
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
|
$reminder->notnow = 0;
|
|
$reminder->user_id = $user->id;
|
|
$reminder->save();
|
|
$this->be($user);
|
|
|
|
$set = $this->object->getDismissedReminders();
|
|
$this->assertCount(3, $set);
|
|
}
|
|
|
|
/**
|
|
* @covers FireflyIII\Repositories\Reminder\ReminderRepository::getExpiredReminders
|
|
*/
|
|
public function testGetExpiredReminders()
|
|
{
|
|
$yesterday = Carbon::now()->subDay();
|
|
$tomorrow = Carbon::now()->addDay();
|
|
|
|
$user = FactoryMuffin::create('FireflyIII\User');
|
|
for ($i = 0; $i < 3; $i++) {
|
|
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
|
$reminder->active = 1;
|
|
$reminder->notnow = 0;
|
|
$reminder->startdate = $tomorrow;
|
|
$reminder->enddate = $yesterday;
|
|
$reminder->user_id = $user->id;
|
|
$reminder->save();
|
|
|
|
}
|
|
|
|
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
|
$reminder->active = 0;
|
|
$reminder->notnow = 0;
|
|
$reminder->startdate = $tomorrow;
|
|
$reminder->enddate = $yesterday;
|
|
$reminder->user_id = $user->id;
|
|
$reminder->save();
|
|
$this->be($user);
|
|
|
|
$set = $this->object->getExpiredReminders();
|
|
$this->assertCount(3, $set);
|
|
}
|
|
|
|
/**
|
|
* @covers FireflyIII\Repositories\Reminder\ReminderRepository::getInactiveReminders
|
|
*/
|
|
public function testGetInactiveReminders()
|
|
{
|
|
$user = FactoryMuffin::create('FireflyIII\User');
|
|
for ($i = 0; $i < 3; $i++) {
|
|
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
|
$reminder->active = 0;
|
|
$reminder->user_id = $user->id;
|
|
$reminder->save();
|
|
|
|
}
|
|
|
|
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
|
$reminder->active = 1;
|
|
$reminder->user_id = $user->id;
|
|
$reminder->save();
|
|
$this->be($user);
|
|
|
|
$set = $this->object->getInactiveReminders();
|
|
$this->assertCount(3, $set);
|
|
}
|
|
}
|