mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-05 04:21:40 +00:00
New tests.
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Report\ChartJsReportChartGenerator;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
|
||||
/**
|
||||
* Class ChartJsReportChartGeneratorTest
|
||||
@@ -6,6 +11,9 @@
|
||||
class ChartJsReportChartGeneratorTest extends TestCase
|
||||
{
|
||||
|
||||
/** @var ChartJsReportChartGenerator */
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
@@ -14,6 +22,8 @@ class ChartJsReportChartGeneratorTest extends TestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->object = new ChartJsReportChartGenerator;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,7 +41,25 @@ class ChartJsReportChartGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testYearInOut()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
$preference = FactoryMuffin::create('FireflyIII\Models\Preference');
|
||||
$preference->data = 'en';
|
||||
$preference->save();
|
||||
|
||||
// mock language preference:
|
||||
Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference);
|
||||
|
||||
// make set:
|
||||
$collection = new Collection;
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$collection->push([new Carbon, 200, 100]);
|
||||
}
|
||||
|
||||
$data = $this->object->yearInOut($collection);
|
||||
|
||||
$this->assertEquals(200, $data['datasets'][0]['data'][0]);
|
||||
$this->assertEquals(100, $data['datasets'][1]['data'][0]);
|
||||
$this->assertCount(5, $data['labels']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,6 +67,21 @@ class ChartJsReportChartGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testYearInOutSummarized()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
$preference = FactoryMuffin::create('FireflyIII\Models\Preference');
|
||||
$preference->data = 'en';
|
||||
$preference->save();
|
||||
|
||||
// mock language preference:
|
||||
Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference);
|
||||
|
||||
// make set:
|
||||
$income = 2400;
|
||||
$expense = 1200;
|
||||
|
||||
$data = $this->object->yearInOutSummarized($income, $expense, 12);
|
||||
|
||||
$this->assertEquals(200, $data['datasets'][0]['data'][1]);
|
||||
$this->assertEquals(100, $data['datasets'][1]['data'][1]);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user