Update some tests.

This commit is contained in:
James Cole
2018-12-19 19:23:52 +01:00
parent 446ff81335
commit c1ae0ab57d
4 changed files with 146 additions and 5 deletions

View File

@@ -74,10 +74,10 @@ class ImportJobTransformer extends AbstractTransformer
'provider' => $importJob->provider,
'status' => $importJob->status,
'stage' => $importJob->stage,
'configuration' => $importJob->configuration,
'extended_status' => $importJob->extended_status,
'transactions' => $importJob->transactions,
'errors' => $importJob->errors,
'configuration' => json_encode($importJob->configuration),
'extended_status' => json_encode($importJob->extended_status),
'transactions' => json_encode($importJob->transactions),
'errors' => json_encode($importJob->errors),
'links' => [
[

View File

@@ -63,7 +63,7 @@ class LinkTypeTransformer extends AbstractTransformer
'name' => $linkType->name,
'inward' => $linkType->inward,
'outward' => $linkType->outward,
'editable' => 1 === (int)$linkType->editable,
'editable' => $linkType->editable,
'links' => [
[
'rel' => 'self',

View File

@@ -0,0 +1,73 @@
<?php
/**
* ImportJobTransformerTest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace Tests\Unit\Transformers;
use FireflyIII\Models\ImportJob;
use FireflyIII\Transformers\ImportJobTransformer;
use Log;
use Symfony\Component\HttpFoundation\ParameterBag;
use Tests\TestCase;
/**
*
* Class ImportJobTransformerTest
*/
class ImportJobTransformerTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
* Basic coverage
*
* @covers \FireflyIII\Transformers\ImportJobTransformer
*/
public function testBasic(): void
{
$job = ImportJob::first();
$job->tag_id = 1;
$parameters = new ParameterBag;
$transformer = app(ImportJobTransformer::class);
$transformer->setParameters($parameters);
$result = $transformer->transform($job);
$this->assertEquals($job->key, $result['key']);
$this->assertEquals($job->tag_id, $result['tag_id']);
$this->assertEquals(json_encode($job->configuration), $result['configuration']);
$this->assertEquals(json_encode($job->extended_status), $result['extended_status']);
$this->assertEquals(json_encode($job->transactions), $result['transactions']);
$this->assertEquals(json_encode($job->errors), $result['errors']);
}
}

View File

@@ -0,0 +1,68 @@
<?php
/**
* LinkTypeTransformerTest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace Tests\Unit\Transformers;
use FireflyIII\Models\ImportJob;
use FireflyIII\Models\LinkType;
use FireflyIII\Transformers\ImportJobTransformer;
use FireflyIII\Transformers\LinkTypeTransformer;
use Log;
use Symfony\Component\HttpFoundation\ParameterBag;
use Tests\TestCase;
/**
*
* Class LinkTypeTransformerTest
*/
class LinkTypeTransformerTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
* Basic coverage
*
* @covers \FireflyIII\Transformers\LinkTypeTransformer
*/
public function testBasic(): void
{
$linkType= LinkType::first();
$parameters = new ParameterBag;
$transformer = app(LinkTypeTransformer::class);
$transformer->setParameters($parameters);
$result = $transformer->transform($linkType);
$this->assertEquals($linkType->inward, $result['inward']);
}
}