mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-19 17:51:19 +00:00
New tests.
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Budget\ChartJsBudgetChartGenerator;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
/**
|
||||
* Class ChartJsBudgetChartGeneratorTest
|
||||
@@ -6,6 +10,10 @@
|
||||
class ChartJsBudgetChartGeneratorTest extends TestCase
|
||||
{
|
||||
|
||||
|
||||
/** @var ChartJsBudgetChartGenerator */
|
||||
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 ChartJsBudgetChartGeneratorTest extends TestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->object = new ChartJsBudgetChartGenerator();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,15 +41,17 @@ class ChartJsBudgetChartGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testBudget()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
// make a collection with some amounts in them.
|
||||
$collection = new Collection;
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$collection->push([null, 100]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Generator\Chart\Budget\ChartJsBudgetChartGenerator::budgetLimit
|
||||
*/
|
||||
public function testBudgetLimit()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
$data = $this->object->budget($collection);
|
||||
|
||||
$this->assertCount(5, $data['labels']);
|
||||
$this->assertCount(5, $data['datasets'][0]['data']);
|
||||
$this->assertEquals(100, $data['datasets'][0]['data'][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +59,20 @@ class ChartJsBudgetChartGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testFrontpage()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
// make a collection with some amounts in them.
|
||||
$collection = new Collection;
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$collection->push(['Some label', 100, 200, 300]);
|
||||
}
|
||||
|
||||
$data = $this->object->frontpage($collection);
|
||||
|
||||
$this->assertCount(5, $data['labels']);
|
||||
$this->assertCount(5, $data['datasets'][0]['data']);
|
||||
$this->assertEquals(100, $data['datasets'][0]['data'][0]);
|
||||
$this->assertEquals(200, $data['datasets'][1]['data'][0]);
|
||||
$this->assertEquals(300, $data['datasets'][2]['data'][0]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,6 +80,27 @@ class ChartJsBudgetChartGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testYear()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
$preference = FactoryMuffin::create('FireflyIII\Models\Preference');
|
||||
$preference->data = 'en';
|
||||
$preference->save();
|
||||
|
||||
$budgets = new Collection;
|
||||
$entries = new Collection;
|
||||
|
||||
// make some budgets:
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$budgets->push(FactoryMuffin::create('FireflyIII\Models\Budget'));
|
||||
$entries->push([new Carbon, 100, 100, 100]);
|
||||
}
|
||||
|
||||
// mock language preference:
|
||||
Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference);
|
||||
|
||||
$data = $this->object->year($budgets, $entries);
|
||||
|
||||
$this->assertCount(5, $data['labels']);
|
||||
$this->assertCount(5, $data['datasets']);
|
||||
$this->assertCount(3, $data['datasets'][0]['data']);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user