mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 00:04:24 +00:00
Implemented two google chart tests.
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Generator\Chart\Account\GoogleAccountChartGenerator;
|
||||||
|
use FireflyIII\Models\Account;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class GoogleAccountChartGeneratorTest
|
* Class GoogleAccountChartGeneratorTest
|
||||||
@@ -6,6 +11,9 @@
|
|||||||
class GoogleAccountChartGeneratorTest extends TestCase
|
class GoogleAccountChartGeneratorTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** @var GoogleAccountChartGenerator */
|
||||||
|
protected $object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up the fixture, for example, opens a network connection.
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
* This method is called before a test is executed.
|
* This method is called before a test is executed.
|
||||||
@@ -14,6 +22,8 @@ class GoogleAccountChartGeneratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->object = new GoogleAccountChartGenerator;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,7 +41,27 @@ class GoogleAccountChartGeneratorTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAll()
|
public function testAll()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
// be somebody
|
||||||
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
// create some accounts:
|
||||||
|
$accounts = new Collection;
|
||||||
|
for ($i = 0; $i < 5; $i++) {
|
||||||
|
$accounts->push(FactoryMuffin::create('FireflyIII\Models\Account'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// data for call:
|
||||||
|
$start = Carbon::createFromDate(2015, 1, 1);
|
||||||
|
$end = Carbon::createFromDate(2015, 1, 15);
|
||||||
|
|
||||||
|
// mock Steam::balance
|
||||||
|
Steam::shouldReceive('balance')->withAnyArgs()->andReturn(0);
|
||||||
|
|
||||||
|
$data = $this->object->all($accounts, $start, $end);
|
||||||
|
$this->assertCount(11, $data['cols']); // accounts * 2 + date.
|
||||||
|
// fifteen days,
|
||||||
|
$this->assertCount(16, $data['rows']); // 15 + 1?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,7 +69,27 @@ class GoogleAccountChartGeneratorTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFrontpage()
|
public function testFrontpage()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
// be somebody
|
||||||
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
// create some accounts:
|
||||||
|
$accounts = new Collection;
|
||||||
|
for ($i = 0; $i < 5; $i++) {
|
||||||
|
$accounts->push(FactoryMuffin::create('FireflyIII\Models\Account'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// data for call:
|
||||||
|
$start = Carbon::createFromDate(2015, 1, 1);
|
||||||
|
$end = Carbon::createFromDate(2015, 1, 15);
|
||||||
|
|
||||||
|
// mock Steam::balance
|
||||||
|
Steam::shouldReceive('balance')->withAnyArgs()->andReturn(0);
|
||||||
|
|
||||||
|
$data = $this->object->frontpage($accounts, $start, $end);
|
||||||
|
$this->assertCount(11, $data['cols']); // accounts * 2 + date.
|
||||||
|
// fifteen days,
|
||||||
|
$this->assertCount(16, $data['rows']); // 15 + 1?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,7 +97,24 @@ class GoogleAccountChartGeneratorTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testSingle()
|
public function testSingle()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
// be somebody
|
||||||
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
/** @var Account $account */
|
||||||
|
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||||
|
|
||||||
|
// data for call:
|
||||||
|
$start = Carbon::createFromDate(2015, 1, 1);
|
||||||
|
$end = Carbon::createFromDate(2015, 1, 15);
|
||||||
|
|
||||||
|
// mock Steam::balance
|
||||||
|
Steam::shouldReceive('balance')->withAnyArgs()->andReturn(0);
|
||||||
|
|
||||||
|
$data = $this->object->single($account, $start, $end);
|
||||||
|
$this->assertCount(3, $data['cols']); // account, date, certainty
|
||||||
|
// fifteen days,
|
||||||
|
$this->assertCount(15, $data['rows']); // 15 days
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -1,11 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Generator\Chart\Bill\GoogleBillChartGenerator;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class GoogleBillChartGeneratorTest
|
* Class GoogleBillChartGeneratorTest
|
||||||
*/
|
*/
|
||||||
class GoogleBillChartGeneratorTest extends TestCase
|
class GoogleBillChartGeneratorTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** @var GoogleBillChartGenerator */
|
||||||
|
protected $object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up the fixture, for example, opens a network connection.
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
* This method is called before a test is executed.
|
* This method is called before a test is executed.
|
||||||
@@ -14,6 +23,8 @@ class GoogleBillChartGeneratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->object = new GoogleBillChartGenerator;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,7 +42,30 @@ class GoogleBillChartGeneratorTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFrontpage()
|
public function testFrontpage()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
// to test frontpage, we generate the exact fake entries
|
||||||
|
// needed:
|
||||||
|
$paid = new Collection;
|
||||||
|
for ($i = 0; $i < 5; $i++) {
|
||||||
|
$obj = new stdClass();
|
||||||
|
$obj->description = 'Something';
|
||||||
|
$obj->amount = 100;
|
||||||
|
$paid->push($obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
$unpaid = new Collection;
|
||||||
|
$sum = 0;
|
||||||
|
for ($i = 0; $i < 5; $i++) {
|
||||||
|
$bill = FactoryMuffin::create('FireflyIII\Models\Bill');
|
||||||
|
$date = new Carbon;
|
||||||
|
$sum += (($bill->amount_max + $bill->amount_min) / 2);
|
||||||
|
$unpaid->push([$bill, $date]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$data = $this->object->frontpage($paid, $unpaid);
|
||||||
|
|
||||||
|
$this->assertCount(2, $data['cols']);
|
||||||
|
$this->assertCount(2, $data['rows']); // two rows, two columns.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,6 +73,18 @@ class GoogleBillChartGeneratorTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testSingle()
|
public function testSingle()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$bill = FactoryMuffin::create('FireflyIII\Models\Bill');
|
||||||
|
$entries = new Collection;
|
||||||
|
for ($i = 0; $i < 5; $i++) {
|
||||||
|
$obj = new stdClass;
|
||||||
|
$obj->amount = 100;
|
||||||
|
$obj->date = new Carbon;
|
||||||
|
$entries->push($obj);
|
||||||
|
}
|
||||||
|
$data = $this->object->single($bill, $entries);
|
||||||
|
|
||||||
|
$this->assertCount(5, $data['rows']);
|
||||||
|
$this->assertCount(4, $data['cols']);
|
||||||
|
$this->assertEquals(100, $data['rows'][0]['c'][3]['v']);
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user