2018-12-19 12:02:16 -06:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* BudgetLimitTransformerTest.php
|
2020-02-16 06:59:55 -06:00
|
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
2018-12-19 12:02:16 -06:00
|
|
|
*
|
2019-10-01 23:45:03 -05:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2018-12-19 12:02:16 -06:00
|
|
|
*
|
2019-10-01 23:45:03 -05:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2018-12-19 12:02:16 -06:00
|
|
|
*
|
2019-10-01 23:45:03 -05:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2018-12-19 12:02:16 -06:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-01 23:45:03 -05:00
|
|
|
* GNU Affero General Public License for more details.
|
2018-12-19 12:02:16 -06:00
|
|
|
*
|
2019-10-01 23:45:03 -05:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2018-12-19 12:02:16 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Tests\Unit\Transformers;
|
|
|
|
|
|
|
|
|
|
|
|
use FireflyIII\Models\BudgetLimit;
|
|
|
|
use FireflyIII\Transformers\BudgetLimitTransformer;
|
|
|
|
use Log;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Class BudgetLimitTransformerTest
|
2019-08-17 03:48:28 -05:00
|
|
|
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
|
|
|
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
2018-12-19 12:02:16 -06:00
|
|
|
*/
|
|
|
|
class BudgetLimitTransformerTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
2019-04-09 13:05:20 -05:00
|
|
|
Log::info(sprintf('Now in %s.', get_class($this)));
|
2018-12-19 12:02:16 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \FireflyIII\Transformers\BudgetLimitTransformer
|
|
|
|
*/
|
|
|
|
public function testBasic(): void
|
|
|
|
{
|
|
|
|
/** @var BudgetLimit $budgetLimit */
|
|
|
|
$budgetLimit = BudgetLimit::first();
|
|
|
|
|
|
|
|
/** @var BudgetLimitTransformer $transformer */
|
|
|
|
$transformer = app(BudgetLimitTransformer::class);
|
|
|
|
$result = $transformer->transform($budgetLimit);
|
|
|
|
|
|
|
|
// compare results:
|
|
|
|
$this->assertEquals($budgetLimit->id, $result['id']);
|
|
|
|
$this->assertEquals($budgetLimit->start_date->format('Y-m-d'), $result['start']);
|
|
|
|
$this->assertGreaterThanOrEqual(0, $result['amount']);
|
|
|
|
}
|
|
|
|
|
2018-12-31 00:48:23 -06:00
|
|
|
}
|