mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-09 11:18:10 +00:00
New tests.
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Category\ChartJsCategoryChartGenerator;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
|
||||
/**
|
||||
* Class ChartJsCategoryChartGeneratorTest
|
||||
@@ -6,6 +11,10 @@
|
||||
class ChartJsCategoryChartGeneratorTest extends TestCase
|
||||
{
|
||||
|
||||
|
||||
/** @var ChartJsCategoryChartGenerator */
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
@@ -14,6 +23,8 @@ class ChartJsCategoryChartGeneratorTest extends TestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->object = new ChartJsCategoryChartGenerator;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,7 +42,17 @@ class ChartJsCategoryChartGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testAll()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
// make a collection of stuff:
|
||||
$collection = new Collection;
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$collection->push([null, 100]);
|
||||
}
|
||||
|
||||
$data = $this->object->all($collection);
|
||||
|
||||
$this->assertCount(5, $data['labels']);
|
||||
$this->assertCount(5, $data['datasets'][0]['data']);
|
||||
$this->assertEquals(100, $data['datasets'][0]['data'][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,15 +60,18 @@ class ChartJsCategoryChartGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testFrontpage()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
// make a collection of stuff:
|
||||
$collection = new Collection;
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$collection->push(['name' => 'Something', 'sum' => 100]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Generator\Chart\Category\ChartJsCategoryChartGenerator::month
|
||||
*/
|
||||
public function testMonth()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
$data = $this->object->frontpage($collection);
|
||||
|
||||
$this->assertCount(5, $data['labels']);
|
||||
$this->assertCount(5, $data['datasets'][0]['data']);
|
||||
$this->assertEquals('Something', $data['labels'][0]);
|
||||
$this->assertEquals(100, $data['datasets'][0]['data'][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,6 +79,27 @@ class ChartJsCategoryChartGeneratorTest extends TestCase
|
||||
*/
|
||||
public function testYear()
|
||||
{
|
||||
$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 a collection of stuff:
|
||||
$collection = new Collection;
|
||||
$categories = new Collection;
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$categories->push(FactoryMuffin::create('FireflyIII\Models\Category'));
|
||||
$collection->push([new Carbon, 100, 100, 100]);
|
||||
}
|
||||
|
||||
$data = $this->object->year($categories, $collection);
|
||||
|
||||
$this->assertCount(5, $data['labels']);
|
||||
$this->assertEquals($categories->first()->name, $data['labels'][0]);
|
||||
$this->assertCount(3, $data['datasets'][0]['data']);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user