firefly-iii/tests/repositories/ReminderRepositoryTest.php

153 lines
4.6 KiB
PHP
Raw Normal View History

2015-05-05 15:46:28 -05:00
<?php
2015-05-10 00:07:17 -05:00
use Carbon\Carbon;
2015-05-05 15:46:28 -05:00
use FireflyIII\Repositories\Reminder\ReminderRepository;
2015-05-10 00:07:17 -05:00
use League\FactoryMuffin\Facade as FactoryMuffin;
2015-05-05 15:46:28 -05:00
/**
* 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();
2015-05-10 00:07:17 -05:00
$helper = $this->mock('FireflyIII\Helpers\Reminders\ReminderHelperInterface');
$helper->shouldReceive('getReminderText')->andReturn('Hello!');
2015-05-07 13:56:27 -05:00
$this->object = new ReminderRepository;
2015-05-05 15:46:28 -05:00
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
public function tearDown()
{
2015-05-06 11:09:45 -05:00
parent::tearDown();
2015-05-05 15:46:28 -05:00
}
/**
* @covers FireflyIII\Repositories\Reminder\ReminderRepository::getActiveReminders
*/
public function testGetActiveReminders()
{
2015-05-10 00:07:17 -05:00
$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);
2015-05-05 15:46:28 -05:00
}
/**
* @covers FireflyIII\Repositories\Reminder\ReminderRepository::getDismissedReminders
*/
public function testGetDismissedReminders()
{
2015-05-10 00:07:17 -05:00
$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);
2015-05-05 15:46:28 -05:00
}
/**
* @covers FireflyIII\Repositories\Reminder\ReminderRepository::getExpiredReminders
*/
public function testGetExpiredReminders()
{
2015-05-10 00:07:17 -05:00
$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);
2015-05-05 15:46:28 -05:00
}
/**
* @covers FireflyIII\Repositories\Reminder\ReminderRepository::getInactiveReminders
*/
public function testGetInactiveReminders()
{
2015-05-10 00:07:17 -05:00
$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);
2015-05-05 15:46:28 -05:00
}
}