New tests.

This commit is contained in:
James Cole
2015-06-28 18:00:11 +02:00
parent a650fa51f7
commit 70eed5cb5e
7 changed files with 192 additions and 26 deletions

View File

@@ -1,10 +1,16 @@
<?php
use Carbon\Carbon;
use FireflyIII\Generator\Chart\PiggyBank\ChartJsPiggyBankChartGenerator;
use Illuminate\Support\Collection;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* Class ChartJsPiggyBankChartGeneratorTest
*/
class ChartJsPiggyBankChartGeneratorTest extends TestCase
{
/** @var ChartJsPiggyBankChartGenerator */
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
@@ -14,6 +20,8 @@ class ChartJsPiggyBankChartGeneratorTest extends TestCase
{
parent::setUp();
$this->object = new ChartJsPiggyBankChartGenerator;
}
/**
@@ -31,6 +39,28 @@ class ChartJsPiggyBankChartGeneratorTest extends TestCase
*/
public function testHistory()
{
$this->markTestIncomplete();
$preference = FactoryMuffin::create('FireflyIII\Models\Preference');
$preference->data = 'en';
$preference->save();
// mock language preference:
Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference);
// create a set
$set = new Collection;
for ($i = 0; $i < 5; $i++) {
$obj = new stdClass;
$obj->date = new Carbon;
$obj->sum = 100;
$set->push($obj);
}
$data = $this->object->history($set);
$this->assertCount(5, $data['labels']);
$this->assertCount(5, $data['datasets'][0]['data']);
$this->assertEquals(100, $data['datasets'][0]['data'][0]);
$this->assertEquals(500, $data['datasets'][0]['data'][4]);
}
}