2015-06-28 03:38:51 -05:00
|
|
|
<?php
|
2015-06-28 14:33:39 -05:00
|
|
|
use Carbon\Carbon;
|
|
|
|
use FireflyIII\Generator\Chart\Budget\GoogleBudgetChartGenerator;
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
2015-06-28 03:38:51 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class GoogleBudgetChartGeneratorTest
|
|
|
|
*/
|
|
|
|
class GoogleBudgetChartGeneratorTest extends TestCase
|
|
|
|
{
|
|
|
|
|
2015-06-28 14:33:39 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @var GoogleBudgetChartGenerator */
|
|
|
|
protected $object;
|
|
|
|
|
2015-06-28 03:38:51 -05:00
|
|
|
/**
|
|
|
|
* 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-06-28 14:33:39 -05:00
|
|
|
$this->object = new GoogleBudgetChartGenerator();
|
|
|
|
|
2015-06-28 03:38:51 -05:00
|
|
|
}
|
|
|
|
|
2015-06-28 14:33:39 -05:00
|
|
|
|
2015-06-28 03:38:51 -05:00
|
|
|
/**
|
|
|
|
* This method is called before the first test of this test class is run.
|
|
|
|
*
|
|
|
|
* @since Method available since Release 3.4.0
|
|
|
|
*/
|
|
|
|
public static function setUpBeforeClass()
|
|
|
|
{
|
|
|
|
parent::setUpBeforeClass();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers FireflyIII\Generator\Chart\Budget\GoogleBudgetChartGenerator::budget
|
|
|
|
*/
|
|
|
|
public function testBudget()
|
|
|
|
{
|
2015-06-28 14:33:39 -05:00
|
|
|
// make a collection with some amounts in them.
|
|
|
|
$collection = new Collection;
|
|
|
|
for ($i = 0; $i < 5; $i++) {
|
|
|
|
$collection->push([new Carbon, 100]);
|
|
|
|
}
|
2015-06-28 03:38:51 -05:00
|
|
|
|
2015-06-28 14:33:39 -05:00
|
|
|
$data = $this->object->budget($collection);
|
|
|
|
|
|
|
|
$this->assertCount(5, $data['rows']);
|
|
|
|
$this->assertCount(2, $data['cols']);
|
|
|
|
$this->assertEquals(100, $data['rows'][0]['c'][1]['v']);
|
2015-06-28 03:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers FireflyIII\Generator\Chart\Budget\GoogleBudgetChartGenerator::frontpage
|
|
|
|
*/
|
|
|
|
public function testFrontpage()
|
|
|
|
{
|
2015-06-28 14:33:39 -05:00
|
|
|
// 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['rows']);
|
|
|
|
$this->assertEquals(100, $data['rows'][0]['c'][1]['v']);
|
|
|
|
$this->assertEquals(200, $data['rows'][0]['c'][2]['v']);
|
|
|
|
$this->assertEquals(300, $data['rows'][0]['c'][3]['v']);
|
2015-06-28 03:38:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers FireflyIII\Generator\Chart\Budget\GoogleBudgetChartGenerator::year
|
|
|
|
*/
|
|
|
|
public function testYear()
|
|
|
|
{
|
2015-06-28 14:33:39 -05:00
|
|
|
$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]);
|
|
|
|
}
|
|
|
|
|
|
|
|
$data = $this->object->year($budgets, $entries);
|
|
|
|
|
|
|
|
$this->assertCount(5, $data['rows']);
|
|
|
|
$this->assertCount(6, $data['cols']);
|
2015-06-28 03:38:51 -05:00
|
|
|
}
|
|
|
|
}
|