mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Cover all transformers.
This commit is contained in:
@@ -98,6 +98,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||||||
* @property string transaction_journal_budget_encrypted
|
* @property string transaction_journal_budget_encrypted
|
||||||
* @property string type
|
* @property string type
|
||||||
* @property string name
|
* @property string name
|
||||||
|
* @property Carbon created_at
|
||||||
|
* @property Carbon updated_at
|
||||||
|
* @property string foreign_currency_code
|
||||||
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
||||||
*/
|
*/
|
||||||
class Transaction extends Model
|
class Transaction extends Model
|
||||||
|
|||||||
@@ -31,9 +31,11 @@ use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
|||||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Models\Note;
|
||||||
use FireflyIII\Models\PiggyBankEvent;
|
use FireflyIII\Models\PiggyBankEvent;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Models\TransactionJournalLink;
|
||||||
use FireflyIII\Models\TransactionJournalMeta;
|
use FireflyIII\Models\TransactionJournalMeta;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
|
use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
|
||||||
@@ -455,6 +457,23 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
return $amount;
|
return $amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournalLink $link
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getLinkNoteText(TransactionJournalLink $link): string
|
||||||
|
{
|
||||||
|
$notes = null;
|
||||||
|
/** @var Note $note */
|
||||||
|
$note = $link->notes()->first();
|
||||||
|
if (null !== $note) {
|
||||||
|
return $note->text ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return Carbon value of a meta field (or NULL).
|
* Return Carbon value of a meta field (or NULL).
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ use FireflyIII\Exceptions\FireflyException;
|
|||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Models\TransactionJournalLink;
|
||||||
use FireflyIII\Models\TransactionJournalMeta;
|
use FireflyIII\Models\TransactionJournalMeta;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
@@ -38,6 +39,14 @@ use Illuminate\Support\MessageBag;
|
|||||||
*/
|
*/
|
||||||
interface JournalRepositoryInterface
|
interface JournalRepositoryInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournalLink $link
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getLinkNoteText(TransactionJournalLink $link): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
* @param TransactionType $type
|
* @param TransactionType $type
|
||||||
|
|||||||
@@ -217,6 +217,22 @@ class UserRepository implements UserRepositoryInterface
|
|||||||
return Role::where('name', $role)->first();
|
return Role::where('name', $role)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param User $user
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getRoleByUser(User $user): ?string
|
||||||
|
{
|
||||||
|
/** @var Role $role */
|
||||||
|
$role = $user->roles()->first();
|
||||||
|
if (null !== $role) {
|
||||||
|
return $role->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return basic user information.
|
* Return basic user information.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -31,6 +31,13 @@ use Illuminate\Support\Collection;
|
|||||||
*/
|
*/
|
||||||
interface UserRepositoryInterface
|
interface UserRepositoryInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param User $user
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getRoleByUser(User $user): ?string;
|
||||||
/**
|
/**
|
||||||
* Returns a collection of all users.
|
* Returns a collection of all users.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -24,11 +24,9 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Transformers;
|
namespace FireflyIII\Transformers;
|
||||||
|
|
||||||
|
|
||||||
use FireflyIII\Models\Note;
|
|
||||||
use FireflyIII\Models\TransactionJournalLink;
|
use FireflyIII\Models\TransactionJournalLink;
|
||||||
use League\Fractal\TransformerAbstract;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -36,6 +34,8 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
|||||||
*/
|
*/
|
||||||
class TransactionLinkTransformer extends AbstractTransformer
|
class TransactionLinkTransformer extends AbstractTransformer
|
||||||
{
|
{
|
||||||
|
/** @var JournalRepositoryInterface */
|
||||||
|
private $repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -44,6 +44,8 @@ class TransactionLinkTransformer extends AbstractTransformer
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
$this->repository = app(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
if ('testing' === config('app.env')) {
|
if ('testing' === config('app.env')) {
|
||||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
}
|
}
|
||||||
@@ -56,13 +58,7 @@ class TransactionLinkTransformer extends AbstractTransformer
|
|||||||
*/
|
*/
|
||||||
public function transform(TransactionJournalLink $link): array
|
public function transform(TransactionJournalLink $link): array
|
||||||
{
|
{
|
||||||
$notes = null;
|
$notes = $this->repository->getLinkNoteText($link);
|
||||||
/** @var Note $note */
|
|
||||||
$note = $link->notes()->first();
|
|
||||||
if (null !== $note) {
|
|
||||||
$notes = $note->text;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'id' => (int)$link->id,
|
'id' => (int)$link->id,
|
||||||
'created_at' => $link->created_at->toAtomString(),
|
'created_at' => $link->created_at->toAtomString(),
|
||||||
|
|||||||
@@ -61,27 +61,21 @@ class TransactionTransformer extends AbstractTransformer
|
|||||||
*/
|
*/
|
||||||
public function transform(Transaction $transaction): array
|
public function transform(Transaction $transaction): array
|
||||||
{
|
{
|
||||||
$categoryId = null;
|
|
||||||
$categoryName = null;
|
|
||||||
$budgetId = null;
|
|
||||||
$budgetName = null;
|
|
||||||
$categoryId = $transaction->transaction_category_id ?? $transaction->transaction_journal_category_id;
|
|
||||||
$categoryName = $transaction->transaction_category_name ?? $transaction->transaction_journal_category_name;
|
|
||||||
$journal = $transaction->transactionJournal;
|
$journal = $transaction->transactionJournal;
|
||||||
$notes = $this->repository->getNoteText($journal);
|
$category = $this->getCategory($transaction);
|
||||||
if ($transaction->transaction_type_type === TransactionType::WITHDRAWAL) {
|
$budget = $this->getBudget($transaction);
|
||||||
$budgetId = $transaction->transaction_budget_id ?? $transaction->transaction_journal_budget_id;
|
|
||||||
$budgetName = $transaction->transaction_budget_name ?? $transaction->transaction_journal_budget_name;
|
|
||||||
}
|
|
||||||
// get tags:
|
|
||||||
$tags = implode(',', $journal->tags->pluck('tag')->toArray());
|
|
||||||
|
|
||||||
|
$this->repository->setUser($journal->user);
|
||||||
|
|
||||||
|
$notes = $this->repository->getNoteText($journal);
|
||||||
|
$tags = implode(',', $this->repository->getTags($journal));
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'id' => (int)$transaction->id,
|
'id' => (int)$transaction->id,
|
||||||
'created_at' => $transaction->created_at->toAtomString(),
|
'created_at' => $transaction->created_at->toAtomString(),
|
||||||
'updated_at' => $transaction->updated_at->toAtomString(),
|
'updated_at' => $transaction->updated_at->toAtomString(),
|
||||||
'description' => $transaction->description,
|
'description' => $transaction->description,
|
||||||
|
'journal_description' => $transaction->description,
|
||||||
'transaction_description' => $transaction->transaction_description,
|
'transaction_description' => $transaction->transaction_description,
|
||||||
'date' => $transaction->date->format('Y-m-d'),
|
'date' => $transaction->date->format('Y-m-d'),
|
||||||
'type' => $transaction->transaction_type_type,
|
'type' => $transaction->transaction_type_type,
|
||||||
@@ -100,10 +94,10 @@ class TransactionTransformer extends AbstractTransformer
|
|||||||
'foreign_currency_decimal_places' => $transaction->foreign_currency_dp,
|
'foreign_currency_decimal_places' => $transaction->foreign_currency_dp,
|
||||||
'bill_id' => $transaction->bill_id,
|
'bill_id' => $transaction->bill_id,
|
||||||
'bill_name' => $transaction->bill_name,
|
'bill_name' => $transaction->bill_name,
|
||||||
'category_id' => $categoryId,
|
'category_id' => $category['category_id'],
|
||||||
'category_name' => $categoryName,
|
'category_name' => $category['category_name'],
|
||||||
'budget_id' => $budgetId,
|
'budget_id' => $budget['budget_id'],
|
||||||
'budget_name' => $budgetName,
|
'budget_name' => $budget['budget_name'],
|
||||||
'notes' => $notes,
|
'notes' => $notes,
|
||||||
'sepa_cc' => $this->repository->getMetaField($journal, 'sepa-cc'),
|
'sepa_cc' => $this->repository->getMetaField($journal, 'sepa-cc'),
|
||||||
'sepa_ct_op' => $this->repository->getMetaField($journal, 'sepa-ct-op'),
|
'sepa_ct_op' => $this->repository->getMetaField($journal, 'sepa-ct-op'),
|
||||||
@@ -138,6 +132,7 @@ class TransactionTransformer extends AbstractTransformer
|
|||||||
if (null !== $transaction->transaction_foreign_amount) {
|
if (null !== $transaction->transaction_foreign_amount) {
|
||||||
$data['foreign_amount'] = round($transaction->transaction_foreign_amount, (int)$transaction->foreign_currency_dp);
|
$data['foreign_amount'] = round($transaction->transaction_foreign_amount, (int)$transaction->foreign_currency_dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// switch on type for consistency
|
// switch on type for consistency
|
||||||
switch ($transaction->transaction_type_type) {
|
switch ($transaction->transaction_type_type) {
|
||||||
case TransactionType::WITHDRAWAL:
|
case TransactionType::WITHDRAWAL:
|
||||||
@@ -176,11 +171,43 @@ class TransactionTransformer extends AbstractTransformer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// expand description.
|
// expand description.
|
||||||
if (\strlen((string)$transaction->transaction_description) > 0) {
|
if ('' !== (string)$transaction->transaction_description) {
|
||||||
$data['description'] = $transaction->transaction_description . ' (' . $transaction->description . ')';
|
$data['description'] = $transaction->transaction_description . ' (' . $transaction->description . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Transaction $transaction
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getBudget(Transaction $transaction): array
|
||||||
|
{
|
||||||
|
if ($transaction->transaction_type_type !== TransactionType::WITHDRAWAL) {
|
||||||
|
return [
|
||||||
|
'budget_id' => null,
|
||||||
|
'budget_name' => null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'budget_id' => $transaction->transaction_budget_id ?? $transaction->transaction_journal_budget_id,
|
||||||
|
'budget_name' => $transaction->transaction_budget_name ?? $transaction->transaction_journal_budget_name,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Transaction $transaction
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getCategory(Transaction $transaction): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'category_id' => $transaction->transaction_category_id ?? $transaction->transaction_journal_category_id,
|
||||||
|
'category_name' => $transaction->transaction_category_name ?? $transaction->transaction_journal_category_name,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace FireflyIII\Transformers;
|
|||||||
|
|
||||||
|
|
||||||
use FireflyIII\Models\Role;
|
use FireflyIII\Models\Role;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
@@ -33,6 +34,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class UserTransformer extends AbstractTransformer
|
class UserTransformer extends AbstractTransformer
|
||||||
{
|
{
|
||||||
|
/** @var UserRepositoryInterface */
|
||||||
|
private $repository;
|
||||||
/**
|
/**
|
||||||
* UserTransformer constructor.
|
* UserTransformer constructor.
|
||||||
*
|
*
|
||||||
@@ -40,6 +43,7 @@ class UserTransformer extends AbstractTransformer
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
$this->repository = app(UserRepositoryInterface::class);
|
||||||
if ('testing' === config('app.env')) {
|
if ('testing' === config('app.env')) {
|
||||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
}
|
}
|
||||||
@@ -54,12 +58,6 @@ class UserTransformer extends AbstractTransformer
|
|||||||
*/
|
*/
|
||||||
public function transform(User $user): array
|
public function transform(User $user): array
|
||||||
{
|
{
|
||||||
/** @var Role $role */
|
|
||||||
$role = $user->roles()->first();
|
|
||||||
if (null !== $role) {
|
|
||||||
$role = $role->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => (int)$user->id,
|
'id' => (int)$user->id,
|
||||||
'created_at' => $user->created_at->toAtomString(),
|
'created_at' => $user->created_at->toAtomString(),
|
||||||
@@ -67,7 +65,7 @@ class UserTransformer extends AbstractTransformer
|
|||||||
'email' => $user->email,
|
'email' => $user->email,
|
||||||
'blocked' => 1 === (int)$user->blocked,
|
'blocked' => 1 === (int)$user->blocked,
|
||||||
'blocked_code' => '' === $user->blocked_code ? null : $user->blocked_code,
|
'blocked_code' => '' === $user->blocked_code ? null : $user->blocked_code,
|
||||||
'role' => $role,
|
'role' => $this->repository->getRoleByUser($user),
|
||||||
'links' => [
|
'links' => [
|
||||||
[
|
[
|
||||||
'rel' => 'self',
|
'rel' => 'self',
|
||||||
|
|||||||
@@ -53,8 +53,10 @@ class TagTransformerTest extends TestCase
|
|||||||
'zoomLevel' => 3,
|
'zoomLevel' => 3,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$transformer = new TagTransformer(new ParameterBag);
|
$transformer = app(TagTransformer::class);
|
||||||
|
$transformer->setParameters(new ParameterBag);
|
||||||
$result = $transformer->transform($tag);
|
$result = $transformer->transform($tag);
|
||||||
|
|
||||||
$this->assertEquals($tag->tag, $result['tag']);
|
$this->assertEquals($tag->tag, $result['tag']);
|
||||||
$this->assertEquals(5.5, $result['latitude']);
|
$this->assertEquals(5.5, $result['latitude']);
|
||||||
$this->assertEquals(6.6, $result['longitude']);
|
$this->assertEquals(6.6, $result['longitude']);
|
||||||
|
|||||||
66
tests/Unit/Transformers/TransactionLinkTransformerTest.php
Normal file
66
tests/Unit/Transformers/TransactionLinkTransformerTest.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* TransactionLinkTransformerTest.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 Carbon\Carbon;
|
||||||
|
use FireflyIII\Models\Transaction;
|
||||||
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Models\TransactionJournalLink;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\TransactionLinkTransformer;
|
||||||
|
use FireflyIII\Transformers\TransactionTransformer;
|
||||||
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TransactionLinkTransformerTest
|
||||||
|
*/
|
||||||
|
class TransactionLinkTransformerTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test basic tag transformer
|
||||||
|
*
|
||||||
|
* @covers \FireflyIII\Transformers\TransactionLinkTransformer
|
||||||
|
*/
|
||||||
|
public function testBasic(): void
|
||||||
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
|
$repository->shouldReceive('getLinkNoteText')->atLeast()->once()->andReturn('abc');
|
||||||
|
|
||||||
|
/** @var TransactionJournalLink $link */
|
||||||
|
$link = TransactionJournalLink::first();
|
||||||
|
|
||||||
|
$transformer = app(TransactionLinkTransformer::class);
|
||||||
|
$transformer->setParameters(new ParameterBag);
|
||||||
|
|
||||||
|
$result = $transformer->transform($link);
|
||||||
|
|
||||||
|
$this->assertEquals($link->source_id, $result['inward_id']);
|
||||||
|
$this->assertEquals('abc', $result['notes']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\Transformers;
|
namespace Tests\Unit\Transformers;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use FireflyIII\Transformers\UserTransformer;
|
use FireflyIII\Transformers\UserTransformer;
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@@ -41,27 +42,15 @@ class UserTransformerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBasic(): void
|
public function testBasic(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$repository->shouldReceive('getRoleByUser')->atLeast()->once()->andReturn('owner');
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
$transformer = new UserTransformer(new ParameterBag());
|
|
||||||
|
$transformer = app(UserTransformer::class);
|
||||||
|
$transformer->setParameters(new ParameterBag);
|
||||||
$result = $transformer->transform($user);
|
$result = $transformer->transform($user);
|
||||||
|
|
||||||
$this->assertEquals($user->email, $result['email']);
|
$this->assertEquals($user->email, $result['email']);
|
||||||
$this->assertEquals('owner', $result['role']);
|
$this->assertEquals('owner', $result['role']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test basic transformer.
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Transformers\UserTransformer
|
|
||||||
*/
|
|
||||||
public function testEmptyUser(): void
|
|
||||||
{
|
|
||||||
$user = $this->emptyUser();
|
|
||||||
$transformer = new UserTransformer(new ParameterBag());
|
|
||||||
$result = $transformer->transform($user);
|
|
||||||
|
|
||||||
$this->assertEquals($user->email, $result['email']);
|
|
||||||
$this->assertNull($result['role']);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user