mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Remove unused tests
This commit is contained in:
@@ -1,203 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Account;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default asset account test set:
|
||||
$defaultAssetSet = new FieldSet();
|
||||
$defaultAssetSet->title = 'default_asset_account';
|
||||
$defaultAssetSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$defaultAssetSet->addField(Field::createBasic('type', 'static-asset'));
|
||||
$defaultAssetSet->addField(Field::createBasic('account_role', 'random-asset-accountRole'));
|
||||
$configuration->addMandatoryFieldSet($defaultAssetSet);
|
||||
|
||||
// expense test set:
|
||||
$expenseSet = new FieldSet();
|
||||
$expenseSet->title = 'expense_account';
|
||||
$expenseSet->addField(Field::createBasic('name', 'uuid'));
|
||||
|
||||
// to make sure expense set ignores the opening balance fields:
|
||||
$field = new Field();
|
||||
$field->title = 'type';
|
||||
$field->fieldTitle = 'type';
|
||||
$field->fieldType = 'static-expense';
|
||||
$field->ignorableFields = ['opening_balance', 'opening_balance_date', 'virtual_balance', 'order'];
|
||||
$expenseSet->addField($field);
|
||||
$configuration->addMandatoryFieldSet($expenseSet);
|
||||
|
||||
// liability test set:
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->title = 'liabilities_account';
|
||||
$fieldSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$fieldSet->addField(Field::createBasic('type', 'static-liabilities'));
|
||||
$fieldSet->addField(Field::createBasic('liability_type', 'random-liability-type'));
|
||||
$fieldSet->addField(Field::createBasic('liability_amount', 'random-amount'));
|
||||
$fieldSet->addField(Field::createBasic('interest', 'random-percentage'));
|
||||
$fieldSet->addField(Field::createBasic('interest_period', 'random-interest-period'));
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'liability_start_date';
|
||||
$field->fieldType = 'random-past-date';
|
||||
$field->ignorableFields = ['opening_balance', 'opening_balance_date'];
|
||||
$field->title = 'liability_start_date';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addMandatoryFieldSet($fieldSet);
|
||||
|
||||
// credit card set:
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->title = 'cc_account';
|
||||
$fieldSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$fieldSet->addField(Field::createBasic('type', 'static-asset'));
|
||||
$fieldSet->addField(Field::createBasic('account_role', 'static-ccAsset'));
|
||||
$fieldSet->addField(Field::createBasic('credit_card_type', 'static-monthlyFull'));
|
||||
$fieldSet->addField(Field::createBasic('monthly_payment_date', 'random-past-date'));
|
||||
$configuration->addMandatoryFieldSet($fieldSet);
|
||||
|
||||
// optional field sets (for all test configs)
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('active', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('iban', 'iban'));
|
||||
$configuration->addOptionalFieldSet('iban', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('bic', 'bic'));
|
||||
$configuration->addOptionalFieldSet('bic', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('account_number', 'account_number'));
|
||||
$configuration->addOptionalFieldSet('account_number', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('opening_balance', 'random-amount'));
|
||||
$fieldSet->addField(Field::createBasic('opening_balance_date', 'random-past-date'));
|
||||
$configuration->addOptionalFieldSet('ob', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('virtual_balance', 'random-amount'));
|
||||
$configuration->addOptionalFieldSet('virtual_balance', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_id';
|
||||
$field->fieldType = 'random-currency-id';
|
||||
$field->ignorableFields = ['currency_code'];
|
||||
$field->title = 'currency_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_code';
|
||||
$field->fieldType = 'random-currency-code';
|
||||
$field->ignorableFields = ['currency_id'];
|
||||
$field->title = 'currency_code';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_code', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('order', 'order'));
|
||||
$configuration->addOptionalFieldSet('order', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('include_net_worth', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('include_net_worth', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('notes', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('latitude', 'latitude'));
|
||||
$fieldSet->addField(Field::createBasic('longitude', 'longitude'));
|
||||
$fieldSet->addField(Field::createBasic('zoom_level', 'random-zoom_level'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* storeDataProvider / emptyDataProvider
|
||||
*
|
||||
* @dataProvider emptyDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.accounts.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,208 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Account;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* Only create optional sets.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function newUpdateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// optional field sets (for all test configs)
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('name', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('active', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('iban', 'iban'));
|
||||
$configuration->addOptionalFieldSet('iban', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('bic', 'bic'));
|
||||
$configuration->addOptionalFieldSet('bic', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('account_number', 'iban'));
|
||||
$configuration->addOptionalFieldSet('account_number', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('order', 'order'));
|
||||
$configuration->addOptionalFieldSet('order', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('include_net_worth', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('include_net_worth', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('virtual_balance', 'random-amount');
|
||||
$field->ignorableFields = ['current_balance'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('virtual_balance', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_id';
|
||||
$field->fieldType = 'random-currency-id';
|
||||
$field->ignorableFields = ['currency_code', 'currency_symbol', 'current_balance'];
|
||||
$field->title = 'currency_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_code';
|
||||
$field->fieldType = 'random-currency-code';
|
||||
$field->ignorableFields = ['currency_id', 'currency_symbol', 'current_balance'];
|
||||
$field->title = 'currency_code';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_code', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('account_role', 'random-asset-accountRole'));
|
||||
$configuration->addOptionalFieldSet('account_role', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('notes', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('latitude', 'latitude'));
|
||||
$fieldSet->addField(Field::createBasic('longitude', 'longitude'));
|
||||
$fieldSet->addField(Field::createBasic('zoom_level', 'random-zoom_level'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('opening_balance', 'random-amount');
|
||||
$field->ignorableFields = ['current_balance'];
|
||||
$fieldSet->addField($field);
|
||||
$fieldSet->addField(Field::createBasic('opening_balance_date', 'random-past-date'));
|
||||
$configuration->addOptionalFieldSet('ob', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [7];
|
||||
$fieldSet->addField(Field::createBasic('account_role', 'static-ccAsset'));
|
||||
$fieldSet->addField(Field::createBasic('credit_card_type', 'static-monthlyFull'));
|
||||
$fieldSet->addField(Field::createBasic('monthly_payment_date', 'random-past-date'));
|
||||
$configuration->addOptionalFieldSet('cc1', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [13];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'liability_type';
|
||||
$field->fieldType = 'random-liability-type';
|
||||
$field->ignorableFields = ['account_role'];
|
||||
$field->title = 'liability_type';
|
||||
$fieldSet->addField($field);
|
||||
$fieldSet->addField(Field::createBasic('account_role', 'null'));
|
||||
$fieldSet->addField(Field::createBasic('credit_card_type', 'null'));
|
||||
$fieldSet->addField(Field::createBasic('monthly_payment_date', 'null'));
|
||||
$configuration->addOptionalFieldSet('liability-1', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [13];
|
||||
$fieldSet->addField(Field::createBasic('interest', 'random-percentage'));
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'interest_period';
|
||||
$field->fieldType = 'random-interest-period';
|
||||
$field->ignorableFields = ['account_role'];
|
||||
$field->title = 'interest_period';
|
||||
$fieldSet->addField($field);
|
||||
$fieldSet->addField(Field::createBasic('account_role', 'null'));
|
||||
$fieldSet->addField(Field::createBasic('credit_card_type', 'null'));
|
||||
$fieldSet->addField(Field::createBasic('monthly_payment_date', 'null'));
|
||||
$configuration->addOptionalFieldSet('liability-2', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* newStoreDataProvider / emptyDataProvider
|
||||
*
|
||||
* @dataProvider newUpdateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.accounts.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Attachment;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default asset account test set:
|
||||
$defaultAssetSet = new FieldSet();
|
||||
$defaultAssetSet->title = 'default_file';
|
||||
$defaultAssetSet->addField(Field::createBasic('filename', 'uuid'));
|
||||
$defaultAssetSet->addField(Field::createBasic('attachable_type', 'random-attachment-type'));
|
||||
$defaultAssetSet->addField(Field::createBasic('attachable_id', 'static-one'));
|
||||
$configuration->addMandatoryFieldSet($defaultAssetSet);
|
||||
|
||||
// optional field sets
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('title', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('title', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('notes', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider emptyDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.attachments.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Attachment;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.attachments.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// optional field sets (for all test configs)
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('filename', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('filename', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('title', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('title', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('notes', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('attachable_type', 'static-journal-type'));
|
||||
$fieldSet->addField(Field::createBasic('attachable_id', 'random-journal-id'));
|
||||
$configuration->addOptionalFieldSet('attachable_type', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,118 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\AvailableBudget;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default asset account test set:
|
||||
$defaultAssetSet = new FieldSet();
|
||||
$defaultAssetSet->title = 'default_file';
|
||||
$defaultAssetSet->addField(Field::createBasic('amount', 'random-amount'));
|
||||
$defaultAssetSet->addField(Field::createBasic('start', 'random-date-two-year'));
|
||||
$defaultAssetSet->addField(Field::createBasic('end', 'random-date-one-year'));
|
||||
$configuration->addMandatoryFieldSet($defaultAssetSet);
|
||||
|
||||
// optional field sets
|
||||
$fieldSet = new FieldSet();
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_id';
|
||||
$field->fieldType = 'random-currency-id';
|
||||
$field->ignorableFields = ['currency_code'];
|
||||
$field->title = 'currency_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_code';
|
||||
$field->fieldType = 'random-currency-code';
|
||||
$field->ignorableFields = ['currency_id'];
|
||||
$field->title = 'currency_code';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_code', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider emptyDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.available_budgets.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,123 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\AvailableBudget;
|
||||
|
||||
use Faker\Factory;
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.available_budgets.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// optional field sets (for all test configs)
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_id';
|
||||
$field->fieldType = 'random-currency-id';
|
||||
$field->ignorableFields = ['currency_code', 'currency_symbol'];
|
||||
$field->title = 'currency_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_code';
|
||||
$field->fieldType = 'random-currency-code';
|
||||
$field->ignorableFields = ['currency_id', 'currency_symbol'];
|
||||
$field->title = 'currency_code';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('amount', 'random-amount'));
|
||||
$configuration->addOptionalFieldSet('amount', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('start', 'random-date-two-year'));
|
||||
$configuration->addOptionalFieldSet('start', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('end', 'random-date-one-year'));
|
||||
$configuration->addOptionalFieldSet('end', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('start', 'random-date-two-year'));
|
||||
$fieldSet->addField(Field::createBasic('end', 'random-date-one-year'));
|
||||
$configuration->addOptionalFieldSet('both', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,179 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Bill;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default asset account test set:
|
||||
$defaultAssetSet = new FieldSet();
|
||||
$defaultAssetSet->title = 'default_file';
|
||||
$defaultAssetSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$defaultAssetSet->addField(Field::createBasic('amount_min', 'random-amount-min'));
|
||||
$defaultAssetSet->addField(Field::createBasic('amount_max', 'random-amount-max'));
|
||||
$defaultAssetSet->addField(Field::createBasic('date', 'random-past-date'));
|
||||
$defaultAssetSet->addField(Field::createBasic('repeat_freq', 'random-bill-repeat-freq'));
|
||||
$configuration->addMandatoryFieldSet($defaultAssetSet);
|
||||
|
||||
// optional field sets
|
||||
$fieldSet = new FieldSet();
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_id';
|
||||
$field->fieldType = 'random-currency-id';
|
||||
$field->ignorableFields = ['currency_code'];
|
||||
$field->title = 'currency_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_code';
|
||||
$field->fieldType = 'random-currency-code';
|
||||
$field->ignorableFields = ['currency_id'];
|
||||
$field->title = 'currency_code';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_code', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('name', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('amount_min', 'random-amount-min'));
|
||||
$configuration->addOptionalFieldSet('amount_min', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('amount_max', 'random-amount-max'));
|
||||
$configuration->addOptionalFieldSet('amount_max', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('date', 'random-past-date'));
|
||||
$configuration->addOptionalFieldSet('date', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('repeat_freq', 'random-bill-repeat-freq'));
|
||||
$configuration->addOptionalFieldSet('repeat_freq', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('skip', 'random-skip'));
|
||||
$configuration->addOptionalFieldSet('skip', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('active', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('notes', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'object_group_id';
|
||||
$field->fieldType = 'random-og-id';
|
||||
$field->ignorableFields = ['object_group_title', 'object_group_order'];
|
||||
$field->title = 'object_group_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('object_group_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'object_group_title';
|
||||
$field->fieldType = 'uuid';
|
||||
$field->ignorableFields = ['object_group_id', 'object_group_order'];
|
||||
$field->title = 'object_group_title';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('object_group_title', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider emptyDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.bills.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,164 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Bill;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.bills.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('name', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('amount_min', 'random-amount-min'));
|
||||
$configuration->addOptionalFieldSet('amount_min', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('amount_max', 'random-amount-max'));
|
||||
$configuration->addOptionalFieldSet('amount_max', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('date', 'random-past-date'));
|
||||
$configuration->addOptionalFieldSet('date', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('repeat_freq', 'random-bill-repeat-freq'));
|
||||
$configuration->addOptionalFieldSet('repeat_freq', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('skip', 'random-skip'));
|
||||
$configuration->addOptionalFieldSet('skip', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('order', 'order'));
|
||||
$configuration->addOptionalFieldSet('order', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('active', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('notes', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'object_group_id';
|
||||
$field->fieldType = 'random-og-id';
|
||||
$field->ignorableFields = ['object_group_title', 'object_group_order'];
|
||||
$field->title = 'object_group_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('object_group_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'object_group_title';
|
||||
$field->fieldType = 'uuid';
|
||||
$field->ignorableFields = ['object_group_id', 'object_group_order'];
|
||||
$field->title = 'object_group_title';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('object_group_title', $fieldSet);
|
||||
|
||||
// optional field sets
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_id';
|
||||
$field->fieldType = 'random-currency-id';
|
||||
$field->ignorableFields = ['currency_code', 'currency_symbol'];
|
||||
$field->title = 'currency_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_code';
|
||||
$field->fieldType = 'random-currency-code';
|
||||
$field->ignorableFields = ['currency_id', 'currency_symbol'];
|
||||
$field->title = 'currency_code';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_code', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,131 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Budget;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default test set:
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_budget';
|
||||
$defaultSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
// optional sets:
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('active', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'auto_budget_currency_id';
|
||||
$field->fieldType = 'random-currency-id';
|
||||
$field->ignorableFields = ['auto_budget_currency_code'];
|
||||
$field->title = 'auto_budget_currency_id';
|
||||
$fieldSet->addField($field);
|
||||
|
||||
$fieldSet->addField(Field::createBasic('auto_budget_type', 'random-auto-type'));
|
||||
$fieldSet->addField(Field::createBasic('auto_budget_amount', 'random-amount'));
|
||||
$fieldSet->addField(Field::createBasic('auto_budget_period', 'random-auto-period'));
|
||||
$configuration->addOptionalFieldSet('auto-id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'auto_budget_currency_code';
|
||||
$field->fieldType = 'random-currency-code';
|
||||
$field->ignorableFields = ['auto_budget_currency_id'];
|
||||
$field->title = 'auto_budget_currency_code';
|
||||
$fieldSet->addField($field);
|
||||
|
||||
$fieldSet->addField(Field::createBasic('auto_budget_type', 'random-auto-type'));
|
||||
$fieldSet->addField(Field::createBasic('auto_budget_amount', 'random-amount'));
|
||||
$fieldSet->addField(Field::createBasic('auto_budget_period', 'random-auto-period'));
|
||||
$configuration->addOptionalFieldSet('auto-code', $fieldSet);
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider emptyDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.budgets.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,131 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Budget;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.budgets.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('name', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('active', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('order', 'order'));
|
||||
$configuration->addOptionalFieldSet('order', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'auto_budget_currency_id';
|
||||
$field->fieldType = 'random-currency-id';
|
||||
$field->ignorableFields = ['auto_budget_currency_code', 'a'];
|
||||
$field->title = 'auto_budget_currency_id';
|
||||
$fieldSet->addField($field);
|
||||
$fieldSet->addField(Field::createBasic('auto_budget_type', 'random-auto-type'));
|
||||
$fieldSet->addField(Field::createBasic('auto_budget_amount', 'random-amount'));
|
||||
$fieldSet->addField(Field::createBasic('auto_budget_period', 'random-auto-period'));
|
||||
$configuration->addOptionalFieldSet('auto_budget_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'auto_budget_currency_code';
|
||||
$field->fieldType = 'random-currency-code';
|
||||
$field->ignorableFields = ['auto_budget_currency_id', 'b'];
|
||||
$field->title = 'auto_budget_currency_code';
|
||||
$fieldSet->addField($field);
|
||||
$fieldSet->addField(Field::createBasic('auto_budget_type', 'random-auto-type'));
|
||||
$fieldSet->addField(Field::createBasic('auto_budget_amount', 'random-amount'));
|
||||
$fieldSet->addField(Field::createBasic('auto_budget_period', 'random-auto-period'));
|
||||
$configuration->addOptionalFieldSet('auto_budget_code', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'auto_budget_type';
|
||||
$field->fieldType = 'static-auto-none';
|
||||
$field->ignorableFields = ['auto_budget_currency_code', 'auto_budget_currency_id', 'c', 'auto_budget_period', 'auto_budget_amount'];
|
||||
$field->expectedReturn = function ($value) {
|
||||
return null;
|
||||
};
|
||||
$field->title = 'auto_budget_type';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('none', $fieldSet);
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,137 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\BudgetLimit;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default test set:
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_budget_limit';
|
||||
$defaultSet->addField(Field::createBasic('start', 'random-date-two-year'));
|
||||
$defaultSet->addField(Field::createBasic('end', 'random-date-one-year'));
|
||||
$defaultSet->addField(Field::createBasic('amount', 'random-amount'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
// optional tests
|
||||
$fieldSet = new FieldSet();
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_id';
|
||||
$field->fieldType = 'random-currency-id';
|
||||
$field->ignorableFields = ['currency_code'];
|
||||
$field->title = 'currency_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_code';
|
||||
$field->fieldType = 'random-currency-code';
|
||||
$field->ignorableFields = ['currency_id'];
|
||||
$field->title = 'currency_code';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_code', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('start', 'random-date-two-year');
|
||||
$field->ignorableFields = ['spent'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('start', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('end', 'random-date-one-year');
|
||||
$field->ignorableFields = ['spent'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('end', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('amount', 'random-amount'));
|
||||
$configuration->addOptionalFieldSet('amount', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider emptyDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.budgets.limits.store', [1]);
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,113 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\BudgetLimit;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.budgets.limits.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1, 1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_id';
|
||||
$field->fieldType = 'random-currency-id';
|
||||
$field->ignorableFields = ['currency_code', 'currency_name', 'currency_symbol', 'spent'];
|
||||
$field->title = 'currency_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1, 1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'currency_code';
|
||||
$field->fieldType = 'random-currency-code';
|
||||
$field->ignorableFields = ['currency_id', 'currency_name', 'currency_symbol', 'spent'];
|
||||
$field->title = 'currency_code';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('currency_code', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1, 1];
|
||||
$fieldSet->addField(Field::createBasic('start', 'random-date-two-year'));
|
||||
$configuration->addOptionalFieldSet('start', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1, 1];
|
||||
$fieldSet->addField(Field::createBasic('end', 'random-date-one-year'));
|
||||
$configuration->addOptionalFieldSet('end', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1, 1];
|
||||
$fieldSet->addField(Field::createBasic('amount', 'random-amount'));
|
||||
$configuration->addOptionalFieldSet('amount', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Category;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default test set:
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_cat';
|
||||
$defaultSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
// add optional set
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('notes', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider emptyDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.categories.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Category;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.categories.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('name', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('notes', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\ObjectGroup;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.object-groups.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('title', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('title', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('order', 'order'));
|
||||
$configuration->addOptionalFieldSet('order', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,146 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\PiggyBank;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default test set:
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_object';
|
||||
$defaultSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('account_id', 'random-piggy-account'));
|
||||
$defaultSet->addField(Field::createBasic('target_amount', 'random-amount-max'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
// add optional set
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('current_amount', 'random-amount-min'));
|
||||
$configuration->addOptionalFieldSet('current_amount', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('start_date', 'random-past-date'));
|
||||
$configuration->addOptionalFieldSet('start_date', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('target_date', 'random-future-date'));
|
||||
$configuration->addOptionalFieldSet('target_date', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('order', 'order'));
|
||||
$configuration->addOptionalFieldSet('order', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'object_group_id';
|
||||
$field->fieldType = 'random-og-id';
|
||||
$field->ignorableFields = ['object_group_title'];
|
||||
$field->title = 'object_group_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('object_group_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'object_group_title';
|
||||
$field->fieldType = 'uuid';
|
||||
$field->ignorableFields = ['object_group_id'];
|
||||
$field->title = 'object_group_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('object_group_title', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('notes', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider emptyDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.piggy_banks.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,146 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\PiggyBank;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.piggy_banks.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('name', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('account_id', 'random-piggy-account');
|
||||
$field->ignorableFields = ['account_name', 'currency_id', 'currency_code'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('account_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('target_amount', 'random-amount-max');
|
||||
$field->ignorableFields = ['percentage', 'current_amount', 'left_to_save', 'save_per_month'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('target_amount', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('current_amount', 'random-amount-min');
|
||||
$field->ignorableFields = ['percentage', 'left_to_save', 'save_per_month'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('current_amount', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('start_date', 'random-past-date'));
|
||||
$configuration->addOptionalFieldSet('start_date', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('target_date', 'random-future-date');
|
||||
$field->ignorableFields = ['save_per_month'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('target_date', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('order', 'order'));
|
||||
$configuration->addOptionalFieldSet('order', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('notes', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'object_group_id';
|
||||
$field->fieldType = 'random-og-id';
|
||||
$field->ignorableFields = ['object_group_title', 'object_group_order'];
|
||||
$field->title = 'object_group_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('object_group_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = new Field();
|
||||
$field->fieldTitle = 'object_group_title';
|
||||
$field->fieldType = 'uuid';
|
||||
$field->ignorableFields = ['object_group_id', 'object_group_order'];
|
||||
$field->title = 'object_group_id';
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('object_group_title', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,190 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Recurrence;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default test set:
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_withdrawal';
|
||||
$defaultSet->addField(Field::createBasic('type', 'static-withdrawal'));
|
||||
$defaultSet->addField(Field::createBasic('title', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('first_date', 'random-future-date'));
|
||||
$defaultSet->addField(Field::createBasic('repeat_until', 'random-future-date'));
|
||||
$defaultSet->addField(Field::createBasic('repetitions/0/type', 'static-type-weekly'));
|
||||
$defaultSet->addField(Field::createBasic('repetitions/0/moment', 'static-one'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/description', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/amount', 'random-amount'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/source_id', 'random-asset-id'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/destination_id', 'random-expense-id'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_withdrawal_2';
|
||||
$defaultSet->addField(Field::createBasic('type', 'static-withdrawal'));
|
||||
$defaultSet->addField(Field::createBasic('title', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('first_date', 'random-future-date'));
|
||||
$defaultSet->addField(Field::createBasic('nr_of_repetitions', 'random-nr-of-reps'));
|
||||
$defaultSet->addField(Field::createBasic('repetitions/0/type', 'static-type-weekly'));
|
||||
$defaultSet->addField(Field::createBasic('repetitions/0/moment', 'static-one'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/description', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/amount', 'random-amount'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/source_id', 'random-asset-id'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/destination_id', 'random-expense-id'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_deposit';
|
||||
$defaultSet->addField(Field::createBasic('type', 'static-deposit'));
|
||||
$defaultSet->addField(Field::createBasic('title', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('first_date', 'random-future-date'));
|
||||
$defaultSet->addField(Field::createBasic('repeat_until', 'random-future-date'));
|
||||
$defaultSet->addField(Field::createBasic('repetitions/0/type', 'static-type-weekly'));
|
||||
$defaultSet->addField(Field::createBasic('repetitions/0/moment', 'static-one'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/description', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/amount', 'random-amount'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/source_id', 'random-revenue-id'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/destination_id', 'random-asset-id'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_transfer';
|
||||
$defaultSet->addField(Field::createBasic('type', 'static-transfer'));
|
||||
$defaultSet->addField(Field::createBasic('title', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('first_date', 'random-future-date'));
|
||||
$defaultSet->addField(Field::createBasic('repeat_until', 'random-future-date'));
|
||||
$defaultSet->addField(Field::createBasic('repetitions/0/type', 'static-type-weekly'));
|
||||
$defaultSet->addField(Field::createBasic('repetitions/0/moment', 'static-one'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/description', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/amount', 'random-amount'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/source_id', 'random-other-asset-id'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/destination_id', 'random-asset-id'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
// add optional set
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('description', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('description', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('apply_rules', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('apply_rules', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('notes', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('active', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('repetitions/0/skip', 'random-skip'));
|
||||
$configuration->addOptionalFieldSet('skip', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/foreign_amount', 'random-amount'));
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/foreign_currency_id', 'random-currency-id'));
|
||||
$configuration->addOptionalFieldSet('foreign1', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/budget_id', 'random-budget-id'));
|
||||
$configuration->addOptionalFieldSet('budget', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/category_id', 'random-category-id'));
|
||||
$configuration->addOptionalFieldSet('category', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/tags', 'random-tags'));
|
||||
$configuration->addOptionalFieldSet('tags', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/piggy_bank_id', 'random-piggy-id'));
|
||||
$configuration->addOptionalFieldSet('piggy', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider emptyDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.recurrences.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,176 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Recurrence;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.recurrences.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
// optional fields
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('title', 'uuid');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('title', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('description', 'uuid');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('description', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('first_date', 'random-past-date');
|
||||
$field->ignorableFields = ['repetitions'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('first_date', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('apply_rules', 'boolean');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('apply_rules', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('active', 'boolean');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('repetitions/0/type', 'static-ndom');
|
||||
$field->ignorableFields = ['repetitions/0/description', 'repetitions/0/occurrences'];
|
||||
$fieldSet->addField($field);
|
||||
$fieldSet->addField(Field::createBasic('repetitions/0/moment', 'moment-ndom'));
|
||||
$configuration->addOptionalFieldSet('ndom', $fieldSet);
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('repetitions/0/type', 'static-monthly');
|
||||
$field->ignorableFields = ['repetitions/0/description', 'repetitions/0/occurrences'];
|
||||
$fieldSet->addField($field);
|
||||
$fieldSet->addField(Field::createBasic('repetitions/0/moment', 'moment-monthly'));
|
||||
$configuration->addOptionalFieldSet('monthly', $fieldSet);
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('repetitions/0/type', 'static-yearly');
|
||||
$field->ignorableFields = ['repetitions/0/description', 'repetitions/0/occurrences'];
|
||||
$fieldSet->addField($field);
|
||||
$fieldSet->addField(Field::createBasic('repetitions/0/moment', 'random-past-date'));
|
||||
$configuration->addOptionalFieldSet('yearly', $fieldSet);
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('repetitions/0/skip', 'random-skip');
|
||||
$field->ignorableFields = ['repetitions/0/description', 'repetitions/0/occurrences'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('skip', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('repetitions/0/weekend', 'weekend');
|
||||
$field->ignorableFields = ['repetitions/0/description', 'repetitions/0/occurrences'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('weekend', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/foreign_amount', 'random-amount'));
|
||||
$field = Field::createBasic('transactions/0/foreign_currency_id', 'random-currency-id');
|
||||
$field->ignorableFields = ['transactions/0/foreign_currency_code', 'transactions/0/foreign_currency_symbol'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('foreign1', $fieldSet);
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('transactions/0/budget_id', 'random-budget-id');
|
||||
$field->ignorableFields = ['transactions/0/budget_name'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('budget', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('transactions/0/category_id', 'random-category-id');
|
||||
$field->ignorableFields = ['transactions/0/category_name'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('category', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/tags', 'random-tags'));
|
||||
$configuration->addOptionalFieldSet('tags', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('transactions/0/piggy_bank_id', 'random-piggy-id');
|
||||
$field->ignorableFields = ['transactions/0/piggy_bank_name'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('piggy', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,143 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Rule;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default test set:
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_rule_id';
|
||||
$defaultSet->addField(Field::createBasic('title', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('rule_group_id', 'random-rule-group-id'));
|
||||
$defaultSet->addField(Field::createBasic('trigger', 'random-trigger'));
|
||||
$defaultSet->addField(Field::createBasic('triggers/0/type', 'random-trigger-type'));
|
||||
$defaultSet->addField(Field::createBasic('triggers/0/value', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('actions/0/type', 'random-action-type'));
|
||||
$defaultSet->addField(Field::createBasic('actions/0/value', 'uuid'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_rule_name';
|
||||
$defaultSet->addField(Field::createBasic('title', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('rule_group_title', 'random-rule-group-title'));
|
||||
$defaultSet->addField(Field::createBasic('trigger', 'random-trigger'));
|
||||
$defaultSet->addField(Field::createBasic('triggers/0/type', 'random-trigger-type'));
|
||||
$defaultSet->addField(Field::createBasic('triggers/0/value', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('actions/0/type', 'random-action-type'));
|
||||
$defaultSet->addField(Field::createBasic('actions/0/value', 'uuid'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
// add optional set
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('order', 'low-order'));
|
||||
$configuration->addOptionalFieldSet('order', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('active', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('strict', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('strict', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('stop_processing', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('stop_processing', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('triggers/0/stop_processing', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('stop_processingX', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('triggers/0/active', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('activeX', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('actions/0/active', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('activeXX', $fieldSet);
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider emptyDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.rules.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,167 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Rule;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.recurrences.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('title', 'uuid');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('title', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('description', 'uuid');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('description', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('order', 'low-order');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('order', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('trigger', 'random-trigger'));
|
||||
$configuration->addOptionalFieldSet('trigger', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('active', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('strict', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('strict', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('stop_processing', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('stop_processing', $fieldSet);
|
||||
|
||||
// sub trigger fields
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('triggers/0/type', 'random-trigger-type');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('trigger_type', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('triggers/0/value', 'uuid');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('trigger_value', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('triggers/0/active', 'boolean');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('trigger_active', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('triggers/0/stop_processing', 'boolean');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('stop_processing', $fieldSet);
|
||||
|
||||
// optional action fields
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('actions/0/type', 'random-action-type');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('action_type', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('actions/0/value', 'uuid');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('action_value', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('actions/0/active', 'boolean');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('action_active', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('actions/0/stop_processing', 'boolean');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('action_stop_processing', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,114 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\RuleGroup;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default test set:
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_object';
|
||||
$defaultSet->addField(Field::createBasic('title', 'uuid'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
// optionals
|
||||
$fieldSet = new FieldSet();
|
||||
$field = Field::createBasic('description', 'uuid');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('description', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$field = Field::createBasic('order', 'low-order');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('order', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$field = Field::createBasic('active', 'boolean');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider storeDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.rule_groups.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\RuleGroup;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.rule_groups.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('title', 'uuid');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('title', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('description', 'uuid');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('description', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('order', 'low-order');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('order', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('active', 'boolean');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Tag;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default test set:
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_object';
|
||||
$defaultSet->addField(Field::createBasic('tag', 'uuid'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
// optionals
|
||||
$fieldSet = new FieldSet();
|
||||
$field = Field::createBasic('date', 'random-past-date');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('date', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$field = Field::createBasic('description', 'uuid');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('description', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('longitude', 'longitude'));
|
||||
$fieldSet->addField(Field::createBasic('latitude', 'latitude'));
|
||||
$fieldSet->addField(Field::createBasic('zoom_level', 'random-zoom_level'));
|
||||
$configuration->addOptionalFieldSet('location', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider storeDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.tags.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Tag;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.tags.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('tag', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('tag', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('date', 'random-past-date'));
|
||||
$configuration->addOptionalFieldSet('date', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('description', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('description', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('longitude', 'longitude'));
|
||||
$fieldSet->addField(Field::createBasic('latitude', 'latitude'));
|
||||
$fieldSet->addField(Field::createBasic('zoom_level', 'random-zoom_level'));
|
||||
$configuration->addOptionalFieldSet('location', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,138 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Transaction;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default test set:
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_object_withdrawal';
|
||||
$defaultSet->addField(Field::createBasic('error_if_duplicate_hash', 'boolean'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/type', 'static-withdrawal'));
|
||||
$field = Field::createBasic('transactions/0/date', 'random-past-date');
|
||||
$field->expectedReturn = function ($value) {
|
||||
$date = new Carbon($value, 'Europe/Amsterdam');
|
||||
|
||||
return $date->toIso8601String();
|
||||
};
|
||||
$defaultSet->addField($field);
|
||||
|
||||
$field = Field::createBasic('transactions/0/amount', 'random-amount');
|
||||
$field->expectedReturn = function ($value) {
|
||||
return number_format((float)$value, 12);
|
||||
};
|
||||
|
||||
$defaultSet->addField($field);
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/description', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/source_id', 'random-asset-id'));
|
||||
$defaultSet->addField(Field::createBasic('transactions/0/destination_id', 'random-expense-id'));
|
||||
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
// optional fields
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/category_id', 'random-category-id'));
|
||||
$configuration->addOptionalFieldSet('category_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/reconciled', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('reconciled', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/tags', 'random-tags'));
|
||||
$configuration->addOptionalFieldSet('tags', $fieldSet);
|
||||
$array = ['notes', 'internal_reference', 'bunq_payment_id', 'sepa_cc', 'sepa_ct_op', 'sepa_ct_id',
|
||||
'sepa_db', 'sepa_country', 'sepa_ep', 'sepa_ci', 'sepa_batch_id'];
|
||||
|
||||
foreach ($array as $value) {
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/' . $value, 'uuid'));
|
||||
$configuration->addOptionalFieldSet($value, $fieldSet);
|
||||
}
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider emptyDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.transactions.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,172 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\Transaction;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*
|
||||
* @param array $submission
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.transactions.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('apply_rules', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('apply_rules', $fieldSet);
|
||||
|
||||
// add date
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('transactions/0/date', 'random-past-date');
|
||||
$field->expectedReturn = function ($value) {
|
||||
$date = new Carbon($value, 'Europe/Amsterdam');
|
||||
|
||||
return $date->toIso8601String();
|
||||
};
|
||||
$fieldSet->addField($field);
|
||||
|
||||
$configuration->addOptionalFieldSet('date', $fieldSet);
|
||||
|
||||
// category
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/category_id', 'random-category-id'));
|
||||
$configuration->addOptionalFieldSet('category_id', $fieldSet);
|
||||
|
||||
// amount
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('transactions/0/amount', 'random-amount');
|
||||
$field->expectedReturn = function ($value) {
|
||||
return number_format((float)$value, 12);
|
||||
};
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('amount', $fieldSet);
|
||||
|
||||
// descr
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/description', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('descr', $fieldSet);
|
||||
|
||||
// source
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('transactions/0/source_id', 'random-asset-id');
|
||||
$field->ignorableFields = ['transactions/0/source_name', 'transactions/0/source_iban'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('src', $fieldSet);
|
||||
|
||||
// dest
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('transactions/0/destination_id', 'random-expense-id');
|
||||
$field->ignorableFields = ['transactions/0/destination_name', 'transactions/0/destination_iban'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('dest', $fieldSet);
|
||||
// optional fields
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('transactions/0/category_id', 'random-category-id');
|
||||
$field->ignorableFields = ['transactions/0/category_name'];
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('category_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/reconciled', 'boolean'));
|
||||
$configuration->addOptionalFieldSet('reconciled', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('transactions/0/tags', 'random-tags');
|
||||
$field->expectedReturn = function ($value) {
|
||||
if (is_array($value)) {
|
||||
asort($value);
|
||||
|
||||
return array_values($value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('tags', $fieldSet);
|
||||
$array = ['notes', 'internal_reference', 'bunq_payment_id', 'sepa_cc', 'sepa_ct_op', 'sepa_ct_id',
|
||||
'sepa_db', 'sepa_country', 'sepa_ep', 'sepa_ci', 'sepa_batch_id'];
|
||||
|
||||
foreach ($array as $value) {
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('transactions/0/' . $value, 'uuid'));
|
||||
$configuration->addOptionalFieldSet($value, $fieldSet);
|
||||
}
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,122 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\TransactionCurrency;
|
||||
|
||||
use Faker\Factory;
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default test set:
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_object';
|
||||
$defaultSet->addField(Field::createBasic('code', 'random-new-currency-code'));
|
||||
$defaultSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('symbol', 'random-new-currency-symbol'));
|
||||
|
||||
// 'code' => substr($faker->uuid, 0, 3),
|
||||
// 'name' => $faker->uuid,
|
||||
// 'symbol' => $faker->randomAscii . $faker->randomAscii,
|
||||
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
// optionals
|
||||
$fieldSet = new FieldSet();
|
||||
$field = Field::createBasic('enabled', 'boolean');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('enabled', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$field = Field::createBasic('default', 'boolean');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('default', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$field = Field::createBasic('decimal_places', 'currency-dp');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('decimal_places', $fieldSet);
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider storeDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.currencies.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,163 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\TransactionCurrency;
|
||||
|
||||
use Faker\Factory;
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.currencies.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = ['RMB'];
|
||||
$fieldSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('name', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = ['RMB'];
|
||||
$fieldSet->addField(Field::createBasic('symbol', 'random-new-currency-symbol'));
|
||||
$configuration->addOptionalFieldSet('symbol', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = ['RMB'];
|
||||
$field = Field::createBasic('enabled', 'boolean');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('enabled', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = ['RMB'];
|
||||
$field = Field::createBasic('default', 'boolean-true');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('default', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = ['RMB'];
|
||||
$field = Field::createBasic('decimal_places', 'currency-dp');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('decimal_places', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = ['RMB'];
|
||||
$fieldSet->addField(Field::createBasic('symbol', 'random-new-currency-code'));
|
||||
$configuration->addOptionalFieldSet('code', $fieldSet);
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataSet(): array
|
||||
{
|
||||
$faker = Factory::create();
|
||||
return [
|
||||
'name' => [
|
||||
'id' => 'INR',
|
||||
'fields' => [
|
||||
'name' => ['test_value' => $faker->uuid],
|
||||
],
|
||||
'extra_ignore' => [],
|
||||
],
|
||||
'code' => [
|
||||
'id' => 'INR',
|
||||
'fields' => [
|
||||
'code' => ['test_value' => substr($faker->uuid, 0, 3)],
|
||||
],
|
||||
'extra_ignore' => [],
|
||||
],
|
||||
'symbol' => [
|
||||
'id' => 'RUB',
|
||||
'fields' => [
|
||||
'description' => ['test_value' => $faker->randomAscii . $faker->randomAscii],
|
||||
],
|
||||
'extra_ignore' => [],
|
||||
],
|
||||
'decimal_places' => [
|
||||
'id' => 'ETH',
|
||||
'fields' => [
|
||||
'decimal_places' => ['test_value' => $faker->numberBetween(1, 6)],
|
||||
],
|
||||
'extra_ignore' => [],
|
||||
],
|
||||
'enabled' => [
|
||||
'id' => 'ETH',
|
||||
'fields' => [
|
||||
'enabled' => ['test_value' => $faker->boolean],
|
||||
],
|
||||
'extra_ignore' => [],
|
||||
],
|
||||
'default' => [
|
||||
'id' => 'XBT',
|
||||
'fields' => [
|
||||
'default' => ['test_value' => $faker->boolean],
|
||||
],
|
||||
'extra_ignore' => [],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\TransactionLink;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default test set:
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_object';
|
||||
$defaultSet->addField(Field::createBasic('link_type_id', 'random-link-type-id'));
|
||||
$defaultSet->addField(Field::createBasic('inward_id', 'random-low-journal-id'));
|
||||
$defaultSet->addField(Field::createBasic('outward_id', 'random-high-journal-id'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_object_name';
|
||||
$defaultSet->addField(Field::createBasic('link_type_name', 'random-link-type-name'));
|
||||
$defaultSet->addField(Field::createBasic('inward_id', 'random-low-journal-id'));
|
||||
$defaultSet->addField(Field::createBasic('outward_id', 'random-high-journal-id'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
// optionals
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->addField(Field::createBasic('notes', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider storeDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.transaction_links.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\TransactionLink;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.transaction_links.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
|
||||
$field = Field::createBasic('link_type_id', 'random-link-type-id');
|
||||
$field->ignorableFields = ['link_type_name'];
|
||||
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('link_type_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
|
||||
$field = Field::createBasic('link_type_name', 'random-link-type-name');
|
||||
$field->ignorableFields = ['link_type_id'];
|
||||
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('link_type_name', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('inward_id', 'random-low-journal-id'));
|
||||
$configuration->addOptionalFieldSet('inward_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('outward_id', 'random-high-journal-id'));
|
||||
$configuration->addOptionalFieldSet('outward_id', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$fieldSet->addField(Field::createBasic('notes', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('notes', $fieldSet);
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\TransactionLinkType;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default test set:
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_object';
|
||||
$defaultSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('inward', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('outward', 'uuid'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider storeDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.link_types.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Models\TransactionLinkType;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.link_types.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [5];
|
||||
$fieldSet->addField(Field::createBasic('name', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('name', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [5];
|
||||
$fieldSet->addField(Field::createBasic('inward', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('inward', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [5];
|
||||
$fieldSet->addField(Field::createBasic('outward', 'uuid'));
|
||||
$configuration->addOptionalFieldSet('outward', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* StoreControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Webhook;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class StoreControllerTest
|
||||
*/
|
||||
class StoreControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider(): array
|
||||
{
|
||||
return [[[]]];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function storeDataProvider(): array
|
||||
{
|
||||
// some test configs:
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
// default test set:
|
||||
$defaultSet = new FieldSet();
|
||||
$defaultSet->title = 'default_object';
|
||||
$defaultSet->addField(Field::createBasic('title', 'uuid'));
|
||||
$defaultSet->addField(Field::createBasic('url', 'secure-url'));
|
||||
$defaultSet->addField(Field::createBasic('trigger', 'webhook-trigger'));
|
||||
$defaultSet->addField(Field::createBasic('response', 'webhook-response'));
|
||||
$defaultSet->addField(Field::createBasic('delivery', 'webhook-delivery'));
|
||||
$configuration->addMandatoryFieldSet($defaultSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$field = Field::createBasic('active', 'boolean');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $submission
|
||||
*
|
||||
* emptyDataProvider / storeDataProvider
|
||||
*
|
||||
* @dataProvider storeDataProvider
|
||||
*/
|
||||
public function testStore(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
// run account store with a minimal data set:
|
||||
$address = route('api.v1.webhooks.store');
|
||||
$this->assertPOST($address, $submission);
|
||||
}
|
||||
}
|
@@ -1,114 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdateControllerTest.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Api\Webhook;
|
||||
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Objects\Field;
|
||||
use Tests\Objects\FieldSet;
|
||||
use Tests\Objects\TestConfiguration;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\CollectsValues;
|
||||
use Tests\Traits\TestHelpers;
|
||||
|
||||
/**
|
||||
* Class UpdateControllerTest
|
||||
*/
|
||||
class UpdateControllerTest extends TestCase
|
||||
{
|
||||
use TestHelpers;
|
||||
use CollectsValues;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
/**
|
||||
* @dataProvider updateDataProvider
|
||||
*/
|
||||
public function testUpdate(array $submission): void
|
||||
{
|
||||
if ([] === $submission) {
|
||||
$this->markTestSkipped('Empty provider.');
|
||||
}
|
||||
Log::debug('testStoreUpdated()');
|
||||
Log::debug('submission :', $submission['submission']);
|
||||
Log::debug('expected :', $submission['expected']);
|
||||
Log::debug('ignore :', $submission['ignore']);
|
||||
Log::debug('parameters :', $submission['parameters']);
|
||||
|
||||
$route = route('api.v1.webhooks.update', $submission['parameters']);
|
||||
$this->assertPUT($route, $submission);
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function updateDataProvider(): array
|
||||
{
|
||||
$configuration = new TestConfiguration();
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('active', 'boolean');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('active', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('title', 'uuid');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('title', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('trigger', 'webhook-trigger');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('trigger', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('response', 'webhook-response');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('response', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('delivery', 'webhook-delivery');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('delivery', $fieldSet);
|
||||
|
||||
$fieldSet = new FieldSet();
|
||||
$fieldSet->parameters = [1];
|
||||
$field = Field::createBasic('url', 'secure-url');
|
||||
$fieldSet->addField($field);
|
||||
$configuration->addOptionalFieldSet('url', $fieldSet);
|
||||
|
||||
return $configuration->generateAll();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user