mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-08 10:48:13 +00:00
Fix test method names.
This commit is contained in:
@@ -66,7 +66,7 @@ class RecurrenceFactoryTest extends TestCase
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category= $this->user()->categories()->inRandomOrder()->first();
|
||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
@@ -160,7 +160,7 @@ class RecurrenceFactoryTest extends TestCase
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category= $this->user()->categories()->inRandomOrder()->first();
|
||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
@@ -187,7 +187,7 @@ class RecurrenceFactoryTest extends TestCase
|
||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||
|
||||
// data for basic recurrence.
|
||||
$data = [
|
||||
$data = [
|
||||
'recurrence' => [
|
||||
'type' => 'deposit',
|
||||
'first_date' => Carbon::create()->addDay(),
|
||||
@@ -243,196 +243,6 @@ class RecurrenceFactoryTest extends TestCase
|
||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deposit. With piggy bank. With tags. With budget. With category.
|
||||
*
|
||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||
*/
|
||||
public function testBasicTransfer(): void
|
||||
{
|
||||
// objects to return:
|
||||
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category= $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
$budgetFactory = $this->mock(BudgetFactory::class);
|
||||
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
|
||||
// mock calls:
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
||||
$piggyFactory->shouldReceive('setUser')->once();
|
||||
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->twice();
|
||||
$accountRepos->shouldReceive('findNull')->twice()->andReturn($accountA, $accountB);
|
||||
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||
|
||||
$budgetFactory->shouldReceive('setUser')->once();
|
||||
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
||||
|
||||
$categoryFactory->shouldReceive('setUser')->once();
|
||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||
|
||||
// data for basic recurrence.
|
||||
$data = [
|
||||
'recurrence' => [
|
||||
'type' => 'transfer',
|
||||
'first_date' => Carbon::create()->addDay(),
|
||||
'repetitions' => 0,
|
||||
'title' => 'Test recurrence' . random_int(1, 100000),
|
||||
'description' => 'Description thing',
|
||||
'apply_rules' => true,
|
||||
'active' => true,
|
||||
'repeat_until' => null,
|
||||
],
|
||||
'meta' => [
|
||||
'tags' => ['a', 'b', 'c'],
|
||||
'piggy_bank_id' => 1,
|
||||
'piggy_bank_name' => 'Bla bla',
|
||||
],
|
||||
'repetitions' => [
|
||||
[
|
||||
'type' => 'daily',
|
||||
'moment' => '',
|
||||
'skip' => 0,
|
||||
'weekend' => 1,
|
||||
],
|
||||
],
|
||||
'transactions' => [
|
||||
[
|
||||
'source_id' => 1,
|
||||
'source_name' => 'Some name',
|
||||
'destination_id' => 2,
|
||||
'destination_name' => 'some otjer name',
|
||||
'currency_id' => 1,
|
||||
'currency_code' => 'EUR',
|
||||
'foreign_currency_id' => null,
|
||||
'foreign_currency_code' => null,
|
||||
'foreign_amount' => null,
|
||||
'description' => 'Bla bla bla',
|
||||
'amount' => '100',
|
||||
'budget_id' => 1,
|
||||
'budget_name' => 'Some budget',
|
||||
'category_id' => 2,
|
||||
'category_name' => 'Some category',
|
||||
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(3));
|
||||
|
||||
$factory = new RecurrenceFactory;
|
||||
$factory->setUser($this->user());
|
||||
|
||||
$result = $factory->create($data);
|
||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* With piggy bank. With tags. With budget. With category.
|
||||
*
|
||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||
*/
|
||||
public function testBasicNoTags(): void
|
||||
{
|
||||
// objects to return:
|
||||
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category= $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
$budgetFactory = $this->mock(BudgetFactory::class);
|
||||
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
|
||||
// mock calls:
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
||||
$piggyFactory->shouldReceive('setUser')->once();
|
||||
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->twice();
|
||||
$accountRepos->shouldReceive('findNull')->twice()->andReturn($accountA, $accountB);
|
||||
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||
|
||||
$budgetFactory->shouldReceive('setUser')->once();
|
||||
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
||||
|
||||
$categoryFactory->shouldReceive('setUser')->once();
|
||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||
|
||||
// data for basic recurrence.
|
||||
$data = [
|
||||
'recurrence' => [
|
||||
'type' => 'withdrawal',
|
||||
'first_date' => Carbon::create()->addDay(),
|
||||
'repetitions' => 0,
|
||||
'title' => 'Test recurrence' . random_int(1, 100000),
|
||||
'description' => 'Description thing',
|
||||
'apply_rules' => true,
|
||||
'active' => true,
|
||||
'repeat_until' => null,
|
||||
],
|
||||
'meta' => [
|
||||
'tags' => [],
|
||||
'piggy_bank_id' => 1,
|
||||
'piggy_bank_name' => 'Bla bla',
|
||||
],
|
||||
'repetitions' => [
|
||||
[
|
||||
'type' => 'daily',
|
||||
'moment' => '',
|
||||
'skip' => 0,
|
||||
'weekend' => 1,
|
||||
],
|
||||
],
|
||||
'transactions' => [
|
||||
[
|
||||
'source_id' => 1,
|
||||
'source_name' => 'Some name',
|
||||
'destination_id' => 2,
|
||||
'destination_name' => 'some otjer name',
|
||||
'currency_id' => 1,
|
||||
'currency_code' => 'EUR',
|
||||
'foreign_currency_id' => null,
|
||||
'foreign_currency_code' => null,
|
||||
'foreign_amount' => null,
|
||||
'description' => 'Bla bla bla',
|
||||
'amount' => '100',
|
||||
'budget_id' => 1,
|
||||
'budget_name' => 'Some budget',
|
||||
'category_id' => 2,
|
||||
'category_name' => 'Some category',
|
||||
|
||||
],
|
||||
],
|
||||
];
|
||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(1));
|
||||
$factory = new RecurrenceFactory;
|
||||
$factory->setUser($this->user());
|
||||
|
||||
$result = $factory->create($data);
|
||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* No piggy bank. With tags. With budget. With category.
|
||||
*
|
||||
@@ -446,7 +256,7 @@ class RecurrenceFactoryTest extends TestCase
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category= $this->user()->categories()->inRandomOrder()->first();
|
||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
@@ -527,6 +337,196 @@ class RecurrenceFactoryTest extends TestCase
|
||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* With piggy bank. With tags. With budget. With category.
|
||||
*
|
||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||
*/
|
||||
public function testBasicNoTags(): void
|
||||
{
|
||||
// objects to return:
|
||||
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
$budgetFactory = $this->mock(BudgetFactory::class);
|
||||
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
|
||||
// mock calls:
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
||||
$piggyFactory->shouldReceive('setUser')->once();
|
||||
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->twice();
|
||||
$accountRepos->shouldReceive('findNull')->twice()->andReturn($accountA, $accountB);
|
||||
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||
|
||||
$budgetFactory->shouldReceive('setUser')->once();
|
||||
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
||||
|
||||
$categoryFactory->shouldReceive('setUser')->once();
|
||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||
|
||||
// data for basic recurrence.
|
||||
$data = [
|
||||
'recurrence' => [
|
||||
'type' => 'withdrawal',
|
||||
'first_date' => Carbon::create()->addDay(),
|
||||
'repetitions' => 0,
|
||||
'title' => 'Test recurrence' . random_int(1, 100000),
|
||||
'description' => 'Description thing',
|
||||
'apply_rules' => true,
|
||||
'active' => true,
|
||||
'repeat_until' => null,
|
||||
],
|
||||
'meta' => [
|
||||
'tags' => [],
|
||||
'piggy_bank_id' => 1,
|
||||
'piggy_bank_name' => 'Bla bla',
|
||||
],
|
||||
'repetitions' => [
|
||||
[
|
||||
'type' => 'daily',
|
||||
'moment' => '',
|
||||
'skip' => 0,
|
||||
'weekend' => 1,
|
||||
],
|
||||
],
|
||||
'transactions' => [
|
||||
[
|
||||
'source_id' => 1,
|
||||
'source_name' => 'Some name',
|
||||
'destination_id' => 2,
|
||||
'destination_name' => 'some otjer name',
|
||||
'currency_id' => 1,
|
||||
'currency_code' => 'EUR',
|
||||
'foreign_currency_id' => null,
|
||||
'foreign_currency_code' => null,
|
||||
'foreign_amount' => null,
|
||||
'description' => 'Bla bla bla',
|
||||
'amount' => '100',
|
||||
'budget_id' => 1,
|
||||
'budget_name' => 'Some budget',
|
||||
'category_id' => 2,
|
||||
'category_name' => 'Some category',
|
||||
|
||||
],
|
||||
],
|
||||
];
|
||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(1));
|
||||
$factory = new RecurrenceFactory;
|
||||
$factory->setUser($this->user());
|
||||
|
||||
$result = $factory->create($data);
|
||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deposit. With piggy bank. With tags. With budget. With category.
|
||||
*
|
||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||
*/
|
||||
public function testBasicTransfer(): void
|
||||
{
|
||||
// objects to return:
|
||||
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
$budgetFactory = $this->mock(BudgetFactory::class);
|
||||
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
|
||||
// mock calls:
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
||||
$piggyFactory->shouldReceive('setUser')->once();
|
||||
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->twice();
|
||||
$accountRepos->shouldReceive('findNull')->twice()->andReturn($accountA, $accountB);
|
||||
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||
|
||||
$budgetFactory->shouldReceive('setUser')->once();
|
||||
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
||||
|
||||
$categoryFactory->shouldReceive('setUser')->once();
|
||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||
|
||||
// data for basic recurrence.
|
||||
$data = [
|
||||
'recurrence' => [
|
||||
'type' => 'transfer',
|
||||
'first_date' => Carbon::create()->addDay(),
|
||||
'repetitions' => 0,
|
||||
'title' => 'Test recurrence' . random_int(1, 100000),
|
||||
'description' => 'Description thing',
|
||||
'apply_rules' => true,
|
||||
'active' => true,
|
||||
'repeat_until' => null,
|
||||
],
|
||||
'meta' => [
|
||||
'tags' => ['a', 'b', 'c'],
|
||||
'piggy_bank_id' => 1,
|
||||
'piggy_bank_name' => 'Bla bla',
|
||||
],
|
||||
'repetitions' => [
|
||||
[
|
||||
'type' => 'daily',
|
||||
'moment' => '',
|
||||
'skip' => 0,
|
||||
'weekend' => 1,
|
||||
],
|
||||
],
|
||||
'transactions' => [
|
||||
[
|
||||
'source_id' => 1,
|
||||
'source_name' => 'Some name',
|
||||
'destination_id' => 2,
|
||||
'destination_name' => 'some otjer name',
|
||||
'currency_id' => 1,
|
||||
'currency_code' => 'EUR',
|
||||
'foreign_currency_id' => null,
|
||||
'foreign_currency_code' => null,
|
||||
'foreign_amount' => null,
|
||||
'description' => 'Bla bla bla',
|
||||
'amount' => '100',
|
||||
'budget_id' => 1,
|
||||
'budget_name' => 'Some budget',
|
||||
'category_id' => 2,
|
||||
'category_name' => 'Some category',
|
||||
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(3));
|
||||
|
||||
$factory = new RecurrenceFactory;
|
||||
$factory->setUser($this->user());
|
||||
|
||||
$result = $factory->create($data);
|
||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user