From be47fde6c2f39203f39b670818259ff25b1c18c9 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 07:38:55 +0200 Subject: [PATCH 01/60] Removed all tests. --- tests/controllers/AccountControllerTest.php | 353 ------- tests/controllers/AuthControllerTest.php | 78 -- tests/controllers/BillControllerTest.php | 273 ------ tests/controllers/BudgetControllerTest.php | 435 --------- tests/controllers/CategoryControllerTest.php | 263 ------ tests/controllers/CurrencyControllerTest.php | 279 ------ tests/controllers/HelpControllerTest.php | 104 -- tests/controllers/HomeControllerTest.php | 159 ---- tests/controllers/JsonControllerTest.php | 228 ----- tests/controllers/NewUserControllerTest.php | 110 --- tests/controllers/PiggyBankControllerTest.php | 454 --------- .../controllers/PreferencesControllerTest.php | 121 --- tests/controllers/ProfileControllerTest.php | 195 ---- tests/controllers/ReportControllerTest.php | 172 ---- tests/controllers/SearchControllerTest.php | 58 -- tests/controllers/TagControllerTest.php | 296 ------ .../controllers/TransactionControllerTest.php | 598 ------------ .../charts/ChartAccountControllerTest.php | 134 --- .../charts/ChartBillControllerTest.php | 100 -- .../charts/ChartBudgetControllerTest.php | 164 ---- .../charts/ChartCategoryControllerTest.php | 125 --- .../charts/ChartPiggyBankControllerTest.php | 53 -- .../charts/ChartReportControllerTest.php | 77 -- tests/factories/all.php | 321 ------- .../ChartJsAccountChartGeneratorTest.php | 114 --- .../ChartJsBillChartGeneratorTest.php | 100 -- .../ChartJsBudgetChartGeneratorTest.php | 113 --- .../ChartJsCategoryChartGeneratorTest.php | 114 --- .../ChartJsPiggyBankChartGeneratorTest.php | 66 -- .../ChartJsReportChartGeneratorTest.php | 80 -- .../GoogleAccountChartGeneratorTest.php | 120 --- .../GoogleBillChartGeneratorTest.php | 90 -- .../GoogleBudgetChartGeneratorTest.php | 99 -- .../GoogleCategoryChartGeneratorTest.php | 116 --- .../GooglePiggyBankChartGeneratorTest.php | 58 -- .../GoogleReportChartGeneratorTest.php | 69 -- .../helpers/ConnectJournalToPiggyBankTest.php | 139 --- tests/helpers/ReportHelperTest.php | 329 ------- tests/helpers/ReportQueryTest.php | 397 -------- tests/models/AccountModelTest.php | 162 ---- tests/models/CategoryModelTest.php | 76 -- tests/models/TagModelTest.php | 95 -- tests/models/TransactionJournalModelTest.php | 636 ------------- tests/repositories/AccountRepositoryTest.php | 891 ------------------ tests/repositories/BillRepositoryTest.php | 467 --------- tests/repositories/BudgetRepositoryTest.php | 399 -------- tests/repositories/CategoryRepositoryTest.php | 290 ------ tests/repositories/CurrencyRepositoryTest.php | 114 --- tests/repositories/JournalRepositoryTest.php | 572 ----------- .../repositories/PiggyBankRepositoryTest.php | 196 ---- tests/repositories/TagRepositoryBasicTest.php | 182 ---- tests/repositories/TagRepositoryTest.php | 656 ------------- tests/support/AmountSupportTest.php | 300 ------ tests/support/ExpandedFormTest.php | 202 ---- tests/support/NavigationTest.php | 287 ------ 55 files changed, 12679 deletions(-) delete mode 100644 tests/controllers/AccountControllerTest.php delete mode 100644 tests/controllers/AuthControllerTest.php delete mode 100644 tests/controllers/BillControllerTest.php delete mode 100644 tests/controllers/BudgetControllerTest.php delete mode 100644 tests/controllers/CategoryControllerTest.php delete mode 100644 tests/controllers/CurrencyControllerTest.php delete mode 100644 tests/controllers/HelpControllerTest.php delete mode 100644 tests/controllers/HomeControllerTest.php delete mode 100644 tests/controllers/JsonControllerTest.php delete mode 100644 tests/controllers/NewUserControllerTest.php delete mode 100644 tests/controllers/PiggyBankControllerTest.php delete mode 100644 tests/controllers/PreferencesControllerTest.php delete mode 100644 tests/controllers/ProfileControllerTest.php delete mode 100644 tests/controllers/ReportControllerTest.php delete mode 100644 tests/controllers/SearchControllerTest.php delete mode 100644 tests/controllers/TagControllerTest.php delete mode 100644 tests/controllers/TransactionControllerTest.php delete mode 100644 tests/controllers/charts/ChartAccountControllerTest.php delete mode 100644 tests/controllers/charts/ChartBillControllerTest.php delete mode 100644 tests/controllers/charts/ChartBudgetControllerTest.php delete mode 100644 tests/controllers/charts/ChartCategoryControllerTest.php delete mode 100644 tests/controllers/charts/ChartPiggyBankControllerTest.php delete mode 100644 tests/controllers/charts/ChartReportControllerTest.php delete mode 100644 tests/factories/all.php delete mode 100644 tests/generators/ChartJsAccountChartGeneratorTest.php delete mode 100644 tests/generators/ChartJsBillChartGeneratorTest.php delete mode 100644 tests/generators/ChartJsBudgetChartGeneratorTest.php delete mode 100644 tests/generators/ChartJsCategoryChartGeneratorTest.php delete mode 100644 tests/generators/ChartJsPiggyBankChartGeneratorTest.php delete mode 100644 tests/generators/ChartJsReportChartGeneratorTest.php delete mode 100644 tests/generators/GoogleAccountChartGeneratorTest.php delete mode 100644 tests/generators/GoogleBillChartGeneratorTest.php delete mode 100644 tests/generators/GoogleBudgetChartGeneratorTest.php delete mode 100644 tests/generators/GoogleCategoryChartGeneratorTest.php delete mode 100644 tests/generators/GooglePiggyBankChartGeneratorTest.php delete mode 100644 tests/generators/GoogleReportChartGeneratorTest.php delete mode 100644 tests/helpers/ConnectJournalToPiggyBankTest.php delete mode 100644 tests/helpers/ReportHelperTest.php delete mode 100644 tests/helpers/ReportQueryTest.php delete mode 100644 tests/models/AccountModelTest.php delete mode 100644 tests/models/CategoryModelTest.php delete mode 100644 tests/models/TagModelTest.php delete mode 100644 tests/models/TransactionJournalModelTest.php delete mode 100644 tests/repositories/AccountRepositoryTest.php delete mode 100644 tests/repositories/BillRepositoryTest.php delete mode 100644 tests/repositories/BudgetRepositoryTest.php delete mode 100644 tests/repositories/CategoryRepositoryTest.php delete mode 100644 tests/repositories/CurrencyRepositoryTest.php delete mode 100644 tests/repositories/JournalRepositoryTest.php delete mode 100644 tests/repositories/PiggyBankRepositoryTest.php delete mode 100644 tests/repositories/TagRepositoryBasicTest.php delete mode 100644 tests/repositories/TagRepositoryTest.php delete mode 100644 tests/support/AmountSupportTest.php delete mode 100644 tests/support/ExpandedFormTest.php delete mode 100644 tests/support/NavigationTest.php diff --git a/tests/controllers/AccountControllerTest.php b/tests/controllers/AccountControllerTest.php deleted file mode 100644 index 8e1d1b9b64..0000000000 --- a/tests/controllers/AccountControllerTest.php +++ /dev/null @@ -1,353 +0,0 @@ -createAccount(); - } - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - - } - - /** - * - */ - public function createAccount() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - if (is_null($this->account)) { - $this->account = FactoryMuffin::create('FireflyIII\Models\Account'); - $this->account->user_id = $user->id; - $this->account->save(); - } - } - - /** - * @covers FireflyIII\Http\Controllers\AccountController::create - */ - public function testCreate() - { - $pref = FactoryMuffin::create('FireflyIII\Models\Preference'); - $pref->data = '1M'; - $this->be($pref->user); - - - Preferences::shouldReceive('get')->withArgs(['viewRange', '1M'])->andReturn($pref); - - - $language = FactoryMuffin::create('FireflyIII\Models\Preference'); - $language->data = 'en'; - Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($language); - - // CURRENCY: - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - Amount::shouldReceive('getDefaultCurrency')->andReturn($currency); - Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - $lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference'); - $lastActivity->data = microtime(); - Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); - - $this->call('GET', '/accounts/create/asset'); - $this->assertResponseOk(); - - - $this->assertViewHas('subTitle', 'Create a new asset account'); - $this->assertViewHas('subTitleIcon', 'fa-money'); - $this->assertViewHas('what', 'asset'); - - } - - /** - * @covers FireflyIII\Http\Controllers\AccountController::delete - */ - public function testDelete() - { - - $this->be($this->account->user); - $this->call('GET', '/accounts/delete/' . $this->account->id); - $this->assertResponseOk(); - $this->assertViewHas('subTitle', 'Delete ' . strtolower(e($this->account->accountType->type)) . ' "' . e($this->account->name) . '"'); - - } - - /** - * @covers FireflyIII\Http\Controllers\AccountController::destroy - */ - public function testDestroy() - { - // fake an account. - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - - $this->be($account->user); - - // mock: - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('destroy')->andReturn(true); - - // post it! - $this->call('POST', '/accounts/destroy/' . $account->id, ['_token' => 'replaceme']); - $this->assertSessionHas('success'); - $this->assertResponseStatus(302); - } - - /** - * @covers FireflyIII\Http\Controllers\AccountController::edit - */ - public function testEdit() - { - // fake an account. - - $this->be($this->account->user); - $this->assertCount(1, DB::table('accounts')->where('id', $this->account->id)->whereNull('deleted_at')->get()); - - // create a transaction journal that will act as opening balance: - $openingBalance = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('openingBalanceTransaction')->andReturn($openingBalance); - - // create a transaction that will be returned for the opening balance transaction: - $opening = FactoryMuffin::create('FireflyIII\Models\Transaction'); - $repository->shouldReceive('getFirstTransaction')->andReturn($opening); - - // CURRENCY: - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - Amount::shouldReceive('getDefaultCurrency')->andReturn($currency); - Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - // get edit page: - $this->call('GET', '/accounts/edit/' . $this->account->id); - - // assert stuff: - $this->assertResponseOk(); - $this->assertSessionHas('preFilled'); - $this->assertViewHas('subTitle', 'Edit ' . strtolower(e($this->account->accountType->type)) . ' "' . e($this->account->name) . '"'); - - - } - - /** - * @covers FireflyIII\Http\Controllers\AccountController::index - */ - public function testIndex() - { - // an account: - $this->be($this->account->user); - - $collection = new Collection; - $collection->push($this->account); - - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('getAccounts')->andReturn($collection); - $repository->shouldReceive('countAccounts')->andReturn(1); - $repository->shouldReceive('getLastActivity')->andReturn(null); - - Amount::shouldReceive('format')->andReturn(''); - Amount::shouldReceive('getCurrencyCode')->andReturn('A'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - - // put stuff in session: - $this->session(['start' => new Carbon, 'end' => new Carbon]); - - // get edit page: - $this->call('GET', '/accounts/asset'); - $this->assertResponseOk(); - $this->assertViewHas('what', 'asset'); - - } - - /** - * @covers FireflyIII\Http\Controllers\AccountController::show - */ - public function testShow() - { - // an account: - $this->be($this->account->user); - - // mock! - Amount::shouldReceive('getCurrencyCode')->andReturn('A'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('getJournals')->andReturn(new LengthAwarePaginator([], 0, 10)); - - // get edit page: - $this->call('GET', '/accounts/show/' . $this->account->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\AccountController::store - */ - public function testStore() - { - // an account: - $this->be($this->account->user); - - $data = [ - 'name' => 'New test account ' . rand(1, 1000), - 'what' => 'asset', - 'virtualBalance' => 0, - 'accountRole' => 'defaultAsset', - 'openingBalance' => 20, - 'openingBalanceDate' => date('Y-m-d'), - 'openingBalanceCurrency' => 1, - '_token' => 'replaceme' - ]; - - // fake validation routine: - $request = $this->mock('FireflyIII\Http\Requests\AccountFormRequest'); - $request->shouldReceive('input')->andReturn(''); - - // fake store routine: - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('store')->andReturn($this->account); - - $this->call('POST', '/accounts/store', $data); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - - } - - /** - * @covers FireflyIII\Http\Controllers\AccountController::store - */ - public function testStoreAndRedirect() - { - // an account: - $this->be($this->account->user); - - $data = [ - 'name' => 'New test account ' . rand(1, 1000), - 'what' => 'asset', - 'virtualBalance' => 0, - 'accountRole' => 'defaultAsset', - 'openingBalance' => 20, - 'openingBalanceDate' => date('Y-m-d'), - 'openingBalanceCurrency' => 1, - '_token' => 'replaceme', - 'create_another' => 1, - ]; - - // fake validation routine: - $request = $this->mock('FireflyIII\Http\Requests\AccountFormRequest'); - $request->shouldReceive('input')->andReturn(''); - - // fake store routine: - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('store')->andReturn($this->account); - - $this->call('POST', '/accounts/store', $data); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - - } - - /** - * @covers FireflyIII\Http\Controllers\AccountController::update - */ - public function testUpdate() - { - - // an account: - $this->be($this->account->user); - - $data = [ - 'name' => 'Edited test account ' . rand(1, 1000), - 'active' => 1, - 'accountRole' => 'defaultAsset', - 'virtualBalance' => 0, - 'openingBalance' => 25, - 'openingBalanceDate' => date('Y-m-d'), - 'openingBalanceCurrency' => 1, - '_token' => 'replaceme' - ]; - - // fake validation routine: - $request = $this->mock('FireflyIII\Http\Requests\AccountFormRequest'); - $request->shouldReceive('input')->andReturn(''); - - // fake update routine: - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('update')->andReturn($this->account); - - $this->call('POST', '/accounts/update/' . $this->account->id, $data); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - } - - /** - * @covers FireflyIII\Http\Controllers\AccountController::update - */ - public function testUpdateAndRedirect() - { - - // an account: - $this->be($this->account->user); - - $data = [ - 'name' => 'Edited test account ' . rand(1, 1000), - 'active' => 1, - 'accountRole' => 'defaultAsset', - 'virtualBalance' => 0, - 'openingBalance' => 25, - 'openingBalanceDate' => date('Y-m-d'), - 'openingBalanceCurrency' => 1, - '_token' => 'replaceme', - 'return_to_edit' => 1, - ]; - - // fake validation routine: - $request = $this->mock('FireflyIII\Http\Requests\AccountFormRequest'); - $request->shouldReceive('input')->andReturn(''); - - // fake update routine: - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('update')->andReturn($this->account); - - $this->call('POST', '/accounts/update/' . $this->account->id, $data); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - } - -} diff --git a/tests/controllers/AuthControllerTest.php b/tests/controllers/AuthControllerTest.php deleted file mode 100644 index 2517e19b8c..0000000000 --- a/tests/controllers/AuthControllerTest.php +++ /dev/null @@ -1,78 +0,0 @@ - 'test@example.com', - 'password' => 'onetwothree', - 'password_confirmation' => 'onetwothree', - '_token' => 'replaceMe' - ]; - $this->call('POST', '/auth/register', $data); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - } - - /** - * @covers FireflyIII\Http\Controllers\Auth\AuthController::postRegister - * @covers FireflyIII\Http\Controllers\Auth\AuthController::validator - * @covers FireflyIII\Http\Controllers\Auth\AuthController::create - */ - public function testPostRegisterFails() - { - - $data = [ - 'email' => 'test@example.com', - 'password' => 'onetwothree', - 'password_confirmation' => 'onetwofour', - '_token' => 'replaceMe' - ]; - $this->call('POST', '/auth/register', $data); - $this->assertResponseStatus(302); - - - } - -} diff --git a/tests/controllers/BillControllerTest.php b/tests/controllers/BillControllerTest.php deleted file mode 100644 index 3fc9e690b2..0000000000 --- a/tests/controllers/BillControllerTest.php +++ /dev/null @@ -1,273 +0,0 @@ -be($bill->user); - - // CURRENCY: - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - Amount::shouldReceive('getDefaultCurrency')->andReturn($currency); - Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - $this->call('GET', '/bills/create'); - $this->assertViewHas('subTitle', 'Create new bill'); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\BillController::delete - */ - public function testDelete() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $this->be($bill->user); - $this->call('GET', '/bills/delete/' . $bill->id); - $this->assertViewHas('subTitle', 'Delete bill "' . e($bill->name) . '"'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\BillController::destroy - */ - public function testDestroy() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $this->be($bill->user); - - $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $repository->shouldReceive('destroy')->andReturn(true); - - - $this->call('POST', '/bills/destroy/' . $bill->id, ['_token' => 'replaceMe']); - $this->assertSessionHas('success', 'The bill was deleted.'); - $this->assertResponseStatus(302); - } - - /** - * @covers FireflyIII\Http\Controllers\BillController::edit - */ - public function testEdit() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $this->be($bill->user); - - // CURRENCY: - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - Amount::shouldReceive('getDefaultCurrency')->andReturn($currency); - Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - $this->call('GET', '/bills/edit/' . $bill->id); - $this->assertViewHas('subTitle', 'Edit bill "' . e($bill->name) . '"'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\BillController::index - */ - public function testIndex() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $this->be($bill->user); - - $collection = new Collection; - $collection->push($bill); - - Amount::shouldReceive('format')->andReturn('XX'); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $repository->shouldReceive('getBills')->once()->andReturn($collection); - $repository->shouldReceive('nextExpectedMatch')->with($bill)->andReturn(new Carbon); - $repository->shouldReceive('lastFoundMatch')->with($bill)->andReturn(new Carbon); - - $this->call('GET', '/bills'); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\BillController::rescan - */ - public function testRescan() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $collection = new Collection; - $this->be($bill->user); - $collection->push($journal); - - $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $repository->shouldReceive('getPossiblyRelatedJournals')->once()->andReturn($collection); - $repository->shouldReceive('scan'); - - $this->call('GET', '/bills/rescan/' . $bill->id); - $this->assertResponseStatus(302); - $this->assertSessionHas('success', 'Rescanned everything.'); - - - } - - /** - * @covers FireflyIII\Http\Controllers\BillController::rescan - */ - public function testRescanInactive() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $bill->active = 0; - $bill->save(); - $this->be($bill->user); - - $this->call('GET', '/bills/rescan/' . $bill->id); - $this->assertResponseStatus(302); - $this->assertSessionHas('warning', 'Inactive bills cannot be scanned.'); - - } - - /** - * @covers FireflyIII\Http\Controllers\BillController::show - */ - public function testShow() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $collection = new Collection; - - $bill->save(); - $this->be($bill->user); - $collection->push($journal); - - - $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $repository->shouldReceive('getJournals')->once()->andReturn($collection); - $repository->shouldReceive('nextExpectedMatch')->once()->andReturn(new Carbon); - - Amount::shouldReceive('format')->andReturn('XX'); - Amount::shouldReceive('formatJournal')->andReturn('XX'); - Amount::shouldReceive('getCurrencyCode')->andReturn('XX'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - - $this->call('GET', '/bills/show/' . $bill->id); - } - - /** - * @covers FireflyIII\Http\Controllers\BillController::store - */ - public function testStore() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $request = $this->mock('FireflyIII\Http\Requests\BillFormRequest'); - - $this->be($bill->user); - $request->shouldReceive('getBillData')->once()->andReturn([]); - $repository->shouldReceive('store')->with([])->andReturn($bill); - - $this->call('POST', '/bills/store', ['_token' => 'replaceMe']); - $this->assertResponseStatus(302); - $this->assertSessionHas('success', 'Bill "' . e($bill->name) . '" stored.'); - } - - /** - * @covers FireflyIII\Http\Controllers\BillController::store - */ - public function testStoreAndRedirect() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $request = $this->mock('FireflyIII\Http\Requests\BillFormRequest'); - - $this->be($bill->user); - $request->shouldReceive('getBillData')->once()->andReturn([]); - $repository->shouldReceive('store')->with([])->andReturn($bill); - - $this->call('POST', '/bills/store', ['_token' => 'replaceMe', 'create_another' => 1]); - $this->assertResponseStatus(302); - $this->assertSessionHas('success', 'Bill "' . e($bill->name) . '" stored.'); - } - - /** - * @covers FireflyIII\Http\Controllers\BillController::update - */ - public function testUpdate() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $request = $this->mock('FireflyIII\Http\Requests\BillFormRequest'); - - $this->be($bill->user); - $request->shouldReceive('getBillData')->once()->andReturn([]); - $repository->shouldReceive('update')->andReturn($bill); - - $this->call('POST', '/bills/update/' . $bill->id, ['_token' => 'replaceMe']); - $this->assertResponseStatus(302); - $this->assertSessionHas('success', 'Bill "' . e($bill->name) . '" updated.'); - } - - /** - * @covers FireflyIII\Http\Controllers\BillController::update - */ - public function testUpdateAndRedirect() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $request = $this->mock('FireflyIII\Http\Requests\BillFormRequest'); - - $this->be($bill->user); - $request->shouldReceive('getBillData')->once()->andReturn([]); - $repository->shouldReceive('update')->andReturn($bill); - - $this->call('POST', '/bills/update/' . $bill->id, ['_token' => 'replaceMe', 'return_to_edit' => 1]); - $this->assertResponseStatus(302); - - } -} diff --git a/tests/controllers/BudgetControllerTest.php b/tests/controllers/BudgetControllerTest.php deleted file mode 100644 index b74bfe6a60..0000000000 --- a/tests/controllers/BudgetControllerTest.php +++ /dev/null @@ -1,435 +0,0 @@ -mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $limitRepetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); - $budget = $limitRepetition->budgetlimit->budget; - $this->be($budget->user); - $today = new Carbon; - - $this->session(['start' => $today]); - $repository->shouldReceive('updateLimitAmount')->once()->andReturn($limitRepetition); - $this->call('POST', '/budgets/amount/' . $budget->id, ['amount' => 100, '_token' => 'replaceme']); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::amount - */ - public function testAmountZero() - { - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $limitRepetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); - $budget = $limitRepetition->budgetlimit->budget; - $this->be($budget->user); - $today = new Carbon; - - $this->session(['start' => $today]); - $repository->shouldReceive('updateLimitAmount')->once()->andReturn($limitRepetition); - $this->call('POST', '/budgets/amount/' . $budget->id, ['amount' => 0, '_token' => 'replaceme']); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::create - */ - public function testCreate() - { - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $this->be($budget->user); - $this->call('GET', '/budgets/create'); - $this->assertResponseOk(); - $this->assertViewHas('subTitle', 'Create a new budget'); - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::delete - */ - public function testDelete() - { - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $this->be($budget->user); - $this->call('GET', '/budgets/delete/' . $budget->id); - - $this->assertResponseOk(); - $this->assertViewHas('subTitle', 'Delete budget "' . e($budget->name) . '"'); - $this->assertViewHas('budget'); - $this->assertSessionHas('budgets.delete.url'); - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::destroy - */ - public function testDestroy() - { - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $this->be($budget->user); - - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $repository->shouldReceive('destroy')->andReturn(true); - - $this->call('POST', '/budgets/destroy/' . $budget->id, ['_token' => 'replaceme']); - - $this->assertSessionHas('success', 'The budget "' . e($budget->name) . '" was deleted.'); - - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::edit - */ - public function testEdit() - { - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $this->be($budget->user); - - $this->call('GET', '/budgets/edit/' . $budget->id); - - $this->assertResponseOk(); - $this->assertViewHas('subTitle', 'Edit budget "' . e($budget->name) . '"'); - $this->assertViewHas('budget'); - $this->assertSessionHas('budgets.edit.url'); - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::index - */ - public function testIndex() - { - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $this->be($budget->user); - $collection = new Collection; - $collection->push($budget); - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); - - $repository->shouldReceive('getActiveBudgets')->once()->andReturn($collection); - $repository->shouldReceive('getInactiveBudgets')->once()->andReturn($collection); - $repository->shouldReceive('cleanupBudgets')->once(); - $repository->shouldReceive('spentInPeriodCorrected')->once(); - $repository->shouldReceive('getCurrentRepetition')->once()->andReturn($repetition); - Amount::shouldReceive('getCurrencySymbol')->andReturn('x'); - Amount::shouldReceive('format')->andReturn('x'); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - Amount::shouldReceive('getDefaultCurrency')->andReturn($currency); - $this->call('GET', '/budgets'); - - $this->assertResponseOk(); - $this->assertViewHas('budgets'); - $this->assertViewHas('inactive'); - $this->assertViewHas('inactive'); - - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::noBudget - */ - public function testNoBudget() - { - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $this->be($budget->user); - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $repository->shouldReceive('getWithoutBudget')->andReturn(new Collection); - - $this->call('GET', '/budgets/list/noBudget'); - $this->assertResponseOk(); - $this->assertViewHas('list'); - $this->assertViewHas('subTitle'); - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::postUpdateIncome - */ - public function testPostUpdateIncome() - { - - - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $this->be($budget->user); - $date = Carbon::now()->startOfMonth()->format('FY'); - Preferences::shouldReceive('set')->once()->withArgs(['budgetIncomeTotal' . $date, 1001]); - Preferences::shouldReceive('mark')->once()->andReturn(true); - $lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference'); - $lastActivity->data = microtime(); - Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); - - // language preference: - $language = FactoryMuffin::create('FireflyIII\Models\Preference'); - $language->data = 'en'; - $language->save(); - Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); - - $this->call('POST', '/budgets/income', ['_token' => 'replaceme', 'amount' => 1001]); - $this->assertResponseStatus(302); - $this->assertRedirectedToRoute('budgets.index'); - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::show - */ - public function testShow() - { - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $this->be($budget->user); - - $paginator = new LengthAwarePaginator(new Collection, 0, 20, 1); - - Amount::shouldReceive('getCurrencyCode')->andReturn('x'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - Amount::shouldReceive('format')->andReturn('x'); - $repository->shouldReceive('getJournals')->andReturn($paginator); - $repository->shouldReceive('getBudgetLimits')->andReturn(new Collection); - - - $this->call('GET', '/budgets/show/' . $budget->id); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::show - */ - public function testShowInvalidRepetition() - { - - $repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); - $budget = $repetition->budgetLimit->budget; - $otherBudget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $otherBudget->user_id = $budget->user_id; - $otherBudget->save(); - - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $this->be($otherBudget->user); - - Amount::shouldReceive('getCurrencyCode')->andReturn('x'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - Amount::shouldReceive('format')->andReturn('x'); - $repository->shouldReceive('getJournals')->andReturn(new Collection); - $repository->shouldReceive('getBudgetLimits')->andReturn(new Collection); - - - $this->call('GET', '/budgets/show/' . $otherBudget->id . '/' . $repetition->id); - $this->assertResponseOk(); - $this->assertViewHas('message', 'Invalid selection.'); - - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::show - */ - public function testShowRepetition() - { - $repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); - $budget = $repetition->budgetLimit->budget; - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $this->be($budget->user); - - $paginator = new LengthAwarePaginator(new Collection, 0, 20, 1); - - Amount::shouldReceive('getCurrencyCode')->andReturn('x'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - Amount::shouldReceive('format')->andReturn('x'); - $repository->shouldReceive('getJournals')->andReturn($paginator); - $repository->shouldReceive('getBudgetLimits')->andReturn(new Collection); - - - $this->call('GET', '/budgets/show/' . $budget->id . '/' . $repetition->id); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::store - */ - public function testStore() - { - // a budget: - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $this->be($budget->user); - - $data = [ - 'name' => 'New test budget ' . rand(1, 1000), - '_token' => 'replaceme' - ]; - - // fake validation routine: - $request = $this->mock('FireflyIII\Http\Requests\BudgetFormRequest'); - $request->shouldReceive('input')->andReturn(''); - - // fake store routine: - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $repository->shouldReceive('store')->andReturn($budget); - - $this->call('POST', '/budgets/store', $data); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::store - */ - public function testStoreAndRedirect() - { - // a budget: - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $this->be($budget->user); - - $data = [ - 'name' => 'New test budget ' . rand(1, 1000), - '_token' => 'replaceme', - 'create_another' => 1, - ]; - - // fake validation routine: - $request = $this->mock('FireflyIII\Http\Requests\BudgetFormRequest'); - $request->shouldReceive('input')->andReturn(''); - - // fake store routine: - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $repository->shouldReceive('store')->andReturn($budget); - - $this->call('POST', '/budgets/store', $data); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::update - */ - public function testUpdate() - { - - // a budget: - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $this->be($budget->user); - - $data = [ - 'name' => 'Edited test account ' . rand(1, 1000), - 'active' => 1, - '_token' => 'replaceme' - ]; - - // fake validation routine: - $request = $this->mock('FireflyIII\Http\Requests\BudgetFormRequest'); - $request->shouldReceive('input')->andReturn(''); - - // fake update routine: - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $repository->shouldReceive('update')->andReturn($budget); - - $this->call('POST', '/budgets/update/' . $budget->id, $data); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::update - */ - public function testUpdateAndRedirect() - { - - // a budget: - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $this->be($budget->user); - - $data = [ - 'name' => 'Edited test account ' . rand(1, 1000), - 'active' => 1, - '_token' => 'replaceme', - 'return_to_edit' => 1, - ]; - - // fake validation routine: - $request = $this->mock('FireflyIII\Http\Requests\BudgetFormRequest'); - $request->shouldReceive('input')->andReturn(''); - - // fake update routine: - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $repository->shouldReceive('update')->andReturn($budget); - - $this->call('POST', '/budgets/update/' . $budget->id, $data); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - } - - /** - * @covers FireflyIII\Http\Controllers\BudgetController::updateIncome - */ - public function testUpdateIncome() - { - - // a budget: - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $this->be($budget->user); - $date = Carbon::now()->format('FY'); - $pref = FactoryMuffin::create('FireflyIII\Models\Preference'); - Preferences::shouldReceive('get')->withArgs(['budgetIncomeTotal' . $date, 1000])->andReturn($pref); - Amount::shouldReceive('format')->andReturn('xx'); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - $lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference'); - $lastActivity->data = microtime(); - Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); - - // language preference: - $language = FactoryMuffin::create('FireflyIII\Models\Preference'); - $language->data = 'en'; - $language->save(); - Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); - - - $this->call('GET', '/budgets/income'); - $this->assertResponseOk(); - $this->assertViewHas('amount'); - } -} diff --git a/tests/controllers/CategoryControllerTest.php b/tests/controllers/CategoryControllerTest.php deleted file mode 100644 index 6fa7f76b00..0000000000 --- a/tests/controllers/CategoryControllerTest.php +++ /dev/null @@ -1,263 +0,0 @@ -be($category->user); - - $this->call('GET', '/categories/create'); - $this->assertResponseOk(); - $this->assertViewHas('subTitle', 'Create a new category'); - } - - /** - * @covers FireflyIII\Http\Controllers\CategoryController::delete - */ - public function testDelete() - { - - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->be($category->user); - - $this->call('GET', '/categories/delete/' . $category->id); - $this->assertResponseOk(); - $this->assertViewHas('subTitle', 'Delete category "' . e($category->name) . '"'); - } - - /** - * @covers FireflyIII\Http\Controllers\CategoryController::destroy - */ - public function testDestroy() - { - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->be($category->user); - - $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - $repository->shouldReceive('destroy'); - - $this->call('POST', '/categories/destroy/' . $category->id, ['_token' => 'replaceMe']); - $this->assertResponseStatus(302); - $this->assertSessionHas('success', 'The category "' . e($category->name) . '" was deleted.'); - } - - /** - * @covers FireflyIII\Http\Controllers\CategoryController::edit - */ - public function testEdit() - { - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->be($category->user); - - $this->call('GET', '/categories/edit/' . $category->id); - $this->assertResponseOk(); - $this->assertViewHas('subTitle', 'Edit category "' . e($category->name) . '"'); - } - - /** - * @covers FireflyIII\Http\Controllers\CategoryController::index - */ - public function testIndex() - { - $collection = new Collection; - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->be($category->user); - $collection->push($category); - - Amount::shouldReceive('getCurrencyCode')->andReturn('xx'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - $repository->shouldReceive('getCategories')->andReturn($collection); - $repository->shouldReceive('getLatestActivity')->andReturn(new Carbon); - - $this->call('GET', '/categories'); - $this->assertResponseOk(); - $this->assertViewHas('categories'); - } - - /** - * @covers FireflyIII\Http\Controllers\CategoryController::noCategory - */ - public function testNoCategory() - { - $collection = new Collection; - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $this->be($journal->user); - $collection->push($journal); - - Amount::shouldReceive('format')->andReturn('xx'); - Amount::shouldReceive('getCurrencyCode')->andReturn('xx'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - - $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - $repository->shouldReceive('getWithoutCategory')->andReturn($repository); - - $this->call('GET', '/categories/list/noCategory'); - $this->assertResponseOk(); - $this->assertViewHas('subTitle'); - - - } - - /** - * @covers FireflyIII\Http\Controllers\CategoryController::show - */ - public function testShow() - { - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $collection = new Collection; - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $this->be($category->user); - $collection->push($journal); - - $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - - $repository->shouldReceive('getJournals')->andReturn($collection); - $repository->shouldReceive('countJournals')->andReturn(1); - - Amount::shouldReceive('format')->andReturn('xx'); - Amount::shouldReceive('getCurrencyCode')->andReturn('xx'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - Amount::shouldReceive('formatJournal')->andReturn('xx'); - - $this->call('GET', '/categories/show/' . $category->id); - $this->assertResponseOk(); - $this->assertViewHas('hideCategory', true); - - } - - - /** - * @covers FireflyIII\Http\Controllers\CategoryController::store - */ - public function testStore() - { - // create - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->be($category->user); - - // mock - $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - $request = $this->mock('FireflyIII\Http\Requests\CategoryFormRequest'); - - // expect - $repository->shouldReceive('store')->andReturn($category); - $request->shouldReceive('input')->andReturn(''); - - $this->call('POST', '/categories/store', ['_token' => 'replaceMe', 'name' => 'Bla bla #' . rand(1, 1000)]); - $this->assertResponseStatus(302); - $this->assertSessionHas('success', 'New category "' . $category->name . '" stored!'); - } - - /** - * @covers FireflyIII\Http\Controllers\CategoryController::store - */ - public function testStoreAndRedirect() - { - // create - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->be($category->user); - - // mock: - $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - $request = $this->mock('FireflyIII\Http\Requests\CategoryFormRequest'); - - // fake: - $repository->shouldReceive('store')->andReturn($category); - $request->shouldReceive('input')->andReturn(''); - - - $this->call('POST', '/categories/store', ['_token' => 'replaceMe', 'create_another' => 1, 'name' => 'Bla bla #' . rand(1, 1000)]); - $this->assertResponseStatus(302); - $this->assertSessionHas('success', 'New category "' . $category->name . '" stored!'); - } - - /** - * @covers FireflyIII\Http\Controllers\CategoryController::update - */ - public function testUpdate() - { - // create - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->be($category->user); - - // mock - $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - $request = $this->mock('FireflyIII\Http\Requests\CategoryFormRequest'); - - // expect - $repository->shouldReceive('update')->andReturn($category); - $request->shouldReceive('input')->andReturn(''); - - $this->call('POST', '/categories/update/' . $category->id, ['_token' => 'replaceMe', 'name' => 'Bla bla #' . rand(1, 1000)]); - $this->assertResponseStatus(302); - $this->assertSessionHas('success', 'Category "' . $category->name . '" updated.'); - } - - /** - * @covers FireflyIII\Http\Controllers\CategoryController::update - */ - public function testUpdateAndRedirect() - { - // create - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->be($category->user); - - // mock - $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - $request = $this->mock('FireflyIII\Http\Requests\CategoryFormRequest'); - - // expect - $request->shouldReceive('input')->andReturn(''); - $repository->shouldReceive('update')->andReturn($category); - - - $this->call('POST', '/categories/update/' . $category->id, ['_token' => 'replaceMe', 'return_to_edit' => 1, 'name' => 'Bla bla #' . rand(1, 1000)]); - $this->assertResponseStatus(302); - $this->assertSessionHas('success', 'Category "' . $category->name . '" updated.'); - } -} diff --git a/tests/controllers/CurrencyControllerTest.php b/tests/controllers/CurrencyControllerTest.php deleted file mode 100644 index 50153b50b3..0000000000 --- a/tests/controllers/CurrencyControllerTest.php +++ /dev/null @@ -1,279 +0,0 @@ -be($user); - - $this->call('GET', '/currency/create'); - $this->assertResponseOk(); - $this->assertViewHas('subTitle', 'Create a new currency'); - $this->assertViewHas('subTitleIcon', 'fa-plus'); - - } - - /** - * @covers FireflyIII\Http\Controllers\CurrencyController::defaultCurrency - */ - public function testDefaultCurrency() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - - $this->call('GET', '/currency/default/' . $currency->id); - $this->assertResponseStatus(302); - $this->assertSessionHas('success', $currency->name . ' is now the default currency.'); - } - - /** - * @covers FireflyIII\Http\Controllers\CurrencyController::delete - */ - public function testDelete() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - - $repository = $this->mock('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); - $repository->shouldReceive('countJournals')->andReturn(0); - - $this->call('GET', '/currency/delete/' . $currency->id); - $this->assertResponseOk(); - $this->assertViewHas('currency'); - - } - - /** - * @covers FireflyIII\Http\Controllers\CurrencyController::delete - */ - public function testDeleteUnable() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - - $repository = $this->mock('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); - $repository->shouldReceive('countJournals')->andReturn(1); - - $this->call('GET', '/currency/delete/' . $currency->id); - $this->assertResponseStatus(302); - $this->assertSessionHas('error'); - - } - - /** - * @covers FireflyIII\Http\Controllers\CurrencyController::destroy - */ - public function testDestroy() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $role = FactoryMuffin::create('FireflyIII\Models\Role'); - $role->name = 'owner'; - $role->save(); - $user->attachRole($role); - - $this->be($user); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - - $repository = $this->mock('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); - $repository->shouldReceive('countJournals')->andReturn(0); - - $this->call('POST', '/currency/destroy/' . $currency->id, ['_token' => 'replaceMe']); - $this->assertResponseStatus(302); - $this->assertSessionHas('success', 'Currency "' . e($currency->name) . '" deleted'); - - } - - /** - * @covers FireflyIII\Http\Controllers\CurrencyController::destroy - */ - public function testDestroyUnable() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $role = FactoryMuffin::create('FireflyIII\Models\Role'); - $role->name = 'owner'; - $role->save(); - $user->attachRole($role); - $this->be($user); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - - $repository = $this->mock('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); - $repository->shouldReceive('countJournals')->andReturn(1); - - $this->call('POST', '/currency/destroy/' . $currency->id, ['_token' => 'replaceMe']); - $this->assertResponseStatus(302); - $this->assertSessionHas('error'); - - } - - /** - * @covers FireflyIII\Http\Controllers\CurrencyController::edit - */ - public function testEdit() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - - $repository = $this->mock('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); - $repository->shouldReceive('countJournals')->andReturn(0); - - $this->call('GET', '/currency/edit/' . $currency->id); - $this->assertResponseOk(); - $this->assertViewHas('currency'); - } - - /** - * @covers FireflyIII\Http\Controllers\CurrencyController::index - */ - public function testIndex() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $this->be($user); - - $repository = $this->mock('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); - $repository->shouldReceive('get')->andReturn(new Collection); - $repository->shouldReceive('getCurrencyByPreference')->andReturn($currency); - - $this->call('GET', '/currency'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\CurrencyController::store - */ - public function testStore() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $role = FactoryMuffin::create('FireflyIII\Models\Role'); - $role->name = 'owner'; - $role->save(); - $user->attachRole($role); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $this->be($user); - - $repository = $this->mock('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); - $request = $this->mock('FireflyIII\Http\Requests\CurrencyFormRequest'); - $request->shouldReceive('getCurrencyData')->andReturn([]); - $repository->shouldReceive('store')->andReturn($currency); - - $this->call('POST', '/currency/store', ['_token' => 'replaceMe']); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - - - } - - /** - * @covers FireflyIII\Http\Controllers\CurrencyController::store - */ - public function testStoreAndReturn() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $role = FactoryMuffin::create('FireflyIII\Models\Role'); - $role->name = 'owner'; - $role->save(); - $user->attachRole($role); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $this->be($user); - - $repository = $this->mock('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); - $request = $this->mock('FireflyIII\Http\Requests\CurrencyFormRequest'); - $request->shouldReceive('getCurrencyData')->andReturn([]); - $repository->shouldReceive('store')->andReturn($currency); - - $this->call('POST', '/currency/store', ['_token' => 'replaceMe', 'create_another' => 1]); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - - - } - - /** - * @covers FireflyIII\Http\Controllers\CurrencyController::update - */ - public function testUpdate() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $role = FactoryMuffin::create('FireflyIII\Models\Role'); - $role->name = 'owner'; - $role->save(); - $user->attachRole($role); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $this->be($user); - - $repository = $this->mock('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); - $request = $this->mock('FireflyIII\Http\Requests\CurrencyFormRequest'); - $request->shouldReceive('getCurrencyData')->andReturn([]); - $repository->shouldReceive('update')->andReturn($currency); - - $this->call('POST', '/currency/update/' . $currency->id, ['_token' => 'replaceMe']); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - } - - /** - * @covers FireflyIII\Http\Controllers\CurrencyController::update - */ - public function testUpdateAndReturn() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $role = FactoryMuffin::create('FireflyIII\Models\Role'); - $role->name = 'owner'; - $role->save(); - $user->attachRole($role); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $this->be($user); - - $repository = $this->mock('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); - $request = $this->mock('FireflyIII\Http\Requests\CurrencyFormRequest'); - $request->shouldReceive('getCurrencyData')->andReturn([]); - $repository->shouldReceive('update')->andReturn($currency); - - $this->call('POST', '/currency/update/' . $currency->id, ['_token' => 'replaceMe', 'return_to_edit' => 1]); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - } -} diff --git a/tests/controllers/HelpControllerTest.php b/tests/controllers/HelpControllerTest.php deleted file mode 100644 index b7f40c5f5a..0000000000 --- a/tests/controllers/HelpControllerTest.php +++ /dev/null @@ -1,104 +0,0 @@ -be($user); - // mock some stuff. - $interface = $this->mock('FireflyIII\Helpers\Help\HelpInterface'); - $interface->shouldReceive('hasRoute')->once()->with('accounts.index')->andReturn(true); - $interface->shouldReceive('getFromCache')->once()->with('help.accounts.index.title')->andReturn('Title.'); - $interface->shouldReceive('getFromCache')->once()->with('help.accounts.index.text')->andReturn('Text'); - $interface->shouldReceive('inCache')->andReturn(true); - - - $this->call('GET', '/help/accounts.index'); - $this->assertResponseOk(); - } - - /** - * Everything present and accounted for, but not cached - * - * @covers FireflyIII\Http\Controllers\HelpController::show - */ - public function testGetHelpTextNoCache() - { - // login - $user = FactoryMuffin::create('FireflyIII\User'); - $content = ['title' => 'Bla', 'text' => 'Bla']; - - $this->be($user); - // mock some stuff. - $interface = $this->mock('FireflyIII\Helpers\Help\HelpInterface'); - $interface->shouldReceive('hasRoute')->once()->with('accounts.index')->andReturn(true); - $interface->shouldReceive('getFromGithub')->once()->with('accounts.index')->andReturn($content); - $interface->shouldReceive('putInCache')->once()->withArgs(['accounts.index', $content]); - $interface->shouldReceive('inCache')->once()->andReturn(false); - - - $this->call('GET', '/help/accounts.index'); - $this->assertResponseOk(); - } - - /** - * No such route. - * - * @covers FireflyIII\Http\Controllers\HelpController::show - */ - public function testGetHelpTextNoRoute() - { - // login - $user = FactoryMuffin::create('FireflyIII\User'); - - $this->be($user); - // mock some stuff. - $interface = $this->mock('FireflyIII\Helpers\Help\HelpInterface'); - $interface->shouldReceive('hasRoute')->once()->with('accounts.index')->andReturn(false); - - - $this->call('GET', '/help/accounts.index'); - $this->assertResponseOk(); - } -} diff --git a/tests/controllers/HomeControllerTest.php b/tests/controllers/HomeControllerTest.php deleted file mode 100644 index f4595b017e..0000000000 --- a/tests/controllers/HomeControllerTest.php +++ /dev/null @@ -1,159 +0,0 @@ -be($user); - - - $this->call('POST', '/daterange', ['end' => $end, 'start' => $start, '_token' => 'replaceme']); - $this->assertResponseOk(); - - $this->assertSessionHas('start'); - $this->assertSessionHas('end'); - - } - - - /** - * @covers FireflyIII\Http\Controllers\HomeController::dateRange - */ - public function testDateRangeWarning() - { - $start = '2014-03-01'; - $end = '2015-03-31'; - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $this->call('POST', '/daterange', ['end' => $end, 'start' => $start, '_token' => 'replaceme']); - $this->assertResponseOk(); - - $this->assertSessionHas('start'); - $this->assertSessionHas('end'); - $this->assertSessionHas('warning'); - } - - /** - * @covers FireflyIII\Http\Controllers\HomeController::flush - */ - public function testFlush() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // create at least one tag: - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->tags()->save($tag); - - $this->call('GET', '/flush'); - $this->assertResponseStatus(302); - - } - - /** - * @covers FireflyIII\Http\Controllers\HomeController::index - */ - public function testIndex() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journals = new Collection([$journal]); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $accounts = new Collection([$account]); - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - $this->be($user); - - // mock ALL THE THINGS! - $repository->shouldReceive('countAccounts')->once()->andReturn(3); - Preferences::shouldReceive('get')->once()->withArgs(['frontPageAccounts', []])->andReturn($preference); - $repository->shouldReceive('getFrontpageAccounts')->once()->with($preference)->andReturn($accounts); - $repository->shouldReceive('getSavingsAccounts')->once()->andReturn($accounts); - $repository->shouldReceive('getPiggyBankAccounts')->once()->andReturn($accounts); - $repository->shouldReceive('sumOfEverything')->once()->andReturn(1); - $repository->shouldReceive('getFrontpageTransactions')->once()->andReturn($journals); - - // language preference: - $language = FactoryMuffin::create('FireflyIII\Models\Preference'); - $language->data = 'en'; - $language->save(); - Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); - - $lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference'); - $lastActivity->data = microtime(); - Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); - - - Amount::shouldReceive('getCurrencyCode')->andReturn('EUR'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - Amount::shouldReceive('format')->andReturn('xxx'); - Amount::shouldReceive('formatJournal')->with($journal)->andReturn('xxx'); - - $this->call('GET', '/'); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\HomeController::index - */ - public function testIndexEmpty() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - $this->be($user); - - // mock ALL THE THINGS! - $repository->shouldReceive('countAccounts')->once()->andReturn(0); - - // language preference: - $language = FactoryMuffin::create('FireflyIII\Models\Preference'); - $language->data = 'en'; - $language->save(); - Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); - - $lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference'); - $lastActivity->data = microtime(); - Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); - - $this->call('GET', '/'); - $this->assertResponseStatus(302); - $this->assertRedirectedToRoute('new-user.index'); - } - -} diff --git a/tests/controllers/JsonControllerTest.php b/tests/controllers/JsonControllerTest.php deleted file mode 100644 index 51ab83c92c..0000000000 --- a/tests/controllers/JsonControllerTest.php +++ /dev/null @@ -1,228 +0,0 @@ - new Carbon, 'end' => new Carbon]]; - $this->be($bill->user); - - $bills = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - // mock! - $bills->shouldReceive('getActiveBills')->andReturn($collection); - $bills->shouldReceive('getRanges')->andReturn($ranges); - $bills->shouldReceive('getJournalsInRange')->andReturn(new Collection); - $bills->shouldReceive('billPaymentsInRange')->andReturn(12); - $accounts->shouldReceive('getCreditCards')->andReturn($ccs); - $accounts->shouldReceive('getTransfersInRange')->andReturn(new Collection); - Amount::shouldReceive('format')->andReturn('xx'); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - Steam::shouldReceive('balance')->andReturn(0); - - - $this->call('GET', '/json/box/bills-paid'); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\JsonController::boxBillsUnpaid - */ - public function testBoxBillsUnpaid() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $creditCard = FactoryMuffin::create('FireflyIII\Models\Account'); - $ccs = new Collection([$creditCard]); - $collection = new Collection([$bill]); - $ranges = [['start' => new Carbon, 'end' => new Carbon]]; - $this->be($bill->user); - - $bills = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - // mock! - $bills->shouldReceive('getActiveBills')->andReturn($collection); - $bills->shouldReceive('getRanges')->andReturn($ranges); - $bills->shouldReceive('getJournalsInRange')->andReturn(new Collection); - $bills->shouldReceive('createFakeBill')->andReturn($bill); - $accounts->shouldReceive('getCreditCards')->andReturn($ccs); - Amount::shouldReceive('format')->andReturn('xx'); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - Steam::shouldReceive('balance')->andReturn(-1); - - $this->call('GET', '/json/box/bills-unpaid'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\JsonController::boxIn - */ - public function testBoxIn() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $repository = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface'); - $repository->shouldReceive('incomeInPeriodCorrected')->andReturn(new Collection); - Amount::shouldReceive('format')->andReturn('xx'); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - $this->call('GET', '/json/box/in'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\JsonController::boxOut - */ - public function testBoxOut() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $repository = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface'); - $repository->shouldReceive('expenseInPeriodCorrected')->andReturn(new Collection); - Amount::shouldReceive('format')->andReturn('xx'); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - $this->call('GET', '/json/box/out'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\JsonController::categories - */ - public function testCategories() - { - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->be($category->user); - $categories = new Collection([$category]); - - $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - $repository->shouldReceive('getCategories')->andReturn($categories); - - $this->call('GET', '/json/categories'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\JsonController::expenseAccounts - */ - public function testExpenseAccounts() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $this->be($account->user); - $accounts = new Collection([$account]); - - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('getAccounts')->with(['Expense account', 'Beneficiary account'])->andReturn($accounts); - - $this->call('GET', '/json/expense-accounts'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\JsonController::revenueAccounts - */ - public function testRevenueAccounts() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $this->be($account->user); - $accounts = new Collection([$account]); - - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('getAccounts')->with(['Revenue account'])->andReturn($accounts); - - $this->call('GET', '/json/revenue-accounts'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\JsonController::tags - */ - public function testTags() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->user()->associate($user); - - $tag->save(); - $this->be($tag->user); - $tags = new Collection([$tag]); - - $repository = $this->mock('FireflyIII\Repositories\Tag\TagRepositoryInterface'); - $repository->shouldReceive('get')->andReturn($tags); - - $this->call('GET', '/json/tags'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\JsonController::transactionJournals - */ - public function testTransactionJournals() - { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $collection = new Collection([$journal]); - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); - $repository->shouldReceive('getTransactionType')->with('withdrawal')->andReturn($type); - $repository->shouldReceive('getJournalsOfType')->with($type)->andReturn($collection); - - - $this->call('GET', '/json/transaction-journals/withdrawal'); - $this->assertResponseOk(); - } - -} diff --git a/tests/controllers/NewUserControllerTest.php b/tests/controllers/NewUserControllerTest.php deleted file mode 100644 index 3016148bd8..0000000000 --- a/tests/controllers/NewUserControllerTest.php +++ /dev/null @@ -1,110 +0,0 @@ -mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - $this->be($user); - - // mock ALL THE THINGS! - $repository->shouldReceive('countAccounts')->once()->andReturn(0); - - // language preference: - $language = FactoryMuffin::create('FireflyIII\Models\Preference'); - $language->data = 'en'; - $language->save(); - Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); - - $lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference'); - $lastActivity->data = microtime(); - Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - $this->call('GET', '/new-user'); - $this->assertResponseStatus(200); - } - - public function testIndexNoAccounts() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - - $this->be($user); - - // mock ALL THE THINGS! - $repository->shouldReceive('countAccounts')->once()->andReturn(3); - - // language preference: - $language = FactoryMuffin::create('FireflyIII\Models\Preference'); - $language->data = 'en'; - $language->save(); - Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); - - $lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference'); - $lastActivity->data = microtime(); - Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); - - $this->call('GET', '/new-user'); - $this->assertResponseStatus(302); - $this->assertRedirectedToRoute('index'); - - } - - public function testPostIndex() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $this->be($user); - - $data = [ - '_token' => 'replaceMe', - 'bank_name' => 'Some Bank', - 'bank_balance' => '100', - 'balance_currency_id' => $currency->id, - 'savings_balance' => '100', - 'credit_card_limit' => '100', - - ]; - - $repository->shouldReceive('store')->andReturn($account); - - $this->call('POST', '/new-user/submit', $data); - $this->assertResponseStatus(302); - $this->assertRedirectedToRoute('index'); - - } - -} diff --git a/tests/controllers/PiggyBankControllerTest.php b/tests/controllers/PiggyBankControllerTest.php deleted file mode 100644 index 884943a5aa..0000000000 --- a/tests/controllers/PiggyBankControllerTest.php +++ /dev/null @@ -1,454 +0,0 @@ -be($piggyBank->account->user); - - - // mock - /** @var Mockery\MockInterface $repository */ - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('leftOnAccount')->withAnyArgs()->andReturn(12); - Amount::shouldReceive('format')->andReturn('XXxx'); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - $this->call('GET', '/piggy-banks/add/' . $piggyBank->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::create - */ - public function testCreate() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $collection = new Collection([$account]); - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // mock - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('getAccounts')->once()->with(['Default account', 'Asset account'])->andReturn($collection); - ExpandedForm::shouldReceive('makeSelectList')->with($collection)->andReturn([]); - - // also cover the view now that we've touched ExpandedForm: - ExpandedForm::shouldReceive('text')->andReturn(''); - ExpandedForm::shouldReceive('select')->andReturn(''); - ExpandedForm::shouldReceive('amount')->andReturn(''); - ExpandedForm::shouldReceive('date')->andReturn(''); - ExpandedForm::shouldReceive('checkbox')->andReturn(''); - ExpandedForm::shouldReceive('optionsList')->andReturn(''); - - $this->call('GET', '/piggy-banks/create'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::delete - */ - public function testDelete() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - - - $this->call('GET', '/piggy-banks/delete/' . $piggyBank->id); - $this->assertResponseOk(); - $this->assertViewHas('subTitle', 'Delete piggy bank "' . e($piggyBank->name) . '"'); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::destroy - */ - public function testDestroy() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - - $repository = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface'); - $repository->shouldReceive('destroy')->once()->withAnyArgs()->andReturn(true); - - - $this->call('POST', '/piggy-banks/destroy/' . $piggyBank->id, ['_token' => 'replaceMe']); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::edit - */ - public function testEdit() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $piggyBank->targetdate = Carbon::now()->addYear(); - $piggyBank->save(); - $this->be($piggyBank->account->user); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $collection = new Collection([$account]); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('getAccounts')->once()->with(['Default account', 'Asset account'])->andReturn($collection); - ExpandedForm::shouldReceive('makeSelectList')->with($collection)->andReturn([]); - - // also cover the view now that we've touched ExpandedForm: - ExpandedForm::shouldReceive('text')->andReturn(''); - ExpandedForm::shouldReceive('select')->andReturn(''); - ExpandedForm::shouldReceive('amount')->andReturn(''); - ExpandedForm::shouldReceive('date')->andReturn(''); - ExpandedForm::shouldReceive('checkbox')->andReturn(''); - ExpandedForm::shouldReceive('optionsList')->andReturn(''); - - - $this->call('GET', '/piggy-banks/edit/' . $piggyBank->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::edit - */ - public function testEditNullDate() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - $piggyBank->targetdate = null; - $piggyBank->save(); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $collection = new Collection([$account]); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $repository->shouldReceive('getAccounts')->once()->with(['Default account', 'Asset account'])->andReturn($collection); - ExpandedForm::shouldReceive('makeSelectList')->with($collection)->andReturn([]); - - // also cover the view now that we've touched ExpandedForm: - ExpandedForm::shouldReceive('text')->andReturn(''); - ExpandedForm::shouldReceive('select')->andReturn(''); - ExpandedForm::shouldReceive('amount')->andReturn(''); - ExpandedForm::shouldReceive('date')->andReturn(''); - ExpandedForm::shouldReceive('checkbox')->andReturn(''); - ExpandedForm::shouldReceive('optionsList')->andReturn(''); - - - $this->call('GET', '/piggy-banks/edit/' . $piggyBank->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::index - */ - public function testIndex() - { - $piggyBank1 = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $piggyBank2 = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $piggyBank3 = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $piggyBank2->account_id = $piggyBank1->account_id; - $user = FactoryMuffin::create('FireflyIII\User'); - - $piggyBank2->save(); - - $collection = new Collection([$piggyBank1, $piggyBank2, $piggyBank3]); - $this->be($user); - - // mock! - $accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface'); - - // act! - $piggyBanks->shouldReceive('getPiggyBanks')->once()->andReturn($collection); - Steam::shouldReceive('balance')->andReturn(20); - $accounts->shouldReceive('leftOnAccount')->andReturn(12); - Amount::shouldReceive('format')->andReturn('123'); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - - $this->call('GET', '/piggy-banks'); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::order - */ - public function testOrder() - { - $piggyBank1 = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $piggyBank2 = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // mock! - $piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface'); - $piggyBanks->shouldReceive('reset')->once(); - $piggyBanks->shouldReceive('setOrder'); - $array = [ - $piggyBank1->id => 0, - $piggyBank2->id => 1, - ]; - - $this->call('POST', '/piggy-banks/sort', ['_token' => 'replaceMe', 'order' => $array]); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::postAdd - */ - public function testPostAdd() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - - // mock! - $accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface'); - $accounts->shouldReceive('leftOnAccount')->andReturn(20); - $piggyBanks->shouldReceive('createEvent')->once(); - - Amount::shouldReceive('format')->andReturn('something'); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - $this->call('POST', '/piggy-banks/add/' . $piggyBank->id, ['_token' => 'replaceMe']); - $this->assertResponseStatus(302); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::postAdd - */ - public function testPostAddOverdraw() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - - // mock! - $accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $accounts->shouldReceive('leftOnAccount')->andReturn(20); - - Amount::shouldReceive('format')->andReturn('something'); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - $this->call('POST', '/piggy-banks/add/' . $piggyBank->id, ['_token' => 'replaceMe', 'amount' => '10000']); - $this->assertResponseStatus(302); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::postRemove - */ - public function testPostRemove() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - - // mock! - $accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface'); - $accounts->shouldReceive('leftOnAccount')->andReturn(20); - $piggyBanks->shouldReceive('createEvent')->once(); - - Amount::shouldReceive('format')->andReturn('something'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('something'); - - $this->call('POST', '/piggy-banks/remove/' . $piggyBank->id, ['_token' => 'replaceMe']); - $this->assertResponseStatus(302); - } - - public function testPostRemoveOverdraw() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - - // mock! - $accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $accounts->shouldReceive('leftOnAccount')->andReturn(20); - - Amount::shouldReceive('format')->andReturn('something'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('something'); - - $this->call('POST', '/piggy-banks/remove/' . $piggyBank->id, ['_token' => 'replaceMe', 'amount' => '10000']); - $this->assertResponseStatus(302); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::remove - */ - public function testRemove() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - - Amount::shouldReceive('format')->andReturn('something'); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - - $this->call('GET', '/piggy-banks/remove/' . $piggyBank->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::show - */ - public function testShow() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - - $piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface'); - $piggyBanks->shouldReceive('getEvents')->andReturn(new Collection); - Amount::shouldReceive('format')->andReturn('something'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('something'); - Amount::shouldReceive('getCurrencyCode')->andReturn('something'); - - - $this->call('GET', '/piggy-banks/show/' . $piggyBank->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::store - */ - public function testStore() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - - $piggyBankData = [ - 'name' => 'Some name' . rand(1, 100), - 'account_id' => $piggyBank->account_id, - 'targetamount' => 100, - 'targetdate' => '', - '_token' => 'replaceMe' - ]; - - // mock! - $piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface'); - $piggyBanks->shouldReceive('store')->once()->andReturn($piggyBank); - - $this->call('POST', '/piggy-banks/store', $piggyBankData); - $this->assertResponseStatus(302); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::store - */ - public function testStoreCreateAnother() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - - $piggyBankData = [ - 'name' => 'Some name' . rand(1, 100), - 'account_id' => $piggyBank->account_id, - 'targetamount' => 100, - 'targetdate' => '', - 'create_another' => 1, - '_token' => 'replaceMe' - ]; - - // mock! - $piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface'); - $piggyBanks->shouldReceive('store')->once()->andReturn($piggyBank); - - $this->call('POST', '/piggy-banks/store', $piggyBankData); - $this->assertResponseStatus(302); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::update - */ - public function testUpdate() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - - $piggyBankData = [ - 'name' => 'Some name' . rand(1, 100), - 'account_id' => $piggyBank->account_id, - 'targetamount' => 200, - 'targetdate' => '', - '_token' => 'replaceMe' - ]; - - // mock! - $piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface'); - $piggyBanks->shouldReceive('update')->once()->andReturn($piggyBank); - - $this->call('POST', '/piggy-banks/update/' . $piggyBank->id, $piggyBankData); - $this->assertResponseStatus(302); - } - - /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::update - */ - public function testUpdateReturnToEdit() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - - $piggyBankData = [ - 'name' => 'Some name' . rand(1, 100), - 'account_id' => $piggyBank->account_id, - 'targetamount' => 200, - 'targetdate' => '', - 'return_to_edit' => 1, - '_token' => 'replaceMe' - ]; - - // mock! - $piggyBanks = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface'); - $piggyBanks->shouldReceive('update')->once()->andReturn($piggyBank); - - $this->call('POST', '/piggy-banks/update/' . $piggyBank->id, $piggyBankData); - $this->assertResponseStatus(302); - } -} diff --git a/tests/controllers/PreferencesControllerTest.php b/tests/controllers/PreferencesControllerTest.php deleted file mode 100644 index 7631aa2ea8..0000000000 --- a/tests/controllers/PreferencesControllerTest.php +++ /dev/null @@ -1,121 +0,0 @@ -be($user); - - - // mock: - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - // fake! - $repository->shouldReceive('getAccounts')->with(['Default account', 'Asset account'])->andReturn(new Collection); - Preferences::shouldReceive('get')->once()->withArgs(['viewRange', '1M'])->andReturn($pref); - Preferences::shouldReceive('get')->once()->withArgs(['frontPageAccounts', []])->andReturn($pref); - Preferences::shouldReceive('get')->once()->withArgs(['budgetMaximum', 1000])->andReturn($pref); - Preferences::shouldReceive('get')->withArgs(['currencyPreference', 'EUR'])->andReturn($pref); - Amount::shouldReceive('format')->andReturn('xx'); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - Amount::shouldReceive('getAllCurrencies')->andReturn(new Collection); - Amount::shouldReceive('getDefaultCurrency')->andReturn($currency); - - $lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference'); - $lastActivity->data = microtime(); - Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); - - // language preference: - $language = FactoryMuffin::create('FireflyIII\Models\Preference'); - $language->data = 'en'; - $language->save(); - Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); - - $this->call('GET', '/preferences'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\PreferencesController::postIndex - */ - public function testPostIndex() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $data = [ - 'frontPageAccounts' => [1, 2, 3], - '_token' => 'replaceMe', - 'viewRange' => '1M', - 'language' => 'en', - ]; - - // language preference: - $language = FactoryMuffin::create('FireflyIII\Models\Preference'); - $language->data = 'en'; - $language->save(); - Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); - - Preferences::shouldReceive('set')->once()->withArgs(['frontPageAccounts', [1, 2, 3]]); - Preferences::shouldReceive('set')->once()->withArgs(['viewRange', '1M']); - Preferences::shouldReceive('set')->once()->withArgs(['budgetMaximum', 0]); - Preferences::shouldReceive('set')->once()->withArgs(['language', 'en']); - Preferences::shouldReceive('mark')->once()->andReturn(true); - - // language preference: - $language = FactoryMuffin::create('FireflyIII\Models\Preference'); - $language->data = 'en'; - $language->save(); - Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); - - $lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference'); - $lastActivity->data = microtime(); - Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); - - - $this->call('POST', '/preferences', $data); - $this->assertResponseStatus(302); - } -} diff --git a/tests/controllers/ProfileControllerTest.php b/tests/controllers/ProfileControllerTest.php deleted file mode 100644 index ff08eef3a2..0000000000 --- a/tests/controllers/ProfileControllerTest.php +++ /dev/null @@ -1,195 +0,0 @@ -be($user); - - $this->call('GET', '/profile/change-password'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\ProfileController::deleteAccount - */ - public function testDeleteAccount() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $this->call('GET', '/profile/delete-account'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\ProfileController::index - */ - public function testIndex() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $this->call('GET', '/profile'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\ProfileController::postChangePassword - * @covers FireflyIII\Http\Controllers\ProfileController::validatePassword - */ - public function testPostChangePassword() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $user->password = bcrypt('current'); - $user->save(); - $this->be($user); - - $post = [ - 'current_password' => 'current', - 'new_password' => 'something', - 'new_password_confirmation' => 'something', - '_token' => 'replaceMe' - ]; - - $this->call('POST', '/profile/change-password', $post); - - $this->assertRedirectedToRoute('profile'); - $this->assertSessionHas('success', 'Password changed!'); - $this->assertResponseStatus(302); - - } - - /** - * @covers FireflyIII\Http\Controllers\ProfileController::postChangePassword - * @covers FireflyIII\Http\Controllers\ProfileController::validatePassword - */ - public function testPostChangePasswordInvalidCurrent() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $post = [ - 'current_password' => 'currentWrong', - 'new_password' => 'something', - 'new_password_confirmation' => 'something', - '_token' => 'replaceMe' - ]; - - $this->call('POST', '/profile/change-password', $post); - - $this->assertRedirectedToRoute('profile.change-password'); - $this->assertSessionHas('error', 'Invalid current password!'); - $this->assertResponseStatus(302); - - } - - /** - * @covers FireflyIII\Http\Controllers\ProfileController::postChangePassword - * @covers FireflyIII\Http\Controllers\ProfileController::validatePassword - */ - public function testPostChangePasswordNoNewPassword() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $user->password = bcrypt('current'); - $user->save(); - $this->be($user); - - $post = [ - 'current_password' => 'current', - 'new_password' => 'current', - 'new_password_confirmation' => 'current', - '_token' => 'replaceMe' - ]; - - $this->call('POST', '/profile/change-password', $post); - - $this->assertSessionHas('error', 'The idea is to change your password.'); - $this->assertResponseStatus(302); - $this->assertRedirectedToRoute('profile.change-password'); - - - } - - /** - * @covers FireflyIII\Http\Controllers\ProfileController::postDeleteAccount - */ - public function testPostDeleteAccount() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $user->password = bcrypt('current'); - $user->save(); - $this->be($user); - - $post = [ - 'password' => 'current', - '_token' => 'replaceMe' - ]; - - $this->call('POST', '/profile/delete-account', $post); - - $this->assertRedirectedToRoute('index'); - $this->assertResponseStatus(302); - - } - - /** - * @covers FireflyIII\Http\Controllers\ProfileController::postDeleteAccount - */ - public function testPostDeleteAccountInvalidPassword() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $user->password = bcrypt('current'); - $user->save(); - $this->be($user); - - $post = [ - 'password' => 'currentXX', - '_token' => 'replaceMe' - ]; - - $this->call('POST', '/profile/delete-account', $post); - - $this->assertRedirectedToRoute('profile.delete-account'); - $this->assertSessionHas('error', 'Invalid password!'); - $this->assertResponseStatus(302); - - } - -} diff --git a/tests/controllers/ReportControllerTest.php b/tests/controllers/ReportControllerTest.php deleted file mode 100644 index 51791cf341..0000000000 --- a/tests/controllers/ReportControllerTest.php +++ /dev/null @@ -1,172 +0,0 @@ -be($user); - - // mock stuff - $helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface'); - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - - // make shared: - AccountMeta::create( - [ - 'account_id' => $account->id, - 'name' => 'accountRole', - 'data' => 'sharedAsset' - ] - ); - - $helper->shouldReceive('listOfMonths')->andReturn([]); - $helper->shouldReceive('listOfYears')->andReturn([]); - $repository->shouldReceive('getAccounts')->andReturn(new Collection([$account])); - - - $this->call('GET', '/reports'); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\ReportController::month - */ - public function testMonth() - { - $user = FactoryMuffin::create('FireflyIII\User'); - FactoryMuffin::create('FireflyIII\Models\Account'); - $budget1 = FactoryMuffin::create('FireflyIII\Models\Budget'); - $budget1->queryAmount = 12; - $budget2 = FactoryMuffin::create('FireflyIII\Models\Budget'); - $budget2->queryAmount = 0; - $this->be($user); - - // mock! - $helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface'); - - // fake! - $helper->shouldReceive('getAccountReport')->andReturn(new Collection); - $helper->shouldReceive('getIncomeReport')->andReturn(new Collection); - $helper->shouldReceive('getExpenseReport')->andReturn(new Collection); - $helper->shouldReceive('getBudgetReport')->andReturn(new Collection); - $helper->shouldReceive('getCategoryReport')->andReturn(new Collection); - $helper->shouldReceive('getBalanceReport')->andReturn(new Collection); - $helper->shouldReceive('getBillReport')->andReturn(new Collection); - - - $this->call('GET', '/reports/2015/1'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\ReportController::month - */ - public function testMonthShared() - { - $user = FactoryMuffin::create('FireflyIII\User'); - FactoryMuffin::create('FireflyIII\Models\Account'); - $budget1 = FactoryMuffin::create('FireflyIII\Models\Budget'); - $budget1->queryAmount = 12; - $budget2 = FactoryMuffin::create('FireflyIII\Models\Budget'); - $budget2->queryAmount = 0; - $this->be($user); - - // mock! - $helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface'); - - // fake! - $helper->shouldReceive('getAccountReport')->andReturn(new Collection); - $helper->shouldReceive('getIncomeReport')->andReturn(new Collection); - $helper->shouldReceive('getExpenseReport')->andReturn(new Collection); - $helper->shouldReceive('getBudgetReport')->andReturn(new Collection); - $helper->shouldReceive('getCategoryReport')->andReturn(new Collection); - $helper->shouldReceive('getBalanceReport')->andReturn(new Collection); - $helper->shouldReceive('getBillReport')->andReturn(new Collection); - - $this->call('GET', '/reports/2015/1/shared'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\ReportController::year - */ - public function testYear() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - - // make shared: - AccountMeta::create( - [ - 'account_id' => $account->id, - 'name' => 'accountRole', - 'data' => 'sharedAsset' - ] - ); - new Collection([$journal]); - - $this->be($user); - - $helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface'); - - - $helper->shouldReceive('getAccountReport')->once()->withAnyArgs()->andReturn([]); - $helper->shouldReceive('getIncomeReport')->once()->withAnyArgs()->andReturn([]); - $helper->shouldReceive('getExpenseReport')->once()->withAnyArgs()->andReturn([]); - - // mock stuff! - Amount::shouldReceive('getDefaultCurrency')->andReturn($currency); - Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - Amount::shouldReceive('format')->andReturn('X'); - - $this->call('GET', '/reports/2015/shared'); - $this->assertResponseOk(); - } - - -} diff --git a/tests/controllers/SearchControllerTest.php b/tests/controllers/SearchControllerTest.php deleted file mode 100644 index 33ac7f9f36..0000000000 --- a/tests/controllers/SearchControllerTest.php +++ /dev/null @@ -1,58 +0,0 @@ -be($user); - $words = ['Something']; - // mock! - $repository = $this->mock('FireflyIII\Support\Search\SearchInterface'); - $repository->shouldReceive('searchTransactions')->with($words)->once()->andReturn([]); - $repository->shouldReceive('searchAccounts')->with($words)->once()->andReturn([]); - $repository->shouldReceive('searchCategories')->with($words)->once()->andReturn([]); - $repository->shouldReceive('searchBudgets')->with($words)->once()->andReturn([]); - $repository->shouldReceive('searchTags')->with($words)->once()->andReturn([]); - - $this->call('GET', '/search?q=Something'); - $this->assertResponseOk(); - } -} diff --git a/tests/controllers/TagControllerTest.php b/tests/controllers/TagControllerTest.php deleted file mode 100644 index 9b6a29df69..0000000000 --- a/tests/controllers/TagControllerTest.php +++ /dev/null @@ -1,296 +0,0 @@ -be($user); - - $this->call('GET', '/tags/create'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TagController::delete - */ - public function testDelete() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $this->be($tag->user); - - $this->call('GET', '/tags/delete/' . $tag->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TagController::destroy - */ - public function testDestroy() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $this->be($tag->user); - - $this->call('POST', '/tags/destroy/' . $tag->id, ['_token' => 'replaceMe']); - $this->assertSessionHas('success'); - $this->assertResponseStatus(302); - - } - - /** - * @covers FireflyIII\Http\Controllers\TagController::edit - */ - public function testEdit() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $this->be($tag->user); - - $this->call('GET', '/tags/edit/' . $tag->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TagController::edit - */ - public function testEditBalancingAct() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $type->type = 'Transfer'; - $type->save(); - $journal->transactionType()->associate($type); - $journal->save(); - $tag->transactionJournals()->save($journal); - $tag->tagMode = 'balancingAct'; - $tag->save(); - $this->be($tag->user); - - $this->call('GET', '/tags/edit/' . $tag->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TagController::edit - */ - public function testEditThreeExpenses() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $type->type = 'Withdrawal'; - $type->save(); - - for ($i = 0; $i < 3; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->transactionType()->associate($type); - $journal->save(); - $tag->transactionJournals()->save($journal); - } - - - $tag->tagMode = 'nothing'; - $tag->save(); - $this->be($tag->user); - - $this->call('GET', '/tags/edit/' . $tag->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TagController::hideTagHelp - */ - public function testHideTagHelp() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $this->be($tag->user); - - $this->call('POST', '/tags/hideTagHelp/true', ['_token' => 'replaceMe']); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TagController::index - */ - public function testIndex() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $this->be($tag->user); - - $this->call('GET', '/tags'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TagController::edit - */ - public function testMultipleDeposits() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - for ($i = 0; $i < 3; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->transaction_type_id = $type->id; - $journal->save(); - $tag->transactionJournals()->save($journal); - } - - - $tag->tagMode = 'nothing'; - $tag->save(); - $this->be($tag->user); - - $this->call('GET', '/tags/edit/' . $tag->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TagController::show - */ - public function testShow() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $this->be($tag->user); - - $this->call('GET', '/tags/show/' . $tag->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TagController::store - */ - public function testStore() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $data = [ - '_token' => 'replaceMe', - 'tag' => 'BlaBla' . rand(1, 1000), - 'tagMode' => 'nothing' - ]; - - $this->call('POST', '/tags/store/', $data); - $this->assertResponseStatus(302); - } - - /** - * @covers FireflyIII\Http\Controllers\TagController::store - */ - public function testStoreWithLocation() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $data = [ - '_token' => 'replaceMe', - 'tag' => 'BlaBla' . rand(1, 1000), - 'tagMode' => 'nothing', - 'latitude' => 12, - 'longitude' => 13, - 'zoomLevel' => 3, - 'setTag' => 'true', - 'create_another' => 1, - ]; - - $this->call('POST', '/tags/store/', $data); - $this->assertResponseStatus(302); - } - - public function testUpdate() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $this->be($tag->user); - - $data = [ - '_token' => 'replaceMe', - 'tag' => 'BlaBla' . rand(1, 1000), - 'tagMode' => 'nothing', - 'id' => $tag->id, - ]; - - $this->call('POST', '/tags/update/' . $tag->id, $data); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - } - - public function testUpdateNoNameChange() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $this->be($tag->user); - - $data = [ - '_token' => 'replaceMe', - 'tag' => $tag->tag, - 'tagMode' => 'nothing', - 'id' => $tag->id, - ]; - - $this->call('POST', '/tags/update/' . $tag->id, $data); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - } - - /** - * @covers FireflyIII\Http\Controllers\TagController::update - */ - public function testUpdateWithLocation() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $this->be($tag->user); - - $data = [ - '_token' => 'replaceMe', - 'tag' => 'BlaBla' . rand(1, 1000), - 'tagMode' => 'nothing', - 'id' => $tag->id, - 'latitude' => 12, - 'setTag' => 'true', - 'longitude' => 13, - 'zoomLevel' => 3, - 'return_to_edit' => 1, - ]; - - $this->call('POST', '/tags/update/' . $tag->id, $data); - $this->assertResponseStatus(302); - } - - -} diff --git a/tests/controllers/TransactionControllerTest.php b/tests/controllers/TransactionControllerTest.php deleted file mode 100644 index 814457fe6b..0000000000 --- a/tests/controllers/TransactionControllerTest.php +++ /dev/null @@ -1,598 +0,0 @@ -be($user); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - - // fake! - $repository->shouldReceive('getAccounts')->andReturn(new Collection); - - - $this->call('GET', '/transactions/create/withdrawal?account_id=12'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TransactionController::delete - */ - public function testDelete() - { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $this->be($journal->user); - - $this->call('GET', '/transaction/delete/' . $journal->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TransactionController::destroy - */ - public function testDestroy() - { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $this->be($journal->user); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); - - // fake! - $repository->shouldReceive('delete')->andReturn(true); - - $this->call('POST', '/transaction/destroy/' . $journal->id, ['_token' => 'replaceMe']); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - - } - - /** - * @covers FireflyIII\Http\Controllers\TransactionController::edit - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testEdit() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - // make complete journal: - $accountType = FactoryMuffin::create('FireflyIII\Models\AccountType'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $transaction1 = FactoryMuffin::create('FireflyIII\Models\Transaction'); - $transaction2 = FactoryMuffin::create('FireflyIII\Models\Transaction'); - - $accountType->type = 'Asset account'; - $account->account_type_id = $accountType->id; - - $account->save(); - $transaction1->account_id = $account->id; - $transaction1->transaction_journal_id = $journal->id; - $transaction1->save(); - - $transaction2->account_id = $account->id; - $transaction2->transaction_journal_id = $journal->id; - $transaction2->save(); - - // also add some tags: - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->transactionJournals()->save($journal); - - // and a category and a budget: - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $category->transactionJournals()->save($journal); - $budget->transactionJournals()->save($journal); - - // and a piggy bank event: - $pbEvent = FactoryMuffin::create('FireflyIII\Models\PiggyBankEvent'); - $pbEvent->transaction_journal_id = $journal->id; - $pbEvent->save(); - - $this->be($journal->user); - - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - - // fake! - $repository->shouldReceive('getAccounts')->andReturn(new Collection); - - $this->call('GET', '/transaction/edit/' . $journal->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TransactionController::edit - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testEditCashDestination() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - // make complete journal: - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - //$expense = FactoryMuffin::create('FireflyIII\Models\Account'); // expense account - //$revenue = FactoryMuffin::create('FireflyIII\Models\Account'); // revenue account - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); // asset account - $cash = FactoryMuffin::create('FireflyIII\Models\Account'); // cash account - - $journal->transactions[0]->account_id = $asset->id; - $journal->transactions[0]->amount = -300; - $journal->transactions[0]->save(); - - $journal->transactions[0]->account_id = $cash->id; - $journal->transactions[0]->amount = 300; - $journal->transactions[0]->save(); - - $this->be($journal->user); - // mock! - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - // fake! - $repository->shouldReceive('getAccounts')->andReturn(new Collection); - - $this->call('GET', '/transaction/edit/' . $journal->id); - - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TransactionController::edit - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testEditDeposit() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - // make complete journal: - $accountType = FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $transaction1 = FactoryMuffin::create('FireflyIII\Models\Transaction'); - $transaction2 = FactoryMuffin::create('FireflyIII\Models\Transaction'); - - $accountType->type = 'Asset account'; - $account->account_type_id = $accountType->id; - - $account->save(); - $transaction1->account_id = $account->id; - $transaction1->transaction_journal_id = $journal->id; - $transaction1->save(); - - $transaction2->account_id = $account->id; - $transaction2->transaction_journal_id = $journal->id; - $transaction2->save(); - - // also add some tags: - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->transactionJournals()->save($journal); - - // and a category and a budget: - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $category->transactionJournals()->save($journal); - $budget->transactionJournals()->save($journal); - - // and a piggy bank event: - $pbEvent = FactoryMuffin::create('FireflyIII\Models\PiggyBankEvent'); - $pbEvent->transaction_journal_id = $journal->id; - $pbEvent->save(); - - $this->be($journal->user); - - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - - // fake! - $repository->shouldReceive('getAccounts')->andReturn(new Collection); - - $this->call('GET', '/transaction/edit/' . $journal->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TransactionController::index - */ - public function testIndexRevenue() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); - - // fake! - $repository->shouldReceive('getJournalsOfTypes')->withArgs([['Deposit'], 0, 0])->andReturn(new LengthAwarePaginator(new Collection, 0, 50)); - - $this->call('GET', '/transactions/deposit'); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\TransactionController::index - */ - public function testIndexTransfer() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); - - // fake! - $repository->shouldReceive('getJournalsOfTypes')->withArgs([['Transfer'], 0, 0])->andReturn(new LengthAwarePaginator(new Collection, 0, 50)); - - $this->call('GET', '/transactions/transfers'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TransactionController::index - */ - public function testIndexWithdrawal() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); - - // fake! - $repository->shouldReceive('getJournalsOfTypes')->withArgs([['Withdrawal'], 0, 0])->andReturn(new LengthAwarePaginator(new Collection, 0, 50)); - - $this->call('GET', '/transactions/withdrawal'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TransactionController::reorder - */ - public function testReorder() - { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $this->be($journal->user); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); - - // fake! - $repository->shouldReceive('getWithDate')->withAnyArgs()->andReturn($journal); - - $data = [ - 'items' => [$journal->id], - 'date' => $journal->date->format('Y-m-d'), - '_token' => 'replaceMe' - ]; - - $this->call('POST', '/transaction/reorder', $data); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\TransactionController::show - */ - public function testShow() - { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $transaction1 = FactoryMuffin::create('FireflyIII\Models\Transaction'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $transaction1->transaction_journal_id = $journal->id; - $transaction1->save(); - $this->be($journal->user); - - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); - - // fake! - $repository->shouldReceive('getAmountBefore')->withAnyArgs()->andReturn(5); - Amount::shouldReceive('getDefaultCurrency')->andReturn($currency); - Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]); - Amount::shouldReceive('getCurrencyCode')->andReturn('X'); - Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); - Amount::shouldReceive('formatTransaction')->andReturn('X'); - Amount::shouldReceive('format')->andReturn('X'); - - - $this->call('GET', '/transaction/show/' . $journal->id); - $this->assertResponseOk(); - } - - /** - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @covers FireflyIII\Http\Controllers\TransactionController::store - */ - public function testStore() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $this->be($account->user); - - $data = [ - 'what' => 'withdrawal', - 'description' => 'Bla bla bla', - 'account_id' => $account->id, - 'expense_account' => 'Bla bla', - 'amount' => '100', - 'amount_currency_id' => $currency->id, - 'date' => '2015-05-05', - 'budget_id' => '0', - 'category' => '', - 'tags' => 'fat-test', - 'piggy_bank_id' => '0', - '_token' => 'replaceMe', - ]; - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); - - // fake! - $repository->shouldReceive('store')->andReturn($journal); - - - $this->call('POST', '/transactions/store/withdrawal', $data); - - //$this->assertSessionHas('errors','bla'); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - - } - - /** - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @covers FireflyIII\Http\Controllers\TransactionController::store - */ - public function testStoreCreateAnother() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $this->be($account->user); - - $data = [ - 'what' => 'withdrawal', - 'description' => 'Bla bla bla', - 'account_id' => $account->id, - 'expense_account' => 'Bla bla', - 'amount' => '100', - 'amount_currency_id' => $currency->id, - 'date' => '2015-05-05', - 'budget_id' => '0', - 'create_another' => '1', - 'category' => '', - 'tags' => 'fat-test', - 'piggy_bank_id' => '0', - '_token' => 'replaceMe', - ]; - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); - - // fake! - $repository->shouldReceive('store')->andReturn($journal); - - - $this->call('POST', '/transactions/store/withdrawal', $data); - - //$this->assertSessionHas('errors','bla'); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - - } - - /** - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @covers FireflyIII\Http\Controllers\TransactionController::store - */ - public function testStoreTransfer() - { - // account types: - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - - $piggy = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $this->be($account->user); - - $account2->user_id = $account->user_id; - $account->account_type_id = $asset->id; - $account2->account_type_id = $asset->id; - $piggy->account_id = $account->id; - $account->save(); - $account2->save(); - $piggy->save(); - - $data = [ - 'what' => 'transfer', - 'description' => 'Bla bla bla', - 'account_from_id' => $account->id, - 'account_to_id' => $account2->id, - 'amount' => '100', - 'amount_currency_id' => $currency->id, - 'date' => '2015-05-05', - 'budget_id' => '0', - 'create_another' => '1', - 'category' => '', - 'tags' => 'fat-test', - 'piggy_bank_id' => $piggy->id, - '_token' => 'replaceMe', - ]; - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); - - // fake! - $repository->shouldReceive('store')->andReturn($journal); - - - $this->call('POST', '/transactions/store/withdrawal', $data); - - //$this->assertSessionHas('errors','bla'); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - - } - - /** - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @covers FireflyIII\Http\Controllers\TransactionController::update - */ - public function testUpdate() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $this->be($journal->user); - $account->user_id = $journal->user_id; - $account->save(); - - $data = [ - '_token' => 'replaceMe', - 'id' => $journal->id, - 'what' => 'withdrawal', - 'description' => 'LunchX', - 'account_id' => $account->id, - 'expense_account' => 'Lunch House', - 'amount' => '4.72', - 'amount_currency_id' => $currency->id, - 'date' => '2015-05-31', - 'budget_id' => '0', - 'category' => 'Lunch', - 'tags' => 'fat-test', - 'piggy_bank_id' => '0', - ]; - - $this->call('POST', '/transactions/store/withdrawal', $data); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); - - // fake! - $repository->shouldReceive('update')->andReturn($journal); - - - $this->call('POST', '/transaction/update/' . $journal->id, $data); - //$this->assertSessionHas('errors','bla'); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - - - } - - /** - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @covers FireflyIII\Http\Controllers\TransactionController::update - */ - public function testUpdateWithRedirect() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $this->be($journal->user); - $account->user_id = $journal->user_id; - $account->save(); - - $data = [ - '_token' => 'replaceMe', - 'id' => $journal->id, - 'what' => 'withdrawal', - 'description' => 'LunchX', - 'account_id' => $account->id, - 'expense_account' => 'Lunch House', - 'amount' => '4.72', - 'amount_currency_id' => $currency->id, - 'date' => '2015-05-31', - 'budget_id' => '0', - 'category' => 'Lunch', - 'return_to_edit' => 1, - 'tags' => 'fat-test', - 'piggy_bank_id' => '0', - ]; - - $this->call('POST', '/transactions/store/withdrawal', $data); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); - - // fake! - $repository->shouldReceive('update')->andReturn($journal); - - - $this->call('POST', '/transaction/update/' . $journal->id, $data); - //$this->assertSessionHas('errors','bla'); - $this->assertResponseStatus(302); - $this->assertSessionHas('success'); - - - } - -} diff --git a/tests/controllers/charts/ChartAccountControllerTest.php b/tests/controllers/charts/ChartAccountControllerTest.php deleted file mode 100644 index 8f41214040..0000000000 --- a/tests/controllers/charts/ChartAccountControllerTest.php +++ /dev/null @@ -1,134 +0,0 @@ -account_type_id = $asset->id; - $two->account_type_id = $asset->id; - $one->save(); - $two->save(); - $accounts = new Collection([$one, $two]); - $date = new Carbon; - $this->be($user); - - // make one shared: - AccountMeta::create( - [ - 'account_id' => $one->id, - 'name' => 'accountRole', - 'data' => 'sharedAsset' - ] - ); - - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - // fake! - $repository->shouldReceive('getAccounts')->once()->andReturn($accounts); - - $this->call('GET', '/chart/account/month/' . $date->format('Y/m')); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\AccountController::all - */ - public function testAllShared() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $accounts = new Collection([$account]); - $date = new Carbon; - $this->be($user); - - // make it shared: - AccountMeta::create( - [ - 'account_id' => $account->id, - 'name' => 'accountRole', - 'data' => 'sharedAsset' - ] - ); - - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - // fake! - $repository->shouldReceive('getAccounts')->once()->andReturn($accounts); - - - $this->call('GET', '/chart/account/month/' . $date->format('Y/m') . '/shared'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\AccountController::frontpage - */ - public function testFrontpage() - { - $accounts = new Collection([FactoryMuffin::create('FireflyIII\Models\Account')]); - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - // fake! - $repository->shouldReceive('getFrontpageAccounts')->andReturn($accounts); - - $this->call('GET', '/chart/account/frontpage'); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\AccountController::single - */ - public function testSingle() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $this->be($account->user); - - $this->call('GET', '/chart/account/' . $account->id); - $this->assertResponseOk(); - - } -} diff --git a/tests/controllers/charts/ChartBillControllerTest.php b/tests/controllers/charts/ChartBillControllerTest.php deleted file mode 100644 index b7f3ec3f9d..0000000000 --- a/tests/controllers/charts/ChartBillControllerTest.php +++ /dev/null @@ -1,100 +0,0 @@ -be($user); - - - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\BillController::frontpage - */ - public function testFrontpage() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // set! - $bills = new Collection([FactoryMuffin::create('FireflyIII\Models\Bill'), FactoryMuffin::create('FireflyIII\Models\Bill')]); - $journals = new Collection( - [FactoryMuffin::create('FireflyIII\Models\TransactionJournal'), FactoryMuffin::create('FireflyIII\Models\TransactionJournal')] - ); - $creditCards = new Collection([FactoryMuffin::create('FireflyIII\Models\Account'), FactoryMuffin::create('FireflyIII\Models\Account')]); - $ranges = [['start' => new Carbon, 'end' => new Carbon]]; - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); - - - // fake! - $repository->shouldReceive('getActiveBills')->andReturn($bills); - $repository->shouldReceive('getRanges')->andReturn($ranges); - $repository->shouldReceive('getJournalsInRange')->andReturn(new Collection, $journals); - $accounts->shouldReceive('getCreditCards')->andReturn($creditCards); - $accounts->shouldReceive('getTransfersInRange')->andReturn(new Collection); - $repository->shouldReceive('createFakeBill')->andReturn($bills->first()); - Steam::shouldReceive('balance')->andReturn(-10, 0); - - $lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference'); - $lastActivity->data = microtime(); - Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); - - $language = FactoryMuffin::create('FireflyIII\Models\Preference'); - $language->data = 'en'; - Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($language); - - - $this->call('GET', '/chart/bill/frontpage'); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\BillController::single - */ - public function testSingle() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $this->be($bill->user); - - // set - $journals = new Collection([FactoryMuffin::create('FireflyIII\Models\TransactionJournal')]); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $repository->shouldReceive('getJournals')->andReturn($journals); - - // fake! - - $this->call('GET', '/chart/bill/' . $bill->id); - $this->assertResponseOk(); - - } - - -} diff --git a/tests/controllers/charts/ChartBudgetControllerTest.php b/tests/controllers/charts/ChartBudgetControllerTest.php deleted file mode 100644 index 4670313328..0000000000 --- a/tests/controllers/charts/ChartBudgetControllerTest.php +++ /dev/null @@ -1,164 +0,0 @@ -be($budget->user); - - $this->call('GET', '/chart/budget/' . $budget->id); - $this->assertResponseOk(); - - - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\BudgetController::budgetLimit - */ - public function testBudgetLimit() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - /** @var \FireflyIII\Models\BudgetLimit $limit */ - $limit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit'); - /** @var \FireflyIII\Models\LimitRepetition $repetition */ - $repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); - - $start = Carbon::now()->startOfMonth(); - $end = Carbon::now()->endOfMonth(); - - $budget->user_id = $user->id; - $limit->budget_id = $budget->id; - $limit->startdate = $start; - $repetition->budget_limit_id = $limit->id; - $repetition->startdate = $start; - $repetition->enddate = $end; - - $budget->save(); - $limit->save(); - $repetition->save(); - - - $this->be($user); - - $this->call('GET', '/chart/budget/' . $budget->id . '/' . $repetition->id); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\BudgetController::frontpage - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testFrontpage() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $start = Carbon::now()->startOfMonth(); - $end = Carbon::now()->endOfMonth(); - $budgets = new Collection; - $limits = []; - $repetitions = []; - - for ($i = 0; $i < 5; $i++) { - /** @var \FireflyIII\Models\Budget $budget */ - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $budgets->push($budget); - - /** @var \FireflyIII\Models\BudgetLimit $limit */ - $limit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit'); - $limit->budget_id = $budget->id; - $limit->startdate = $start; - $limit->save(); - - $set = new Collection([$limit]); - $limits[] = $set; - - /** @var \FireflyIII\Models\LimitRepetition $repetition */ - $repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); - $repetition->budget_limit_id = $limit->id; - $repetition->startdate = $start; - $repetition->enddate = $end; - $repetition->save(); - $set = new Collection([$repetition]); - $repetitions[] = $set; - } - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - - // fake! - $repository->shouldReceive('getBudgets')->andReturn($budgets); - $repository->shouldReceive('getBudgetLimitRepetitions')->andReturn($repetitions[0], $repetitions[1], new Collection); - $repository->shouldReceive('spentInPeriodCorrected')->andReturn(10); - $repository->shouldReceive('getWithoutBudgetSum')->andReturn(10); - - $this->call('GET', '/chart/budget/frontpage'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\BudgetController::year - */ - public function testYear() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $collection = new Collection([$budget]); - $this->be($user); - - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - - // fake! - $repository->shouldReceive('getBudgets')->andReturn($collection); - $repository->shouldReceive('spentInPeriodCorrected')->andReturn(0); - - - $this->call('GET', '/chart/budget/year/2015'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\BudgetController::year - */ - public function testYearShared() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $this->call('GET', '/chart/budget/year/2015/shared'); - $this->assertResponseOk(); - } - -} diff --git a/tests/controllers/charts/ChartCategoryControllerTest.php b/tests/controllers/charts/ChartCategoryControllerTest.php deleted file mode 100644 index fe544b7d1f..0000000000 --- a/tests/controllers/charts/ChartCategoryControllerTest.php +++ /dev/null @@ -1,125 +0,0 @@ -be($category->user); - - $this->call('GET', '/chart/category/' . $category->id . '/all'); - $this->assertResponseOk(); - - - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\CategoryController::frontpage - */ - public function testFrontpage() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // make data: - $set = [ - ['name' => 'Something', 'sum' => 100], - ['name' => 'Something Else', 'sum' => 200], - ['name' => 'Something Else Entirely', 'sum' => 200] - ]; - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - - // fake! - $repository->shouldReceive('getCategoriesAndExpensesCorrected')->andReturn($set); - - //getCategoriesAndExpensesCorrected - - $this->call('GET', '/chart/category/frontpage'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\CategoryController::month - */ - public function testMonth() - { - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->be($category->user); - - $this->call('GET', '/chart/category/' . $category->id . '/month'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\CategoryController::year - */ - public function testYear() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $categories = new Collection([FactoryMuffin::create('FireflyIII\Models\Category')]); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - - // fake! - $repository->shouldReceive('getCategories')->andReturn($categories); - $repository->shouldReceive('spentInPeriodCorrected')->andReturn(0); - - $this->call('GET', '/chart/category/year/2015'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\CategoryController::year - */ - public function testYearShared() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $categories = new Collection([FactoryMuffin::create('FireflyIII\Models\Category')]); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - - // fake! - $repository->shouldReceive('getCategories')->andReturn($categories); - $repository->shouldReceive('spentInPeriodCorrected')->andReturn(0); - - $this->call('GET', '/chart/category/year/2015/shared'); - $this->assertResponseOk(); - } - -} diff --git a/tests/controllers/charts/ChartPiggyBankControllerTest.php b/tests/controllers/charts/ChartPiggyBankControllerTest.php deleted file mode 100644 index b5b27fc0c5..0000000000 --- a/tests/controllers/charts/ChartPiggyBankControllerTest.php +++ /dev/null @@ -1,53 +0,0 @@ -be($piggy->account->user); - - // data: - $obj = new stdClass; - $obj->sum = 100; - $obj->date = '2015-01-01'; - $set = [ - $obj - ]; - - // mock! - $repository = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface'); - - // fake! - $repository->shouldReceive('getEventSummarySet')->andReturn($set); - - $this->call('GET', '/chart/piggyBank/' . $piggy->id); - $this->assertResponseOk(); - } -} diff --git a/tests/controllers/charts/ChartReportControllerTest.php b/tests/controllers/charts/ChartReportControllerTest.php deleted file mode 100644 index 950bcb25a5..0000000000 --- a/tests/controllers/charts/ChartReportControllerTest.php +++ /dev/null @@ -1,77 +0,0 @@ -be($user); - - $this->call('GET', '/chart/report/in-out/2015'); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\ReportController::yearInOut - */ - public function testYearInOutShared() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $this->call('GET', '/chart/report/in-out/2015/shared'); - $this->assertResponseOk(); - - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\ReportController::yearInOutSummarized - */ - public function testYearInOutSummarized() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $this->call('GET', '/chart/report/in-out-sum/2015'); - $this->assertResponseOk(); - } - - /** - * @covers FireflyIII\Http\Controllers\Chart\ReportController::yearInOutSummarized - */ - public function testYearInOutSummarizedShared() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $this->call('GET', '/chart/report/in-out-sum/2015/shared'); - $this->assertResponseOk(); - } -} diff --git a/tests/factories/all.php b/tests/factories/all.php deleted file mode 100644 index 96a6bb4044..0000000000 --- a/tests/factories/all.php +++ /dev/null @@ -1,321 +0,0 @@ - 'word', - ] -); - -FactoryMuffin::define( - 'FireflyIII\Models\Bill', - [ - 'user_id' => 'factory|FireflyIII\User', - 'name' => 'sentence', - 'match' => function () { - $words = []; - for ($i = 0; $i < 3; $i++) { - $words[] = RandomString::generateRandomString(5); - } - - return join(',', $words); - }, - 'amount_min' => 10, - 'amount_max' => 20, - 'date' => 'date', - 'active' => 1, - 'automatch' => 1, - 'repeat_freq' => 'monthly', - 'skip' => 0, - 'name_encrypted' => 1, - 'match_encrypted' => 1, - - ] -); - -FactoryMuffin::define( - 'FireflyIII\Models\Account', - [ - 'user_id' => 'factory|FireflyIII\User', - 'account_type_id' => 'factory|FireflyIII\Models\AccountType', - 'name' => 'word', - 'active' => 'boolean', - 'encrypted' => function () { - return true; - }, - 'virtual_balance' => 0 - ] -); - -FactoryMuffin::define( - 'FireflyIII\Models\Tag', - [ - 'description' => 'sentence', - 'user_id' => 'factory|FireflyIII\User', - 'tag' => function () { - return RandomString::generateRandomString(20); - }, - 'tagMode' => 'nothing', - 'date' => 'date', - 'latitude' => 12, - 'longitude' => 13, - 'zoomLevel' => 3, - ] -); - -FactoryMuffin::define( - 'FireflyIII\Models\Budget', - [ - 'user_id' => 'factory|FireflyIII\User', - 'name' => 'sentence', - 'active' => 'boolean', - 'encrypted' => 1, - ] -); - -FactoryMuffin::define( - 'FireflyIII\Models\TransactionGroup', - [ - 'user_id' => 'factory|FireflyIII\User', - 'relation' => 'balance', - ] -); - - -FactoryMuffin::define( - 'FireflyIII\Models\Category', - [ - 'user_id' => 'factory|FireflyIII\User', - 'name' => 'sentence', - 'encrypted' => 1, - ] -); - -FactoryMuffin::define( - 'FireflyIII\Models\LimitRepetition', - [ - 'budget_limit_id' => 'factory|FireflyIII\Models\BudgetLimit', - 'startdate' => 'date', - 'enddate' => 'date', - 'amount' => function () { - return rand(1, 100); - }, - ] -); - -FactoryMuffin::define( - 'FireflyIII\Models\BudgetLimit', - [ - 'budget_id' => 'factory|FireflyIII\Models\Budget', - 'startdate' => 'date', - 'amount' => function () { - return rand(1, 100); - }, - 'repeats' => 'false', - 'repeat_freq' => 'monthly', - - ] -); - - -FactoryMuffin::define( - 'FireflyIII\Models\Preference', - [ - 'name' => 'word', - 'data' => 'sentence', - 'user_id' => 'factory|FireflyIII\User', - ] -); - -FactoryMuffin::define( - 'FireflyIII\Models\AccountType', - [ - 'type' => function () { - $types = ['Expense account', 'Revenue account', 'Asset account', 'Cash account']; - $count = DB::table('account_types')->count(); - if ($count < 4) { - return $types[$count]; - } else { - return RandomString::generateRandomString(10); - } - }, - 'editable' => 1, - ] -); - -FactoryMuffin::define( - 'FireflyIII\Models\TransactionCurrency', - [ - 'code' => function () { - return RandomString::generateRandomString(3); - }, - 'symbol' => function () { - return RandomString::generateRandomString(8); - }, - 'name' => 'word' - ] -); - - -FactoryMuffin::define( - 'FireflyIII\User', - [ - 'email' => function () { - $first = RandomString::generateRandomString(20); - $second = RandomString::generateRandomString(20); - $domain = RandomString::generateRandomString(30); - $email = $first . '.' . $second . '@' . $domain . '.com'; - - return $email; - }, - 'password' => bcrypt('james'), - ] -); - -FactoryMuffin::define( - 'FireflyIII\Models\Transaction', - [ - 'transaction_journal_id' => 'factory|FireflyIII\Models\TransactionJournal', - 'amount' => function () { - return rand(1, 100); - }, - 'description' => 'sentence', - 'account_id' => 'factory|FireflyIII\Models\Account' - ] -); - -FactoryMuffin::define( - 'FireflyIII\Models\PiggyBank', - [ - 'account_id' => 'factory|FireflyIII\Models\Account', - 'name' => 'sentence', - 'targetamount' => function () { - return rand(1, 100); - }, - 'startdate' => 'date', - 'targetdate' => 'date', - 'remind_me' => false, - 'reminder_skip' => 0, - 'order' => 0, - ] -); - -FactoryMuffin::define( - 'FireflyIII\Models\PiggyBankRepetition', - [ - 'piggy_bank_id' => 'factory|FireflyIII\Models\PiggyBank', - 'startdate' => 'date', - 'targetdate' => 'date', - 'currentamount' => function () { - return rand(1, 100); - }, - ] -); - - -FactoryMuffin::define( - 'FireflyIII\Models\PiggyBankEvent', - [ - 'piggy_bank_id' => 'factory|FireflyIII\Models\PiggyBank', - 'transaction_journal_id' => 'factory|FireflyIII\Models\TransactionJournal', - 'date' => 'date', - 'amount' => function () { - return rand(1, 100); - }, - ] -); - - -FactoryMuffin::define( - 'FireflyIII\Models\TransactionType', - [ - 'type' => function () { - $types = ['Withdrawal', 'Deposit', 'Transfer']; - $count = DB::table('transaction_types')->count(); - if ($count < 3) { - return $types[$count]; - } else { - return RandomString::generateRandomString(10); - } - } - ] -); - -FactoryMuffin::define( - 'FireflyIII\Models\TransactionJournal', - [ - 'user_id' => 'factory|FireflyIII\User', - 'transaction_type_id' => 'factory|FireflyIII\Models\TransactionType', - 'transaction_currency_id' => 'factory|FireflyIII\Models\TransactionCurrency', - 'description' => 'sentence', - 'completed' => '1', - 'date' => 'date', - 'encrypted' => '1', - 'order' => '0', - ], function (TransactionJournal $object, $saved) { - if ($saved) { - $one = FactoryMuffin::create('FireflyIII\Models\Account'); - $two = FactoryMuffin::create('FireflyIII\Models\Account'); - - Transaction::create( - [ - 'account_id' => $one->id, - 'transaction_journal_id' => $object->id, - 'amount' => 100 - ] - ); - Transaction::create( - [ - 'account_id' => $two->id, - 'transaction_journal_id' => $object->id, - 'amount' => -100 - ] - ); - - } - -} -); diff --git a/tests/generators/ChartJsAccountChartGeneratorTest.php b/tests/generators/ChartJsAccountChartGeneratorTest.php deleted file mode 100644 index fd6cd6118f..0000000000 --- a/tests/generators/ChartJsAccountChartGeneratorTest.php +++ /dev/null @@ -1,114 +0,0 @@ -object = new ChartJsAccountChartGenerator; - - parent::setUp(); - - - } - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - /** - * @covers FireflyIII\Generator\Chart\Account\ChartJsAccountChartGenerator::frontpage - */ - public function testFrontpage() - { - // be somebody - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // create some accounts: - $accounts = new Collection; - for ($i = 0; $i < 5; $i++) { - $accounts->push(FactoryMuffin::create('FireflyIII\Models\Account')); - } - - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->data = 'en'; - $preference->save(); - - // data for call: - $start = Carbon::createFromDate(2015, 1, 1); - $end = Carbon::createFromDate(2015, 1, 15); - - // mock language preference: - Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference); - - // mock Steam::balance - Steam::shouldReceive('balance')->withAnyArgs()->andReturn(0); - - // call - $result = $this->object->frontpage($accounts, $start, $end); - - $this->assertEquals($accounts->count(), $result['count']); - $this->assertCount(15, $result['labels']); - $this->assertCount($accounts->count(), $result['datasets']); - } - - /** - * @covers FireflyIII\Generator\Chart\Account\ChartJsAccountChartGenerator::single - */ - public function testSingle() - { - // be somebody - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->data = 'en'; - $preference->save(); - - // mock language preference: - Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference); - - // mock Steam::balance - Steam::shouldReceive('balance')->withAnyArgs()->andReturn(0); - - // data for call: - $start = Carbon::createFromDate(2015, 1, 1); - $end = Carbon::createFromDate(2015, 1, 15); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - - // call - $result = $this->object->single($account, $start, $end); - - - // test - $this->assertCount(15, $result['labels']); - $this->assertEquals($account->name, $result['datasets'][0]['label']); - $this->assertCount(15, $result['datasets'][0]['data']); - - - } -} \ No newline at end of file diff --git a/tests/generators/ChartJsBillChartGeneratorTest.php b/tests/generators/ChartJsBillChartGeneratorTest.php deleted file mode 100644 index 62485e9c84..0000000000 --- a/tests/generators/ChartJsBillChartGeneratorTest.php +++ /dev/null @@ -1,100 +0,0 @@ -object = new ChartJsBillChartGenerator(); - - - } - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - /** - * @covers FireflyIII\Generator\Chart\Bill\ChartJsBillChartGenerator::frontpage - */ - public function testFrontpage() - { - // to test frontpage, we generate the exact fake entries - // needed: - $paid = new Collection; - for ($i = 0; $i < 5; $i++) { - $obj = new stdClass(); - $obj->description = 'Something'; - $obj->amount = 100; - $paid->push($obj); - } - - $unpaid = new Collection; - $sum = 0; - for ($i = 0; $i < 5; $i++) { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $date = new Carbon; - $sum += (($bill->amount_max + $bill->amount_min) / 2); - $unpaid->push([$bill, $date]); - } - - - $data = $this->object->frontpage($paid, $unpaid); - - $this->assertCount(2, $data); - $this->assertEquals($sum, $data[0]['value']); - $this->assertEquals(500, $data[1]['value']); - } - - /** - * @covers FireflyIII\Generator\Chart\Bill\ChartJsBillChartGenerator::single - */ - public function testSingle() - { - - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->data = 'en'; - $preference->save(); - - // mock language preference: - Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference); - - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $entries = new Collection; - for ($i = 0; $i < 5; $i++) { - $obj = new stdClass; - $obj->amount = 100; - $obj->date = new Carbon; - $entries->push($obj); - } - $data = $this->object->single($bill, $entries); - - $this->assertCount(5, $data['labels']); - $this->assertCount(5, $data['datasets'][1]['data']); - $this->assertEquals(100, $data['datasets'][1]['data'][0]); // see if first is equal. - - - } -} \ No newline at end of file diff --git a/tests/generators/ChartJsBudgetChartGeneratorTest.php b/tests/generators/ChartJsBudgetChartGeneratorTest.php deleted file mode 100644 index 4fe5e2290e..0000000000 --- a/tests/generators/ChartJsBudgetChartGeneratorTest.php +++ /dev/null @@ -1,113 +0,0 @@ -object = new ChartJsBudgetChartGenerator(); - - } - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - /** - * @covers FireflyIII\Generator\Chart\Budget\ChartJsBudgetChartGenerator::budget - */ - public function testBudget() - { - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->data = 'en'; - $preference->save(); - - // mock language preference: - Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference); - - // make a collection with some amounts in them. - $collection = new Collection; - for ($i = 0; $i < 5; $i++) { - $collection->push([new Carbon, 100]); - } - - $data = $this->object->budget($collection); - - $this->assertCount(5, $data['labels']); - $this->assertCount(5, $data['datasets'][0]['data']); - $this->assertEquals(100, $data['datasets'][0]['data'][0]); - } - - /** - * @covers FireflyIII\Generator\Chart\Budget\ChartJsBudgetChartGenerator::frontpage - */ - public function testFrontpage() - { - // make a collection with some amounts in them. - $collection = new Collection; - for ($i = 0; $i < 5; $i++) { - $collection->push(['Some label', 100, 200, 300]); - } - - $data = $this->object->frontpage($collection); - - $this->assertCount(5, $data['labels']); - $this->assertCount(5, $data['datasets'][0]['data']); - $this->assertEquals(100, $data['datasets'][0]['data'][0]); - $this->assertEquals(200, $data['datasets'][1]['data'][0]); - $this->assertEquals(300, $data['datasets'][2]['data'][0]); - - } - - /** - * @covers FireflyIII\Generator\Chart\Budget\ChartJsBudgetChartGenerator::year - */ - public function testYear() - { - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->data = 'en'; - $preference->save(); - - $budgets = new Collection; - $entries = new Collection; - - // make some budgets: - for ($i = 0; $i < 5; $i++) { - $budgets->push(FactoryMuffin::create('FireflyIII\Models\Budget')); - $entries->push([new Carbon, 100, 100, 100]); - } - - // mock language preference: - Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference); - - $data = $this->object->year($budgets, $entries); - - $this->assertCount(5, $data['labels']); - $this->assertCount(5, $data['datasets']); - $this->assertCount(3, $data['datasets'][0]['data']); - - } -} \ No newline at end of file diff --git a/tests/generators/ChartJsCategoryChartGeneratorTest.php b/tests/generators/ChartJsCategoryChartGeneratorTest.php deleted file mode 100644 index 3b75f4361a..0000000000 --- a/tests/generators/ChartJsCategoryChartGeneratorTest.php +++ /dev/null @@ -1,114 +0,0 @@ -object = new ChartJsCategoryChartGenerator; - - } - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - /** - * @covers FireflyIII\Generator\Chart\Category\ChartJsCategoryChartGenerator::all - */ - public function testAll() - { - - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->data = 'en'; - $preference->save(); - - // mock language preference: - Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference); - - - // make a collection of stuff: - $collection = new Collection; - for ($i = 0; $i < 5; $i++) { - $collection->push([new Carbon, 100]); - } - - $data = $this->object->all($collection); - - $this->assertCount(5, $data['labels']); - $this->assertCount(5, $data['datasets'][0]['data']); - $this->assertEquals(100, $data['datasets'][0]['data'][0]); - } - - /** - * @covers FireflyIII\Generator\Chart\Category\ChartJsCategoryChartGenerator::frontpage - */ - public function testFrontpage() - { - // make a collection of stuff: - $collection = new Collection; - for ($i = 0; $i < 5; $i++) { - $collection->push(['name' => 'Something', 'sum' => 100]); - } - - $data = $this->object->frontpage($collection); - - $this->assertCount(5, $data['labels']); - $this->assertCount(5, $data['datasets'][0]['data']); - $this->assertEquals('Something', $data['labels'][0]); - $this->assertEquals(100, $data['datasets'][0]['data'][0]); - } - - /** - * @covers FireflyIII\Generator\Chart\Category\ChartJsCategoryChartGenerator::year - */ - public function testYear() - { - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->data = 'en'; - $preference->save(); - - // mock language preference: - Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference); - - // make a collection of stuff: - $collection = new Collection; - $categories = new Collection; - for ($i = 0; $i < 5; $i++) { - $categories->push(FactoryMuffin::create('FireflyIII\Models\Category')); - $collection->push([new Carbon, 100, 100, 100]); - } - - $data = $this->object->year($categories, $collection); - - $this->assertCount(5, $data['labels']); - $this->assertEquals($categories->first()->name, $data['labels'][0]); - $this->assertCount(3, $data['datasets'][0]['data']); - - - } -} \ No newline at end of file diff --git a/tests/generators/ChartJsPiggyBankChartGeneratorTest.php b/tests/generators/ChartJsPiggyBankChartGeneratorTest.php deleted file mode 100644 index e63b9d73fd..0000000000 --- a/tests/generators/ChartJsPiggyBankChartGeneratorTest.php +++ /dev/null @@ -1,66 +0,0 @@ -object = new ChartJsPiggyBankChartGenerator; - - } - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - /** - * @covers FireflyIII\Generator\Chart\PiggyBank\ChartJsPiggyBankChartGenerator::history - */ - public function testHistory() - { - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->data = 'en'; - $preference->save(); - - // mock language preference: - Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference); - - // create a set - $set = new Collection; - for ($i = 0; $i < 5; $i++) { - $obj = new stdClass; - $obj->date = new Carbon; - $obj->sum = 100; - $set->push($obj); - } - - $data = $this->object->history($set); - $this->assertCount(5, $data['labels']); - $this->assertCount(5, $data['datasets'][0]['data']); - $this->assertEquals(100, $data['datasets'][0]['data'][0]); - $this->assertEquals(500, $data['datasets'][0]['data'][4]); - - - } -} \ No newline at end of file diff --git a/tests/generators/ChartJsReportChartGeneratorTest.php b/tests/generators/ChartJsReportChartGeneratorTest.php deleted file mode 100644 index 4c41c23123..0000000000 --- a/tests/generators/ChartJsReportChartGeneratorTest.php +++ /dev/null @@ -1,80 +0,0 @@ -object = new ChartJsReportChartGenerator; - - } - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - /** - * FireflyIII\Generator\Chart\Report\ChartJsReportChartGenerator::yearInOut - */ - public function testYearInOut() - { - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->data = 'en'; - $preference->save(); - - // mock language preference: - Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($preference); - - // make set: - $collection = new Collection; - for ($i = 0; $i < 5; $i++) { - $collection->push([new Carbon, 200, 100]); - } - - $data = $this->object->yearInOut($collection); - - $this->assertEquals(200, $data['datasets'][0]['data'][0]); - $this->assertEquals(100, $data['datasets'][1]['data'][0]); - $this->assertCount(5, $data['labels']); - - } - - /** - * FireflyIII\Generator\Chart\Report\ChartJsReportChartGenerator::yearInOutSummarized - */ - public function testYearInOutSummarized() - { - // make set: - $income = 2400; - $expense = 1200; - - $data = $this->object->yearInOutSummarized($income, $expense, 12); - - $this->assertEquals(200, $data['datasets'][0]['data'][1]); - $this->assertEquals(100, $data['datasets'][1]['data'][1]); - - } -} \ No newline at end of file diff --git a/tests/generators/GoogleAccountChartGeneratorTest.php b/tests/generators/GoogleAccountChartGeneratorTest.php deleted file mode 100644 index 864034180b..0000000000 --- a/tests/generators/GoogleAccountChartGeneratorTest.php +++ /dev/null @@ -1,120 +0,0 @@ -object = new GoogleAccountChartGenerator; - - } - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - /** - * @covers FireflyIII\Generator\Chart\Account\GoogleAccountChartGenerator::all - */ - public function testAll() - { - // be somebody - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // create some accounts: - $accounts = new Collection; - for ($i = 0; $i < 5; $i++) { - $accounts->push(FactoryMuffin::create('FireflyIII\Models\Account')); - } - - // data for call: - $start = Carbon::createFromDate(2015, 1, 1); - $end = Carbon::createFromDate(2015, 1, 15); - - // mock Steam::balance - Steam::shouldReceive('balance')->withAnyArgs()->andReturn(0); - - $data = $this->object->all($accounts, $start, $end); - $this->assertCount(11, $data['cols']); // accounts * 2 + date. - // fifteen days, - $this->assertCount(16, $data['rows']); // 15 + 1? - } - - /** - * @covers FireflyIII\Generator\Chart\Account\GoogleAccountChartGenerator::frontpage - */ - public function testFrontpage() - { - // be somebody - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // create some accounts: - $accounts = new Collection; - for ($i = 0; $i < 5; $i++) { - $accounts->push(FactoryMuffin::create('FireflyIII\Models\Account')); - } - - // data for call: - $start = Carbon::createFromDate(2015, 1, 1); - $end = Carbon::createFromDate(2015, 1, 15); - - // mock Steam::balance - Steam::shouldReceive('balance')->withAnyArgs()->andReturn(0); - - $data = $this->object->frontpage($accounts, $start, $end); - $this->assertCount(11, $data['cols']); // accounts * 2 + date. - // fifteen days, - $this->assertCount(16, $data['rows']); // 15 + 1? - } - - /** - * @covers FireflyIII\Generator\Chart\Account\GoogleAccountChartGenerator::single - */ - public function testSingle() - { - // be somebody - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - /** @var Account $account */ - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - - // data for call: - $start = Carbon::createFromDate(2015, 1, 1); - $end = Carbon::createFromDate(2015, 1, 15); - - // mock Steam::balance - Steam::shouldReceive('balance')->withAnyArgs()->andReturn(0); - - $data = $this->object->single($account, $start, $end); - $this->assertCount(3, $data['cols']); // account, date, certainty - // fifteen days, - $this->assertCount(15, $data['rows']); // 15 days - } - -} \ No newline at end of file diff --git a/tests/generators/GoogleBillChartGeneratorTest.php b/tests/generators/GoogleBillChartGeneratorTest.php deleted file mode 100644 index 5576098595..0000000000 --- a/tests/generators/GoogleBillChartGeneratorTest.php +++ /dev/null @@ -1,90 +0,0 @@ -object = new GoogleBillChartGenerator; - - } - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - /** - * @covers FireflyIII\Generator\Chart\Bill\GoogleBillChartGenerator::frontpage - */ - public function testFrontpage() - { - // to test frontpage, we generate the exact fake entries - // needed: - $paid = new Collection; - for ($i = 0; $i < 5; $i++) { - $obj = new stdClass(); - $obj->description = 'Something'; - $obj->amount = 100; - $paid->push($obj); - } - - $unpaid = new Collection; - $sum = 0; - for ($i = 0; $i < 5; $i++) { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $date = new Carbon; - $sum += (($bill->amount_max + $bill->amount_min) / 2); - $unpaid->push([$bill, $date]); - } - - - $data = $this->object->frontpage($paid, $unpaid); - - $this->assertCount(2, $data['cols']); - $this->assertCount(2, $data['rows']); // two rows, two columns. - } - - /** - * @covers FireflyIII\Generator\Chart\Bill\GoogleBillChartGenerator::single - */ - public function testSingle() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $entries = new Collection; - for ($i = 0; $i < 5; $i++) { - $obj = new stdClass; - $obj->amount = 100; - $obj->date = new Carbon; - $entries->push($obj); - } - $data = $this->object->single($bill, $entries); - - $this->assertCount(5, $data['rows']); - $this->assertCount(4, $data['cols']); - $this->assertEquals(100, $data['rows'][0]['c'][3]['v']); - } -} \ No newline at end of file diff --git a/tests/generators/GoogleBudgetChartGeneratorTest.php b/tests/generators/GoogleBudgetChartGeneratorTest.php deleted file mode 100644 index 13b3cb54bc..0000000000 --- a/tests/generators/GoogleBudgetChartGeneratorTest.php +++ /dev/null @@ -1,99 +0,0 @@ -object = new GoogleBudgetChartGenerator(); - - } - - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - - /** - * @covers FireflyIII\Generator\Chart\Budget\GoogleBudgetChartGenerator::budget - */ - public function testBudget() - { - // make a collection with some amounts in them. - $collection = new Collection; - for ($i = 0; $i < 5; $i++) { - $collection->push([new Carbon, 100]); - } - - $data = $this->object->budget($collection); - - $this->assertCount(5, $data['rows']); - $this->assertCount(2, $data['cols']); - $this->assertEquals(100, $data['rows'][0]['c'][1]['v']); - } - - /** - * @covers FireflyIII\Generator\Chart\Budget\GoogleBudgetChartGenerator::frontpage - */ - public function testFrontpage() - { - // make a collection with some amounts in them. - $collection = new Collection; - for ($i = 0; $i < 5; $i++) { - $collection->push(['Some label', 100, 200, 300]); - } - - $data = $this->object->frontpage($collection); - - $this->assertCount(5, $data['rows']); - $this->assertEquals(100, $data['rows'][0]['c'][1]['v']); - $this->assertEquals(200, $data['rows'][0]['c'][2]['v']); - $this->assertEquals(300, $data['rows'][0]['c'][3]['v']); - } - - /** - * @covers FireflyIII\Generator\Chart\Budget\GoogleBudgetChartGenerator::year - */ - public function testYear() - { - $budgets = new Collection; - $entries = new Collection; - - // make some budgets: - for ($i = 0; $i < 5; $i++) { - $budgets->push(FactoryMuffin::create('FireflyIII\Models\Budget')); - $entries->push([new Carbon, 100, 100, 100]); - } - - $data = $this->object->year($budgets, $entries); - - $this->assertCount(5, $data['rows']); - $this->assertCount(6, $data['cols']); - } -} \ No newline at end of file diff --git a/tests/generators/GoogleCategoryChartGeneratorTest.php b/tests/generators/GoogleCategoryChartGeneratorTest.php deleted file mode 100644 index 78f0ffde39..0000000000 --- a/tests/generators/GoogleCategoryChartGeneratorTest.php +++ /dev/null @@ -1,116 +0,0 @@ -object = new GoogleCategoryChartGenerator(); - - } - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - - /** - * @covers FireflyIII\Generator\Chart\Category\GoogleCategoryChartGenerator::all - */ - public function testAll() - { - // make a collection of stuff: - $collection = new Collection; - for ($i = 0; $i < 5; $i++) { - $collection->push([new Carbon, 100]); - } - - $data = $this->object->all($collection); - - $this->assertCount(5, $data['rows']); - $this->assertCount(2, $data['cols']); - $this->assertEquals(100, $data['rows'][0]['c'][1]['v']); - } - - /** - * @covers FireflyIII\Generator\Chart\Category\GoogleCategoryChartGenerator::frontpage - */ - public function testFrontpage() - { - // make a collection of stuff: - $collection = new Collection; - for ($i = 0; $i < 5; $i++) { - $collection->push(['name' => 'Something', 'sum' => 100]); - } - - $data = $this->object->frontpage($collection); - - $this->assertCount(5, $data['rows']); - $this->assertCount(2, $data['cols']); - $this->assertEquals('Something', $data['rows'][0]['c'][0]['v']); - $this->assertEquals(100, $data['rows'][0]['c'][1]['v']); - - } - - /** - * @covers FireflyIII\Generator\Chart\Category\GoogleCategoryChartGenerator::month - */ - public function testMonth() - { - // make a collection of stuff: - $collection = new Collection; - for ($i = 0; $i < 5; $i++) { - $collection->push([new Carbon, 100]); - } - - $data = $this->object->month($collection); - - $this->assertCount(5, $data['rows']); - $this->assertCount(2, $data['cols']); - $this->assertEquals(100, $data['rows'][0]['c'][1]['v']); - } - - /** - * @covers FireflyIII\Generator\Chart\Category\GoogleCategoryChartGenerator::year - */ - public function testYear() - { - // make a collection of stuff: - $collection = new Collection; - $categories = new Collection; - for ($i = 0; $i < 5; $i++) { - $categories->push(FactoryMuffin::create('FireflyIII\Models\Category')); - $collection->push([new Carbon, 100, 100, 100]); - } - - $data = $this->object->year($categories, $collection); - - $this->assertCount(5, $data['rows']); - $this->assertEquals($categories->first()->name, $data['cols'][1]['label']); - $this->assertEquals(100, $data['rows'][0]['c'][1]['v']); - - } -} \ No newline at end of file diff --git a/tests/generators/GooglePiggyBankChartGeneratorTest.php b/tests/generators/GooglePiggyBankChartGeneratorTest.php deleted file mode 100644 index 7c1daf7a9f..0000000000 --- a/tests/generators/GooglePiggyBankChartGeneratorTest.php +++ /dev/null @@ -1,58 +0,0 @@ -object = new GooglePiggyBankChartGenerator(); - - } - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - /** - * @covers FireflyIII\Generator\Chart\PiggyBank\GooglePiggyBankChartGenerator::history - */ - public function testHistory() - { - // create a set - $set = new Collection; - for ($i = 0; $i < 5; $i++) { - $obj = new stdClass; - $obj->date = new Carbon; - $obj->sum = 100; - $set->push($obj); - } - - $data = $this->object->history($set); - $this->assertCount(5, $data['rows']); - $this->assertCount(2, $data['cols']); - - $this->assertEquals(100, $data['rows'][0]['c'][1]['v']); - $this->assertEquals(500, $data['rows'][4]['c'][1]['v']); - } -} \ No newline at end of file diff --git a/tests/generators/GoogleReportChartGeneratorTest.php b/tests/generators/GoogleReportChartGeneratorTest.php deleted file mode 100644 index 57c715ad02..0000000000 --- a/tests/generators/GoogleReportChartGeneratorTest.php +++ /dev/null @@ -1,69 +0,0 @@ -object = new GoogleReportChartGenerator; - - } - - /** - * This method is called before the first test of this test class is run. - * - * @since Method available since Release 3.4.0 - */ - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - /** - * FireflyIII\Generator\Chart\Report\GoogleReportChartGenerator::yearInOut - */ - public function testYearInOut() - { - // make set: - $collection = new Collection; - for ($i = 0; $i < 5; $i++) { - $collection->push([new Carbon, 200, 100]); - } - - $data = $this->object->yearInOut($collection); - - $this->assertCount(5, $data['rows']); - - $this->assertEquals(200, $data['rows'][0]['c'][1]['v']); - $this->assertEquals(100, $data['rows'][0]['c'][2]['v']); - } - - /** - * FireflyIII\Generator\Chart\Report\GoogleReportChartGenerator::yearInOutSummarized - */ - public function testYearInOutSummarized() - { - // make set: - $income = 2400; - $expense = 1200; - - $data = $this->object->yearInOutSummarized($income, $expense, 12); - - $this->assertEquals(200, $data['rows'][1]['c'][1]['v']); - $this->assertEquals(100, $data['rows'][1]['c'][2]['v']); - } -} \ No newline at end of file diff --git a/tests/helpers/ConnectJournalToPiggyBankTest.php b/tests/helpers/ConnectJournalToPiggyBankTest.php deleted file mode 100644 index 09967aa788..0000000000 --- a/tests/helpers/ConnectJournalToPiggyBankTest.php +++ /dev/null @@ -1,139 +0,0 @@ -get('piggy_bank_id')))); - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - public function setUp() - { - parent::setUp(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - } - - /** - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @covers FireflyIII\Handlers\Events\ConnectJournalToPiggyBank::handle - */ - public function testNoRepetition() - { - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - /** @var \FireflyIII\Models\PiggyBank $piggyBank */ - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account1->user_id = $user->id; - $account2->user_id = $user->id; - $piggyBank->account_id = $account1->id; - $account1->save(); - $account2->save(); - $piggyBank->save(); - - // because the event handler responds to this piggy bank, we must remove - // the piggy bank repetition: - /** @var \FireflyIII\Models\PiggyBankRepetition $rep */ - foreach ($piggyBank->piggyBankRepetitions()->get() as $rep) { - $rep->forceDelete(); - } - - - $event = new JournalCreated($journal, $piggyBank->id); - $class = new ConnectJournalToPiggyBank(); - $result = $class->handle($event); - - - $this->assertFalse($result); - } - - /** - * @covers FireflyIII\Handlers\Events\ConnectJournalToPiggyBank::handle - */ - public function testNoSuchPiggy() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $event = new JournalCreated($journal, 1); - $class = new ConnectJournalToPiggyBank(); - $result = $class->handle($event); - - - $this->assertFalse($result); - } - - /** - * @covers FireflyIII\Handlers\Events\ConnectJournalToPiggyBank::handle - */ - public function testWithRepetition() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // deposit - - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - - $journal->user_id = $user->id; - $journal->save(); - - // create piggy bank event to continue handler: - $start = clone $journal->date; - $end = clone $journal->date; - $start->subDay(); - $end->addDay(); - - PiggyBankRepetition::create( - [ - 'piggy_bank_id' => $piggyBank->id, - 'startdate' => $start->format('Y-m-d'), - 'targetdate' => $end->format('Y-m-d'), - 'currentamount' => 0, - ] - ); - - - /** @var Transaction $transaction */ - foreach ($journal->transactions()->get() as $transaction) { - if ($transaction->amount < 0) { - $piggyBank->account_id = $transaction->account_id; - $account = $transaction->account; - $account->user_id = $user->id; - $account->save(); - $piggyBank->account_id = $account->id; - $piggyBank->save(); - } - } - $event = new JournalCreated($journal, $piggyBank->id); - $class = new ConnectJournalToPiggyBank(); - $result = $class->handle($event); - - $this->assertTrue($result); - } -} diff --git a/tests/helpers/ReportHelperTest.php b/tests/helpers/ReportHelperTest.php deleted file mode 100644 index 91a3576d47..0000000000 --- a/tests/helpers/ReportHelperTest.php +++ /dev/null @@ -1,329 +0,0 @@ -object = new ReportHelper($query); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - } - - /** - * @covers FireflyIII\Helpers\Report\ReportHelper::getAccountReport - */ - public function testGetAccountReport() - { - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); - $cash = FactoryMuffin::create('FireflyIII\Models\AccountType'); - $user = FactoryMuffin::create('FireflyIII\User'); - for ($i = 0; $i < 5; $i++) { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $account->user_id = $user->id; - $account->account_type_id = $asset->id; - $account->save(); - - } - - $cashAccount = FactoryMuffin::create('FireflyIII\Models\Account'); - $cashAccount->user_id = $user->id; - $cashAccount->account_type_id = $cash->id; - $cashAccount->save(); - - $this->be($user); - /** @var AccountCollection $object */ - $object = $this->object->getAccountReport(Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth(), false); - - $this->assertCount(5, $object->getAccounts()); - $this->assertEquals(0, $object->getDifference()); - $this->assertEquals(0, $object->getEnd()); - $this->assertEquals(0, $object->getStart()); - } - - /** - * @covers FireflyIII\Helpers\Report\ReportHelper::getBalanceReport - */ - public function testGetBalanceReport() - { - // factory! - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); - $user = FactoryMuffin::create('FireflyIII\User'); - $rep = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); - for ($i = 0; $i < 5; $i++) { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $account->user_id = $user->id; - $account->account_type_id = $asset->id; - $account->save(); - } - - $set = new Collection; - for ($i = 0; $i < 5; $i++) { - $set->push(FactoryMuffin::create('FireflyIII\Models\Budget')); - } - - $this->be($user); - - // mock! - $budgetRepos = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $tagRepos = $this->mock('FireflyIII\Repositories\Tag\TagRepositoryInterface'); - - // fake! - $budgetRepos->shouldReceive('getBudgets')->andReturn($set); - $budgetRepos->shouldReceive('getCurrentRepetition')->andReturn($rep); - $tagRepos->shouldReceive('coveredByBalancingActs')->andReturn(0); - - // test! - $object = $this->object->getBalanceReport(Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth(), false); - $this->assertCount(8, $object->getBalanceLines()); - $this->assertCount(5, $object->getBalanceHeader()->getAccounts()); - } - - /** - * @covers FireflyIII\Helpers\Report\ReportHelper::getBillReport - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testGetBillReport() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // factory! - $set = new Collection; - $journals = new Collection; - FactoryMuffin::create('FireflyIII\Models\Account'); - FactoryMuffin::create('FireflyIII\Models\Account'); - for ($i = 0; $i < 5; $i++) { - $set->push(FactoryMuffin::create('FireflyIII\Models\Bill')); - } - - for ($i = 0; $i < 5; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journals->push($journal); - } - - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - - // fake! - $repository->shouldReceive('getBills')->andReturn($set); - $repository->shouldReceive('getJournalsInRange')->withAnyArgs()->andReturn(new Collection, $journals); - - // test! - $object = $this->object->getBillReport(Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth(), false); - $this->assertCount(5, $object->getBills()); - } - - /** - * @covers FireflyIII\Helpers\Report\ReportHelper::getBudgetReport - */ - public function testGetBudgetReport() - { - // factory! - $user = FactoryMuffin::create('FireflyIII\User'); - $set = new Collection; - $rep1 = new Collection; - $rep2 = new Collection; - for ($i = 0; $i < 5; $i++) { - $set->push(FactoryMuffin::create('FireflyIII\Models\Budget')); - } - for ($i = 0; $i < 5; $i++) { - $rep1->push(FactoryMuffin::create('FireflyIII\Models\LimitRepetition')); - } - - $this->be($user); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - - // fake! - $repository->shouldReceive('getBudgets')->andReturn($set); - $repository->shouldReceive('getBudgetLimitRepetitions')->andReturn($rep1, $rep2); - $repository->shouldReceive('spentInPeriodCorrected')->andReturn(rand(0, 100)); - $repository->shouldReceive('getWithoutBudgetSum')->andReturn(rand(0, 100)); - - // test! - $object = $this->object->getBudgetReport(Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth(), false); - - $this->assertCount(10, $object->getBudgetLines()); - } - - /** - * @covers FireflyIII\Helpers\Report\ReportHelper::getCategoryReport - */ - public function testGetCategoryReport() - { - // factory! - $user = FactoryMuffin::create('FireflyIII\User'); - $set = new Collection; - for ($i = 0; $i < 5; $i++) { - $set->push(FactoryMuffin::create('FireflyIII\Models\Category')); - } - - $this->be($user); - - // mock! - $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - - // fake! - $repository->shouldReceive('getCategories')->andReturn($set); - $repository->shouldReceive('spentInPeriodCorrected')->andReturn(rand(1, 100)); - - // test! - $object = $this->object->getCategoryReport(Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth(), false); - $this->assertCount(5, $object->getCategories()); - } - - - /** - * @covers FireflyIII\Helpers\Report\ReportHelper::getExpenseReport - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testGetExpenseReport() - { - // factory! - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - // create five journals in this month for the report: - $date = Carbon::now()->startOfMonth()->addDay(); - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); - $left = FactoryMuffin::create('FireflyIII\Models\Account'); - $right = FactoryMuffin::create('FireflyIII\Models\Account'); - $left->account_type_id = $asset->id; - $right->account_type_id = $asset->id; - $right->save(); - $left->save(); - - // save meta for account: - AccountMeta::create( - [ - 'account_id' => $left->id, - 'name' => 'accountRole', - 'data' => 'defaultAsset' - ] - ); - AccountMeta::create( - [ - 'account_id' => $right->id, - 'name' => 'accountRole', - 'data' => 'defaultAsset' - ] - ); - - - for ($i = 0; $i < 5; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->date = $date; - $journal->transaction_type_id = $type->id; - $journal->user_id = $user->id; - $journal->save(); - } - - // test! - $object = $this->object->getExpenseReport(Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth(), true); - $this->assertCount(5, $object->getExpenses()); - } - - /** - * @covers FireflyIII\Helpers\Report\ReportHelper::getIncomeReport - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testGetIncomeReport() - { - // factory! - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - // create five journals in this month for the report: - $date = Carbon::now()->startOfMonth()->addDay(); - $left = FactoryMuffin::create('FireflyIII\Models\Account'); - $right = FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); - $left->account_type_id = $asset->id; - $right->account_type_id = $asset->id; - - // save meta for account: - AccountMeta::create( - [ - 'account_id' => $left->id, - 'name' => 'accountRole', - 'data' => 'defaultAsset' - ] - ); - AccountMeta::create( - [ - 'account_id' => $right->id, - 'name' => 'accountRole', - 'data' => 'defaultAsset' - ] - ); - - $right->save(); - $left->save(); - for ($i = 0; $i < 5; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->date = $date; - $journal->transaction_type_id = $type->id; - $journal->user_id = $user->id; - $journal->save(); - } - - // test! - $object = $this->object->getIncomeReport(Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth(), true); - $this->assertCount(5, $object->getIncomes()); - - } - - /** - * @covers FireflyIII\Helpers\Report\ReportHelper::listOfMonths - */ - public function testListOfMonths() - { - // start of year up until now - $date = new Carbon('2015-01-01'); - $now = new Carbon; - $diff = $now->diffInMonths($date) + 1; // the month itself. - $result = $this->object->listOfMonths($date); - - $this->assertCount($diff, $result[2015]); - - } - -} diff --git a/tests/helpers/ReportQueryTest.php b/tests/helpers/ReportQueryTest.php deleted file mode 100644 index a7451c5319..0000000000 --- a/tests/helpers/ReportQueryTest.php +++ /dev/null @@ -1,397 +0,0 @@ -object = new ReportQuery; - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - } - - - /** - * @covers FireflyIII\Helpers\Report\ReportQuery::expenseInPeriodCorrected - * @covers FireflyIII\Helpers\Report\ReportQuery::queryJournalsWithTransactions - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testExpenseInPeriodCorrected() - { - $start = new Carbon('2015-01-01'); - $end = new Carbon('2015-02-01'); - - $user = FactoryMuffin::create('FireflyIII\User'); - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - $expense = FactoryMuffin::create('FireflyIII\Models\AccountType'); - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); - - $date = new Carbon('2015-01-12'); - - for ($i = 0; $i < 10; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->date = $date; - $journal->user_id = $user->id; - $journal->transaction_type_id = $type->id; - $journal->save(); - - // two transactions: - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account1->account_type_id = $asset->id; - $account1->user_id = $user->id; - $account2->account_type_id = $expense->id; - $account2->user_id = $user->id; - $account1->save(); - $account2->save(); - - AccountMeta::create( - [ - 'account_id' => $account1->id, - 'name' => 'accountRole', - 'data' => 'defaultAsset' - ] - ); - - $amount = 100; - if ($i == 8) { - $amount = 0; // at least one "empty" journal. - } - - // update both transactions - $journal->transactions[0]->account_id = $account1->id; - $journal->transactions[0]->amount = $amount * -1; - $journal->transactions[0]->save(); - - $journal->transactions[1]->account_id = $account2->id; - $journal->transactions[1]->amount = $amount; - $journal->transactions[1]->save(); - - - } - $this->be($user); - - - $set = $this->object->expenseInPeriodCorrected($start, $end, false); - - - $this->assertCount(9, $set); - } - - /** - * @covers FireflyIII\Helpers\Report\ReportQuery::expenseInPeriodCorrected - * @covers FireflyIII\Helpers\Report\ReportQuery::queryJournalsWithTransactions - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testExpenseInPeriodCorrectedShared() - { - $start = new Carbon('2015-01-01'); - $end = new Carbon('2015-02-01'); - - $user = FactoryMuffin::create('FireflyIII\User'); - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - $expense = FactoryMuffin::create('FireflyIII\Models\AccountType'); - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); - - $date = new Carbon('2015-01-12'); - - for ($i = 0; $i < 10; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->date = $date; - $journal->user_id = $user->id; - $journal->transaction_type_id = $type->id; - $journal->save(); - - // two transactions: - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account1->account_type_id = $asset->id; - $account1->user_id = $user->id; - $account2->account_type_id = $expense->id; - $account2->user_id = $user->id; - $account1->save(); - $account2->save(); - - AccountMeta::create( - [ - 'account_id' => $account1->id, - 'name' => 'accountRole', - 'data' => 'defaultAsset' - ] - ); - - $amount = 100; - if ($i == 8) { - $amount = 0; // at least one "empty" journal. - } - - // update both transactions - $journal->transactions[0]->account_id = $account1->id; - $journal->transactions[0]->amount = $amount * -1; - $journal->transactions[0]->save(); - - $journal->transactions[1]->account_id = $account2->id; - $journal->transactions[1]->amount = $amount; - $journal->transactions[1]->save(); - - } - $this->be($user); - - $set = $this->object->expenseInPeriodCorrected($start, $end, true); - - $this->assertCount(9, $set); - } - - /** - * @covers FireflyIII\Helpers\Report\ReportQuery::getAllAccounts - */ - public function testGetAllAccounts() - { - $start = new Carbon('2015-01-01'); - $end = new Carbon('2015-02-01'); - $user = FactoryMuffin::create('FireflyIII\User'); - FactoryMuffin::create('FireflyIII\Models\Account'); - FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - - for ($i = 0; $i < 10; $i++) { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $account->account_type_id = $asset->id; - $account->user_id = $user->id; - $account->save(); - } - - Steam::shouldReceive('balance')->andReturn(0); - - $this->be($user); - - $set = $this->object->getAllAccounts($start, $end, false); - $this->assertCount(10, $set); - } - - /** - * @covers FireflyIII\Helpers\Report\ReportQuery::getAllAccounts - */ - public function testGetAllAccountsShared() - { - $start = new Carbon('2015-01-01'); - $end = new Carbon('2015-02-01'); - $user = FactoryMuffin::create('FireflyIII\User'); - FactoryMuffin::create('FireflyIII\Models\Account'); - FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - - for ($i = 0; $i < 10; $i++) { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $account->account_type_id = $asset->id; - $account->user_id = $user->id; - $account->save(); - } - - Steam::shouldReceive('balance')->andReturn(0); - - $this->be($user); - - $set = $this->object->getAllAccounts($start, $end, true); - $this->assertCount(10, $set); - } - - /** - * @covers FireflyIII\Helpers\Report\ReportQuery::incomeInPeriodCorrected - * @covers FireflyIII\Helpers\Report\ReportQuery::queryJournalsWithTransactions - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testIncomeInPeriodCorrected() - { - $start = new Carbon('2015-01-01'); - $end = new Carbon('2015-02-01'); - - $user = FactoryMuffin::create('FireflyIII\User'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - $expense = FactoryMuffin::create('FireflyIII\Models\AccountType'); - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); - - $date = new Carbon('2015-01-12'); - - for ($i = 0; $i < 10; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->date = $date; - $journal->user_id = $user->id; - $journal->transaction_type_id = $type->id; - $journal->save(); - - // two transactions: - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account1->account_type_id = $asset->id; - $account1->user_id = $user->id; - $account2->account_type_id = $expense->id; - $account2->user_id = $user->id; - $account1->save(); - $account2->save(); - - AccountMeta::create( - [ - 'account_id' => $account1->id, - 'name' => 'accountRole', - 'data' => 'defaultAsset' - ] - ); - - $amount = 100; - if ($i == 8) { - $amount = 0; // at least one "empty" journal. - } - - // update both transactions - $journal->transactions[0]->account_id = $account1->id; - $journal->transactions[0]->amount = $amount; - $journal->transactions[0]->save(); - - $journal->transactions[1]->account_id = $account2->id; - $journal->transactions[1]->amount = $amount * -1; - $journal->transactions[1]->save(); - - } - $this->be($user); - - $set = $this->object->incomeInPeriodCorrected($start, $end, false); - - $this->assertCount(9, $set); - } - - /** - * @covers FireflyIII\Helpers\Report\ReportQuery::incomeInPeriodCorrected - * @covers FireflyIII\Helpers\Report\ReportQuery::queryJournalsWithTransactions - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testIncomeInPeriodCorrectedShared() - { - $start = new Carbon('2015-01-01'); - $end = new Carbon('2015-02-01'); - - $user = FactoryMuffin::create('FireflyIII\User'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - $expense = FactoryMuffin::create('FireflyIII\Models\AccountType'); - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); - - $date = new Carbon('2015-01-12'); - - for ($i = 0; $i < 10; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->date = $date; - $journal->user_id = $user->id; - $journal->transaction_type_id = $type->id; - $journal->save(); - - // two transactions: - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account1->account_type_id = $asset->id; - $account1->user_id = $user->id; - $account2->account_type_id = $expense->id; - $account2->user_id = $user->id; - $account1->save(); - $account2->save(); - - AccountMeta::create( - [ - 'account_id' => $account1->id, - 'name' => 'accountRole', - 'data' => 'defaultAsset' - ] - ); - - $amount = 100; - if ($i == 8) { - $amount = 0; // at least one "empty" journal. - } - - // update both transactions - $journal->transactions[0]->account_id = $account1->id; - $journal->transactions[0]->amount = $amount * -1; - $journal->transactions[0]->save(); - - $journal->transactions[1]->account_id = $account2->id; - $journal->transactions[1]->amount = $amount; - $journal->transactions[1]->save(); - - } - $this->be($user); - - $set = $this->object->incomeInPeriodCorrected($start, $end, true); - - $this->assertCount(9, $set); - } - - /** - * @covers FireflyIII\Helpers\Report\ReportQuery::spentInBudgetCorrected - */ - public function testSpentInBudgetCorrected() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $account->user_id = $user->id; - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $budget->user_id = $user->id; - - $account->save(); - $budget->save(); - - $this->be($user); - - $result = $this->object->spentInBudgetCorrected($account, $budget, new Carbon, new Carbon); - $this->assertEquals(0, $result); - - } - - /** - * @covers FireflyIII\Helpers\Report\ReportQuery::spentNoBudget - */ - public function testSpentNoBudget() - { - - $user = FactoryMuffin::create('FireflyIII\User'); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $account->user_id = $user->id; - - $account->save(); - - $this->be($user); - - $result = $this->object->spentNoBudget($account, new Carbon, new Carbon); - $this->assertEquals(0, $result); - } - -} diff --git a/tests/models/AccountModelTest.php b/tests/models/AccountModelTest.php deleted file mode 100644 index 662a2a73a2..0000000000 --- a/tests/models/AccountModelTest.php +++ /dev/null @@ -1,162 +0,0 @@ - $account->name, - 'account_type_id' => $account->account_type_id, - 'user_id' => $account->user_id - ]; - - $result = Account::firstOrCreateEncrypted($search); - - // should be the same account: - - $this->assertEquals($account->id, $result->id); - - } - - /** - * @covers FireflyIII\Models\Account::firstOrCreateEncrypted - */ - public function testFirstOrCreateEncryptedNew() - { - // create account: - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - FactoryMuffin::create('FireflyIII\User'); - - // search for account with the same properties: - $search = [ - 'name' => 'Some new account', - 'account_type_id' => $account->account_type_id, - 'user_id' => $account->user_id, - 'active' => 1, - ]; - - $result = Account::firstOrCreateEncrypted($search); - - // should not be the same account: - - $this->assertNotEquals($account->id, $result->id); - - - } - - /** - * @covers FireflyIII\Models\Account::firstOrNullEncrypted - */ - public function testFirstOrNullEncrypted() - { - // create account: - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - - - // search for account with the same properties: - $search = [ - 'name' => $account->name, - 'account_type_id' => $account->account_type_id, - 'user_id' => $account->user_id - ]; - - $result = Account::firstOrNullEncrypted($search); - - // should be the same account: - - $this->assertEquals($account->id, $result->id); - } - - /** - * @covers FireflyIII\Models\Account::firstOrNullEncrypted - */ - public function testFirstOrNullEncryptedNew() - { - // create account: - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - FactoryMuffin::create('FireflyIII\User'); - - // search for account with the same properties: - $search = [ - 'name' => 'Some new account', - 'account_type_id' => $account->account_type_id, - 'user_id' => $account->user_id, - 'active' => 1, - ]; - - $result = Account::firstOrNullEncrypted($search); - - // should not be the same account: - - $this->assertNull($result); - - - } - - /** - * @covers FireflyIII\Models\Account::getNameForEditformAttribute - */ - public function testGetNameForEditformAttribute() - { - // normal name is normal - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $this->assertEquals($account->name, $account->getNameForEditformAttribute()); - } - /** - * @covers FireflyIII\Models\Account::getNameForEditformAttribute - */ - public function testGetNameForEditformAttributeCash() - { - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - // cash name is empty - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $this->assertEquals('', $account->getNameForEditformAttribute()); - } - -} diff --git a/tests/models/CategoryModelTest.php b/tests/models/CategoryModelTest.php deleted file mode 100644 index c4abe4cfb5..0000000000 --- a/tests/models/CategoryModelTest.php +++ /dev/null @@ -1,76 +0,0 @@ - $category->name, - 'user_id' => $category->user_id - ]; - - $result = Category::firstOrCreateEncrypted($search); - - $this->assertEquals($result->id, $category->id); - } - - /** - * @covers FireflyIII\Models\Category::firstOrCreateEncrypted - */ - public function testFirstOrCreateEncryptedNew() - { - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - - $search = [ - 'name' => 'Some category name', - 'user_id' => $category->user_id - ]; - - $result = Category::firstOrCreateEncrypted($search); - - $this->assertNotEquals($result->id, $category->id); - } - -} diff --git a/tests/models/TagModelTest.php b/tests/models/TagModelTest.php deleted file mode 100644 index b4411d1eb1..0000000000 --- a/tests/models/TagModelTest.php +++ /dev/null @@ -1,95 +0,0 @@ - 'something', - 'tag' => $tag->tag, - 'user_id' => $tag->user_id, - ]; - - $result = Tag::firstOrCreateEncrypted($search); - - $this->assertEquals($tag->id, $result->id); - } - - /** - * @covers FireflyIII\Models\Tag::firstOrCreateEncrypted - */ - public function testFirstOrCreateEncryptedNew() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - - $search = [ - 'tagMode' => 'something', - 'tag' => 'Something else', - 'user_id' => $tag->user_id, - ]; - - $result = Tag::firstOrCreateEncrypted($search); - - $this->assertNotEquals($tag->id, $result->id); - } - - /** - * @covers FireflyIII\Models\Tag::save - */ - public function testSave() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - // connect some transaction journals to the tag: - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->tags()->save($tag); - $tag->save(); - $journal = TransactionJournal::find($journal->id); - - $this->assertEquals(1, $journal->tag_count); - - - } - -} diff --git a/tests/models/TransactionJournalModelTest.php b/tests/models/TransactionJournalModelTest.php deleted file mode 100644 index 17d8646557..0000000000 --- a/tests/models/TransactionJournalModelTest.php +++ /dev/null @@ -1,636 +0,0 @@ -transactions[0]->amount = '123.45'; - $journal->transactions[0]->save(); - $journal->transactions[1]->amount = '-123.45'; - $journal->transactions[1]->save(); - - $amount = $journal->actual_amount; - $this->assertEquals('123.45', $amount); - } - - /** - * Journal has one tag. - * - * @covers FireflyIII\Models\TransactionJournal::getAmountAttribute - * @covers FireflyIII\Models\TransactionJournal::amountByTag - * @covers FireflyIII\Models\TransactionJournal::save - * @covers FireflyIII\Models\TransactionJournal::amountByTags - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testGetAmountAttributeAdvancePayment() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - // make types: - $withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $depositType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - // make tag - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'advancePayment'; - $tag->save(); - - // make withdrawal - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $withdrawal->transaction_type_id = $withdrawalType->id; - $withdrawal->save(); - - // make deposit - $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $deposit->transaction_type_id = $depositType->id; - $deposit->save(); - - // make accounts - $expense = FactoryMuffin::create('FireflyIII\Models\Account'); - $revenue = FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - - // transactions are already in place, update them: - $withdrawal->transactions[0]->account_id = $asset->id; - $withdrawal->transactions[0]->amount = -300; - $withdrawal->transactions[0]->save(); - - $withdrawal->transactions[1]->account_id = $expense->id; - $withdrawal->transactions[1]->amount = 300; - $withdrawal->transactions[1]->save(); - - $deposit->transactions[0]->account_id = $revenue->id; - $deposit->transactions[0]->amount = -89.88; - $deposit->transactions[0]->save(); - - $deposit->transactions[1]->account_id = $asset->id; - $deposit->transactions[1]->amount = 89.88; - $deposit->transactions[1]->save(); - - // connect to tag: - $tag->transactionJournals()->save($withdrawal); - $tag->transactionJournals()->save($deposit); - - $withdrawal->save(); - $deposit->save(); - $withdrawal = TransactionJournal::find($withdrawal->id); - $deposit = TransactionJournal::find($deposit->id); - - // amount should be 210.12: - $this->assertEquals('210.12', $withdrawal->amount); - $this->assertEquals('0', $deposit->amount); - - - } - - - /** - * Journal has one tag. - * - * @covers FireflyIII\Models\TransactionJournal::getAmountAttribute - * @covers FireflyIII\Models\TransactionJournal::amountByTag - * @covers FireflyIII\Models\TransactionJournal::amountByTags - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testGetAmountAttributeBalancingAct() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // make types: - $withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $transferType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - // make a tag - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'balancingAct'; - $tag->save(); - - // make a withdrawal and a transfer - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $withdrawal->transaction_type_id = $withdrawalType->id; - $withdrawal->save(); - - $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $transfer->transaction_type_id = $transferType->id; - $transfer->save(); - - // connect to tag: - $tag->transactionJournals()->save($withdrawal); - $tag->transactionJournals()->save($transfer); - - // make accounts: - $expense = FactoryMuffin::create('FireflyIII\Models\Account'); - $revenue = FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - $revenue->account_type_id = $asset->account_type_id; - $revenue->save(); - - // transactions are already in place, update them: - $withdrawal->transactions[0]->account_id = $asset->id; - $withdrawal->transactions[0]->amount = -123.45; - $withdrawal->transactions[0]->save(); - - $withdrawal->transactions[1]->account_id = $expense->id; - $withdrawal->transactions[1]->amount = 123.45; - $withdrawal->transactions[1]->save(); - - $transfer->transactions[0]->account_id = $revenue->id; - $transfer->transactions[0]->amount = -123.45; - $transfer->transactions[0]->save(); - - $transfer->transactions[1]->account_id = $asset->id; - $transfer->transactions[1]->amount = 123.45; - $transfer->transactions[1]->save(); - - $withdrawal->save(); - - $withdrawal = TransactionJournal::find($withdrawal->id); - - $amount = $withdrawal->amount; - - - $this->assertEquals('0', $amount); - } - - /** - * Journal has no tags. - * - * @covers FireflyIII\Models\TransactionJournal::getAmountAttribute - * @covers FireflyIII\Models\TransactionJournal::amountByTag - * @covers FireflyIII\Models\TransactionJournal::amountByTags - */ - public function testGetAmountAttributeNoTags() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - - $journal->transactions[0]->amount = 123.45; - $journal->transactions[0]->save(); - - $journal->transactions[1]->amount = -123.45; - $journal->transactions[1]->save(); - - $amount = $journal->amount; - $this->assertEquals('123.45', $amount); - } - - /** - * - * Journal has one tag. - * - * @covers FireflyIII\Models\TransactionJournal::getAmountAttribute - * @covers FireflyIII\Models\TransactionJournal::amountByTag - * @covers FireflyIII\Models\TransactionJournal::amountByTags - */ - public function testGetAmountAttributeTag() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // has a normal tag, but nothing special. - // make tag - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'nothing'; - $tag->save(); - - // make withdrawal - $withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $withdrawal->transaction_type_id = $withdrawalType->id; - $withdrawal->save(); - - // make accounts - $expense = FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - - $withdrawal->transactions[0]->amount = -300; - $withdrawal->transactions[0]->account_id = $asset->id; - $withdrawal->transactions[0]->save(); - - $withdrawal->transactions[1]->amount = 300; - $withdrawal->transactions[1]->account_id = $expense->id; - $withdrawal->transactions[1]->save(); - - // connect to tag: - $tag->transactionJournals()->save($withdrawal); - - $withdrawal->save(); - $withdrawal = TransactionJournal::find($withdrawal->id); - - $this->assertEquals('300', $withdrawal->amount); - - - } - - /** - * Journal has multiple tags, withdrawal. All default tag. - * - * @covers FireflyIII\Models\TransactionJournal::getAmountAttribute - * @covers FireflyIII\Models\TransactionJournal::amountByTag - * @covers FireflyIII\Models\TransactionJournal::amountByTags - */ - public function testGetAmountAttributeTags() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // has two normal tags: - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'nothing'; - $tag->save(); - $tag2 = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag2->tagMode = 'nothing'; - $tag2->save(); - - // make withdrawal - $withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $withdrawal->transaction_type_id = $withdrawalType->id; - $withdrawal->save(); - - // make accounts - $expense = FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - - $withdrawal->transactions[0]->amount = -300; - $withdrawal->transactions[0]->account_id = $asset->id; - $withdrawal->transactions[0]->save(); - - $withdrawal->transactions[1]->amount = 300; - $withdrawal->transactions[1]->account_id = $expense->id; - $withdrawal->transactions[1]->save(); - - // connect to tag: - $tag->transactionJournals()->save($withdrawal); - $tag2->transactionJournals()->save($withdrawal); - - // grab withdrawal again to update tag count: - $withdrawal->save(); - $withdrawal = TransactionJournal::find($withdrawal->id); - - $this->assertEquals('300', $withdrawal->amount); - - - } - - /** - * Multiple tags, transfer, and one is a balancing act - * - * @covers FireflyIII\Models\TransactionJournal::getAmountAttribute - * @covers FireflyIII\Models\TransactionJournal::amountByTag - * @covers FireflyIII\Models\TransactionJournal::amountByTags - */ - public function testGetAmountAttributeTagsTransfer() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // has two normal tags: - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'balancingAct'; - $tag->save(); - $tag2 = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag2->tagMode = 'nothing'; - $tag2->save(); - - // make withdrawal - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $transferType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $transfer->transaction_type_id = $transferType->id; - $transfer->save(); - - // make accounts - $expense = FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - - $transfer->transactions[0]->amount = -300; - $transfer->transactions[0]->account_id = $asset->id; - $transfer->transactions[0]->save(); - - $transfer->transactions[1]->amount = 300; - $transfer->transactions[1]->account_id = $expense->id; - $transfer->transactions[1]->save(); - - // connect to tag: - $tag->transactionJournals()->save($transfer); - $tag2->transactionJournals()->save($transfer); - - $transfer->save(); - $transfer = TransactionJournal::find($transfer->id); - - $this->assertEquals('300', $transfer->amount); - - - } - - /** - * Multiple tags, transfer, and one is a advance payment. - * - * @covers FireflyIII\Models\TransactionJournal::getAmountAttribute - * @covers FireflyIII\Models\TransactionJournal::amountByTag - * @covers FireflyIII\Models\TransactionJournal::amountByTags - */ - public function testGetAmountAttributeTagsTransferAdvance() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // has two normal tags: - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'advancePayment'; - $tag->save(); - $tag2 = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag2->tagMode = 'nothing'; - $tag2->save(); - - // make withdrawal - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $transferType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $transfer->transaction_type_id = $transferType->id; - $transfer->save(); - - // make accounts - $expense = FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - - $transfer->transactions[0]->amount = -300; - $transfer->transactions[0]->account_id = $asset->id; - $transfer->transactions[0]->save(); - - $transfer->transactions[1]->amount = 300; - $transfer->transactions[1]->account_id = $expense->id; - $transfer->transactions[1]->save(); - - // connect to tag: - $tag->transactionJournals()->save($transfer); - $tag2->transactionJournals()->save($transfer); - - $transfer->save(); - $transfer = TransactionJournal::find($transfer->id); - - $this->assertEquals('300', $transfer->amount); - - - } - - /** - * Multiple tags, withdrawal, and one is a balancingAct. - * - * @covers FireflyIII\Models\TransactionJournal::getAmountAttribute - * @covers FireflyIII\Models\TransactionJournal::amountByTag - * @covers FireflyIII\Models\TransactionJournal::amountByTags - */ - public function testGetAmountAttributeTagsWithdrawalAdvance() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // has two normal tags: - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'balancingAct'; - $tag->save(); - $tag2 = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag2->tagMode = 'nothing'; - $tag2->save(); - - // make withdrawal - $withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $withdrawal->transaction_type_id = $withdrawalType->id; - $withdrawal->save(); - - // make accounts - $expense = FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - - $withdrawal->transactions[0]->amount = -300; - $withdrawal->transactions[0]->account_id = $asset->id; - $withdrawal->transactions[0]->save(); - - $withdrawal->transactions[1]->amount = 300; - $withdrawal->transactions[1]->account_id = $expense->id; - $withdrawal->transactions[1]->save(); - - // connect to tag: - $tag->transactionJournals()->save($withdrawal); - $tag2->transactionJournals()->save($withdrawal); - - $withdrawal->save(); - $withdrawal = TransactionJournal::find($withdrawal->id); - - $this->assertEquals('300', $withdrawal->amount); - - - } - - - /** - * @covers FireflyIII\Models\TransactionJournal::getCorrectAmountAttribute - */ - public function testGetCorrectAmountAttribute() - { - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - - // make accounts - FactoryMuffin::create('FireflyIII\Models\Account'); - $revenue = FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - - // make withdrawal - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->transaction_type_id = $withdrawal->id; - $journal->save(); - - $journal->transactions[0]->account_id = $asset->id; - $journal->transactions[0]->amount = 300; - $journal->transactions[0]->save(); - - $journal->transactions[1]->account_id = $revenue->id; - $journal->transactions[1]->amount = -300; - $journal->transactions[1]->save(); - - // get asset account: - $result = $journal->correct_amount; - - $this->assertEquals(-300, $result); - } - - /** - * @covers FireflyIII\Models\TransactionJournal::getCorrectAmountAttribute - */ - public function testGetCorrectAmountAttributeDeposit() - { - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType'); // deposit - - // make accounts - FactoryMuffin::create('FireflyIII\Models\Account'); - $revenue = FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - - // make withdrawal - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->transaction_type_id = $deposit->id; - $journal->save(); - - $journal->transactions[0]->account_id = $asset->id; - $journal->transactions[0]->amount = 300; - $journal->transactions[0]->save(); - - $journal->transactions[1]->account_id = $revenue->id; - $journal->transactions[1]->amount = -300; - $journal->transactions[1]->save(); - - // get asset account: - $result = $journal->correct_amount; - - $this->assertEquals(300, $result); - } - - /** - * @covers FireflyIII\Models\TransactionJournal::getCorrectAmountAttribute - */ - public function testGetCorrectAmountAttributeTransfer() - { - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // deposit - $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType'); // transfer - - // make accounts - FactoryMuffin::create('FireflyIII\Models\Account'); - $revenue = FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - - // make withdrawal - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->transaction_type_id = $transfer->id; - $journal->save(); - - $journal->transactions[0]->account_id = $asset->id; - $journal->transactions[0]->amount = 300; - $journal->transactions[0]->save(); - - $journal->transactions[1]->account_id = $revenue->id; - $journal->transactions[1]->amount = -300; - $journal->transactions[1]->save(); - - // get asset account: - $result = $journal->correct_amount; - - $this->assertEquals('300', $result); - } - - /** - * @covers FireflyIII\Models\TransactionJournal::getDestinationAccountAttribute - */ - public function testGetDestinationAccountAttribute() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $depositType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $deposit->transaction_type_id = $depositType->id; - $deposit->save(); - - // make accounts - FactoryMuffin::create('FireflyIII\Models\Account'); - $revenue = FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - - $deposit->transactions[0]->account_id = $asset->id; - $deposit->transactions[0]->amount = 300; - $deposit->transactions[0]->save(); - - $deposit->transactions[1]->account_id = $revenue->id; - $deposit->transactions[1]->amount = -300; - $deposit->transactions[1]->save(); - - // get asset account: - $result = $deposit->destination_account; - - $this->assertEquals($asset->id, $result->id); - } - - /** - * @covers FireflyIII\Models\TransactionJournal::getSourceAccountAttribute - */ - public function testGetSourceAccountAttribute() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $depositType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $deposit->transaction_type_id = $depositType->id; - $deposit->save(); - - // make accounts - FactoryMuffin::create('FireflyIII\Models\Account'); - $revenue = FactoryMuffin::create('FireflyIII\Models\Account'); - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); - - $deposit->transactions[0]->account_id = $asset->id; - $deposit->transactions[0]->amount = 300; - $deposit->transactions[0]->save(); - - $deposit->transactions[1]->account_id = $revenue->id; - $deposit->transactions[1]->amount = -300; - $deposit->transactions[1]->save(); - - // get asset account: - $result = $deposit->source_account; - - $this->assertEquals($revenue->id, $result->id); - } - -} diff --git a/tests/repositories/AccountRepositoryTest.php b/tests/repositories/AccountRepositoryTest.php deleted file mode 100644 index 6a17b5d564..0000000000 --- a/tests/repositories/AccountRepositoryTest.php +++ /dev/null @@ -1,891 +0,0 @@ -object = new AccountRepository; - parent::setUp(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::countAccounts - */ - public function testCountAccounts() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $type = $account->accountType->type; - $this->be($account->user); - - $this->assertEquals(1, $this->object->countAccounts([$type])); - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::destroy - * @covers FireflyIII\Providers\EventServiceProvider::boot - * @covers FireflyIII\Providers\EventServiceProvider::registerDeleteEvents - */ - public function testDestroy() - { - // create account: - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - - // create some transactions and attach them to the account: - for ($i = 0; $i < 5; $i++) { - $transaction = FactoryMuffin::create('FireflyIII\Models\Transaction'); - $transaction->account_id = $account->id; - $transaction->save(); - } - - $accountId = $account->id; - $this->be($account->user); - - - $this->object->destroy($account); - - // cannot find account: - $this->assertCount(0, Account::whereId($accountId)->whereNotNull('deleted_at')->get()); - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::getAccounts - */ - public function testGetAccounts() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $type = $account->accountType->type; - $this->be($account->user); - - $this->assertCount(1, $this->object->getAccounts([$type])); - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::getCreditCards - */ - public function testGetCreditCards() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - - // create account meta object: - $meta = new AccountMeta; - $meta->name = 'accountRole'; - $meta->data = 'ccAsset'; - $meta->account_id = $account->id; - $meta->save(); - - // meta account type - $meta = new AccountMeta; - $meta->name = 'ccType'; - $meta->data = 'monthlyFull'; - $meta->account_id = $account->id; - $meta->save(); - - // login - $this->be($account->user); - - // test! - $this->assertCount(1, $this->object->getCreditCards()); - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::getFirstTransaction - */ - public function testGetFirstTransaction() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $first = $journal->transactions()->orderBy('date', 'DESC')->first(); - $first->account_id = $account->id; - $first->save(); - - - // login - $this->be($account->user); - - $oldest = $this->object->getFirstTransaction($journal, $account); - - $this->assertEquals($first->amount, $oldest->amount); - $this->assertEquals($first->id, $oldest->id); - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::getFrontpageAccounts - */ - public function testGetFrontpageAccounts() - { - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - - - // making two account types is kind of cheating but it works. - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - /** @var Preference $preference */ - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->data = []; - $preference->save(); - $this->be($account->user); - - $set = $this->object->getFrontpageAccounts($preference); - - $this->assertEquals($account->id, $set->first()->id); - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::getFrontpageAccounts - */ - public function testGetFrontpageAccountsWithPreference() - { - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - - - // making two account types is kind of cheating but it works. - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - /** @var Preference $preference */ - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->data = [$account->id]; - $preference->save(); - $this->be($account->user); - - $set = $this->object->getFrontpageAccounts($preference); - - $this->assertEquals($account->id, $set->first()->id); - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::getFrontpageTransactions - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testGetFrontpageTransactions() - { - // three journals - /** @var Account $account */ - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal3 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - - // three dates (one is out of bounds) - $journal1->date = new Carbon('2012-01-02'); - $journal1->user_id = $account->user_id; - $journal2->date = new Carbon('2012-01-09'); - $journal2->user_id = $account->user_id; - $journal3->date = new Carbon('2012-02-02'); - $journal3->user_id = $account->user_id; - - // save all - $journal1->save(); - $journal2->save(); - $journal3->save(); - - $journal1->transactions[0]->account_id = $account->id; - $journal1->transactions[0]->save(); - $journal2->transactions[0]->account_id = $account->id; - $journal2->transactions[0]->save(); - $journal3->transactions[0]->account_id = $account->id; - $journal3->transactions[0]->save(); - - // be user - $this->be($journal1->user); - - // get set: - - $set = $this->object->getFrontpageTransactions($account, new Carbon('2012-01-01'), new Carbon('2012-01-31')); - - // should have two left. - $this->assertCount(2, $set); - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::getJournals - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testGetJournals() - { - $date = new Carbon; - // three journals - /** @var Account $account */ - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal3 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - - // three dates (one is out of bounds) - $journal1->date = $date; - $journal1->user_id = $account->user_id; - $journal2->date = $date; - $journal2->user_id = $account->user_id; - $journal3->date = $date; - $journal3->user_id = $account->user_id; - - // save all - $journal1->save(); - $journal2->save(); - $journal3->save(); - - $journal1->transactions[0]->account_id = $account->id; - $journal1->transactions[0]->save(); - $journal2->transactions[0]->account_id = $account->id; - $journal2->transactions[0]->save(); - $journal3->transactions[0]->account_id = $account->id; - $journal3->transactions[0]->save(); - - // be user - $this->be($journal1->user); - - // get paginator: - /** @var LengthAwarePaginator $paginator */ - $paginator = $this->object->getJournals($account, 1); - - // should have three entries: - $this->assertEquals(3, $paginator->count()); - $this->assertEquals(1, $paginator->currentPage()); - $this->assertFalse($paginator->isEmpty()); - - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::getLastActivity - */ - public function testGetLastActivity() - { - $date = new Carbon('2012-02-02'); - // one journal - /** @var Account $account */ - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->date = $date; - $journal->user_id = $account->user_id; - $journal->save(); - - $journal->transactions[0]->account_id = $account->id; - $journal->transactions[0]->save(); - - // be user - $this->be($journal->user); - - $latest = $this->object->getLastActivity($account); - $this->assertEquals($date->format('Y-m-d'), $latest->format('Y-m-d')); - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::getLastActivity - */ - public function testGetLastActivityNoActivity() - { - /** @var Account $account */ - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $this->be($account->user); - - $latest = $this->object->getLastActivity($account); - $this->assertnull($latest); - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::getPiggyBankAccounts - */ - public function testGetPiggyBankAccounts() - { - $date = Carbon::now()->startOfMonth()->addDays(3); - /* - * Quite the collection of objects for this one. - */ - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $piggyBankRepetition = $piggyBank->piggybankRepetitions()->first(); - /* - * Update id's to match each other: - */ - $piggyBankRepetition->currentamount = rand(1, 100); - $piggyBankRepetition->startdate = $date; - $piggyBankRepetition->targetdate = $date; - $piggyBank->account_id = $account->id; - $piggyBankRepetition->save(); - $piggyBank->save(); - - /* - * Put dates in session: - */ - $this->session(['start' => Carbon::now()->startOfMonth(), 'end' => Carbon::now()->endOfMonth()]); - - /* - * Run method: - */ - $this->be($account->user); - $collection = $this->object->getPiggyBankAccounts(); - - $this->assertCount(1, $collection); - $this->assertEquals($collection->first()->id, $account->id); - $this->assertEquals($collection->first()->piggyBalance, $piggyBankRepetition->currentamount); - $this->assertEquals(0, $collection->first()->startBalance); - $this->assertEquals(0, $collection->first()->endBalance); - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::getSavingsAccounts - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testGetSavingsAccounts() - { - // create three accounts: - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - $type = FactoryMuffin::create('FireflyIII\Models\AccountType'); - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account1->account_type_id = $type->id; - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2->account_type_id = $type->id; - $account3 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account3->account_type_id = $type->id; - - // make them savings accounts: - $meta = new AccountMeta; - $meta->name = 'accountRole'; - $meta->data = 'savingAsset'; - $meta->account_id = $account1->id; - $meta->save(); - - $meta = new AccountMeta; - $meta->name = 'accountRole'; - $meta->data = 'savingAsset'; - $meta->account_id = $account2->id; - $meta->save(); - - $meta = new AccountMeta; - $meta->name = 'accountRole'; - $meta->data = 'savingAsset'; - $meta->account_id = $account3->id; - $meta->save(); - - // assign to the same user: - $account2->user_id = $account1->user_id; - $account3->user_id = $account1->user_id; - $account1->save(); - $account2->save(); - $account3->save(); - $this->be($account1->user); - - // mock steam balance: - Steam::shouldReceive('balance')->andReturn(0, 0, 1, 2, 4, 3); - - // get the result from the method: - $result = $this->object->getSavingsAccounts(); - - $this->assertEquals(0, $result->get(0)->difference); - $this->assertEquals(1, $result->get(1)->difference); - $this->assertEquals(-1, $result->get(2)->difference); - - $this->assertEquals(100, $result->get(0)->percentage); - $this->assertEquals(100, $result->get(1)->percentage); - $this->assertEquals(25, $result->get(2)->percentage); - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::getTransfersInRange - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testGetTransfersInRange() - { - FactoryMuffin::create('FireflyIII\Models\Account'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // deposit - FactoryMuffin::create('FireflyIII\Models\AccountType'); // expense - FactoryMuffin::create('FireflyIII\Models\AccountType'); // revenue - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); // asset - $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType'); // transfer - $user = FactoryMuffin::create('FireflyIII\User'); // user! - $accounts = []; - $opposings = []; // opposing accounts. - $journals = []; - // dates - $start = new Carbon('2014-01-01'); - $end = new Carbon('2014-01-31'); - $inRange = new Carbon('2014-01-15'); - $before = new Carbon('2013-01-15'); - - // create two accounts: - for ($i = 0; $i < 2; $i++) { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $account->account_type_id = $asset->id; - $account->user_id = $user->id; - $account->save(); - $accounts[] = $account; - - $opposing = FactoryMuffin::create('FireflyIII\Models\Account'); - $opposing->account_type_id = $asset->id; - $opposing->user_id = $user->id; - $opposing->save(); - $opposings[] = $opposing; - } - - // for each account, create ten journals - foreach ($accounts as $index => $account) { - for ($i = 0; $i < 10; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->user_id = $user->id; - $journal->transaction_type_id = $transfer->id; - $journal->save(); - - // if $i < 6, transfer is in range: - if ($i < 6) { - $journal->date = $inRange; - } else { - $journal->date = $before; - } - - /* - * Transfers can go either way (see the amount) - */ - if ($i < 4) { - $amount = 100; - } else { - $amount = -100; - } - - - $journal->transactions[0]->account_id = $account->id; - $journal->transactions[0]->amount = $amount; - $journal->transactions[1]->account_id = $opposings[$index]->id; - $journal->transactions[1]->amount = $amount * -1; - $journal->transactions[0]->save(); - $journal->transactions[1]->save(); - // save journal: - $journal->save(); - $journals[] = $journal; - } - } - $this->be($user); - - $set = $this->object->getTransfersInRange($accounts[0], $start, $end); - - $this->assertEquals(4, $set->count()); - $this->assertEquals(100, $set->first()->amount); - $this->assertEquals($journals[0]->description, $set->first()->description); - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::leftOnAccount - */ - public function testLeftOnAccount() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $piggyBankRepetition = $piggyBank->piggybankRepetitions()->first(); - $piggyBankRepetition->currentamount = rand(1, 100); - $piggyBankRepetition->save(); - $this->be($piggyBank->account->user); - - - $result = $this->object->leftOnAccount($piggyBank->account, new Carbon); - - $this->assertEquals($piggyBankRepetition->currentamount * -1, $result); - - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::openingBalanceTransaction - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testOpeningBalanceTransaction() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - - // dates - $one = new Carbon('2013-01-15'); - $two = new Carbon('2015-01-15'); - - // journal 1 will match: - $journal1->date = $one; - $journal1->user_id = $account->user_id; - $journal2->date = $two; - $journal2->user_id = $account->user_id; - - // add account things: - $journal1->transactions[0]->account_id = $account->id; - $journal1->transactions[1]->account_id = $account->id; - $journal2->transactions[0]->account_id = $account->id; - $journal2->transactions[1]->account_id = $account->id; - $journal1->transactions[0]->save(); - $journal1->transactions[1]->save(); - $journal2->transactions[0]->save(); - $journal2->transactions[1]->save(); - - - $journal1->save(); - $journal2->save(); - - - $this->be($account->user); - - $result = $this->object->openingBalanceTransaction($account); - $this->assertEquals($journal1->id, $result->id); - $this->assertEquals($journal1->description, $result->description); - $this->assertEquals(100, $result->amount); - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::openingBalanceTransaction - */ - public function testOpeningBalanceTransactionNull() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $this->be($account->user); - - $result = $this->object->openingBalanceTransaction($account); - $this->assertNull($result); - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::store - * @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount - * @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata - * @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance - * - */ - public function testStore() - { - $user = FactoryMuffin::create('FireflyIII\User'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $this->be($user); - - $data = [ - 'accountType' => 'expense', - 'user' => $user->id, - 'name' => 'Test account #' . rand(1, 100), - 'active' => true, - 'accountRole' => 'testAccount', - 'openingBalance' => 100, - 'virtualBalance' => 0, - 'openingBalanceCurrency' => $currency->id, - 'openingBalanceDate' => '2015-01-01', - ]; - - - $account = $this->object->store($data); - - $this->assertEquals($data['name'], $account->name); - - } - - /** - * This function should give a big fat error, but it doesnt. - * - * @covers FireflyIII\Repositories\Account\AccountRepository::store - * @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount - * @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata - * @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance - */ - public function testStoreWithExistingAccount() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); // expense - FactoryMuffin::create('FireflyIII\Models\AccountType'); // revenue - FactoryMuffin::create('FireflyIII\Models\AccountType'); // asset - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // deposit - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // transfer - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $this->be($account->user); - - - $data = [ - 'accountType' => 'expense', - 'user' => $account->user->id, - 'name' => $account->name, - 'active' => $account->active, - 'accountRole' => 'testAccount', - 'openingBalance' => 0, - 'virtualBalance' => 0, - 'openingBalanceCurrency' => $currency->id, - 'openingBalanceDate' => '2015-01-01', - ]; - - $newAccount = $this->object->store($data); - - $this->assertEquals($account->name, $newAccount->name); - $this->assertEquals($account->id, $newAccount->id); - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::store - * @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount - * @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata - * @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException - */ - public function testStoreWithInvalidAccountData() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $this->be($account->user); - - - $data = [ - 'accountType' => 'expense', - 'user' => $account->user->id + 12, - 'name' => $account->name, - 'active' => $account->active, - 'accountRole' => 'testAccount', - 'openingBalance' => 0, - 'virtualBalance' => 0, - 'openingBalanceCurrency' => $currency->id, - 'openingBalanceDate' => '2015-01-01', - ]; - - $this->object->store($data); - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::store - * @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount - * @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata - * @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance - */ - public function testStoreWithNegativeInitialBalance() - { - $user = FactoryMuffin::create('FireflyIII\User'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $this->be($user); - - $data = [ - 'accountType' => 'expense', - 'user' => $user->id, - 'name' => 'Test account #' . rand(1, 100), - 'active' => true, - 'accountRole' => 'testAccount', - 'openingBalance' => -100, - 'virtualBalance' => 0, - 'openingBalanceCurrency' => $currency->id, - 'openingBalanceDate' => '2015-01-01', - ]; - - - $account = $this->object->store($data); - - $this->assertEquals($data['name'], $account->name); - $this->assertEquals(-100, $account->transactions()->first()->amount); - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::sumOfEverything - */ - public function testSumOfEverything() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $this->assertEquals(0, $this->object->sumOfEverything()); - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::update - * @covers FireflyIII\Repositories\Account\AccountRepository::updateMetadata - * @covers FireflyIII\Repositories\Account\AccountRepository::updateInitialBalance - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testUpdate() - { - $user = FactoryMuffin::create('FireflyIII\User'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $this->be($user); - - $data = [ - 'accountType' => 'expense', - 'user' => $user->id, - 'name' => 'Test account #' . rand(1, 100), - 'active' => true, - 'accountRole' => 'testAccount', - 'openingBalance' => 100, - 'virtualBalance' => 0, - 'openingBalanceCurrency' => $currency->id, - 'openingBalanceDate' => '2015-01-01', - ]; - - - $account = $this->object->store($data); - - // now update that same account: - $data = [ - 'name' => 'New account name' . rand(0, 100), - 'active' => 1, - 'virtualBalance' => 0, - 'openingBalance' => 50, - 'openingBalanceCurrency' => $currency->id, - 'openingBalanceDate' => '2015-02-02', - ]; - - $newAccount = $this->object->update($account, $data); - - $this->assertEquals($data['name'], $newAccount->name); - $this->assertEquals(50, $account->transactions()->first()->amount); - - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::update - * @covers FireflyIII\Repositories\Account\AccountRepository::updateMetadata - * @covers FireflyIII\Repositories\Account\AccountRepository::updateInitialBalance - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testUpdateDeleteOpeningBalance() - { - $user = FactoryMuffin::create('FireflyIII\User'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $this->be($user); - - $data = [ - 'accountType' => 'expense', - 'user' => $user->id, - 'name' => 'Test account #' . rand(1, 100), - 'active' => true, - 'accountRole' => 'testAccount', - 'openingBalance' => 100, - 'virtualBalance' => 0, - 'openingBalanceCurrency' => $currency->id, - 'openingBalanceDate' => '2015-01-01', - ]; - - - $account = $this->object->store($data); - - // now update that same account: - $data = [ - 'name' => 'New account name' . rand(0, 100), - 'active' => 1, - 'user' => $user->id, - 'accountRole' => 'testAccount', - 'virtualBalance' => 0, - 'openingBalance' => 0, - ]; - - $newAccount = $this->object->update($account, $data); - - $this->assertEquals($data['name'], $newAccount->name); - $this->assertEquals(0, $newAccount->transactions()->whereNull('deleted_at')->count()); - - - } - - /** - * @covers FireflyIII\Repositories\Account\AccountRepository::update - * @covers FireflyIII\Repositories\Account\AccountRepository::updateMetadata - * @covers FireflyIII\Repositories\Account\AccountRepository::updateInitialBalance - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testUpdateNewOpeningBalance() - { - $user = FactoryMuffin::create('FireflyIII\User'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $this->be($user); - - $data = [ - 'accountType' => 'expense', - 'user' => $user->id, - 'name' => 'Test account #' . rand(1, 100), - 'active' => true, - 'accountRole' => 'testAccount', - 'openingBalance' => 0, - 'virtualBalance' => 0, - ]; - - - $account = $this->object->store($data); - - // now update that same account: - $data = [ - 'name' => 'New account name' . rand(0, 100), - 'active' => 1, - 'user' => $user->id, - 'virtualBalance' => 0, - 'accountRole' => 'testAccount', - 'ccMonthlyPaymentDate' => '2015-01-01', - 'openingBalance' => 51, - 'openingBalanceCurrency' => $currency->id, - 'openingBalanceDate' => '2015-02-02', - ]; - - $newAccount = $this->object->update($account, $data); - - $this->assertEquals($data['name'], $newAccount->name); - $this->assertEquals(51, $account->transactions()->first()->amount); - - - } -} diff --git a/tests/repositories/BillRepositoryTest.php b/tests/repositories/BillRepositoryTest.php deleted file mode 100644 index 36356391f5..0000000000 --- a/tests/repositories/BillRepositoryTest.php +++ /dev/null @@ -1,467 +0,0 @@ -object = new BillRepository; - parent::setUp(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - } - - public function testBillPaymentsInRange() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $start = Carbon::now()->startOfMonth(); - $end = Carbon::now()->endOfMonth(); - - // payment: - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->date = $start; - $journal->bill_id = $bill->id; - $journal->save(); - - - $this->object->billPaymentsInRange($bill, $start, $end); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::createFakeBill - */ - public function testCreateFakeBill() - { - $description = 'Fake bill ' . rand(10, 100); - $date = new Carbon('2013-01-01'); - $amount = 1200; - $bill = $this->object->createFakeBill($description, $date, $amount); - - $this->assertEquals($amount, $bill->amount_max); - $this->assertEquals($amount, $bill->amount_min); - $this->assertNull($bill->id); - $this->assertEquals($description, $bill->name); - - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::destroy - */ - public function testDestroy() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $accountId = $bill->id; - $this->object->destroy($bill); - - // cannot find bill: - $this->assertCount(0, Bill::whereId($accountId)->whereNotNull('deleted_at')->get()); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::getActiveBills - */ - public function testGetActiveBills() - { - $bill1 = FactoryMuffin::create('FireflyIII\Models\Bill'); - $bill2 = FactoryMuffin::create('FireflyIII\Models\Bill'); - - // update bills - $bill1->active = 1; - $bill2->active = 0; - $bill2->user_id = $bill1->user_id; - $bill1->save(); - $bill2->save(); - $this->be($bill1->user); - - $set = $this->object->getActiveBills(); - - $this->assertCount(1, $set); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::getBills - */ - public function testGetBills() - { - $bill1 = FactoryMuffin::create('FireflyIII\Models\Bill'); - $bill2 = FactoryMuffin::create('FireflyIII\Models\Bill'); - - // update bills - $bill1->active = 1; - $bill2->active = 0; - $bill2->user_id = $bill1->user_id; - $bill1->save(); - $bill2->save(); - $this->be($bill1->user); - - $set = $this->object->getBills(); - - $this->assertCount(2, $set); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::getJournals - */ - public function testGetJournals() - { - $bill1 = FactoryMuffin::create('FireflyIII\Models\Bill'); - - // update bills - $bill1->active = 1; - $bill1->save(); - $this->be($bill1->user); - - $set = $this->object->getJournals($bill1); - - $this->assertCount(0, $set); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::getJournalsInRange - */ - public function testGetJournalsInRange() - { - $bill1 = FactoryMuffin::create('FireflyIII\Models\Bill'); - - // update bills - $bill1->active = 1; - $bill1->save(); - $this->be($bill1->user); - - $set = $this->object->getJournalsInRange($bill1, new Carbon, new Carbon); - - $this->assertCount(0, $set); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::getPossiblyRelatedJournals - */ - public function testGetPossiblyRelatedJournals() - { - $bill1 = FactoryMuffin::create('FireflyIII\Models\Bill'); - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - $bill1->amount_min = 100; - $bill1->amount_max = 1000; - $account->user_id = $bill1->user_id; - $bill1->save(); - $account->save(); - - // create some transactions to match our bill: - for ($i = 0; $i < 8; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->user_id = $bill1->user_id; - $journal->save(); - $journal->transactions[0]->account_id = $account->id; - $journal->transactions[0]->save(); - } - $this->be($bill1->user); - - $set = $this->object->getPossiblyRelatedJournals($bill1); - $this->assertCount(8, $set); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::getRanges - */ - public function testGetRanges() - { - $bill1 = FactoryMuffin::create('FireflyIII\Models\Bill'); - $bill1->date = new Carbon('2012-01-01'); - $bill1->repeat_freq = 'monthly'; - $bill1->save(); - - $set = $this->object->getRanges($bill1, new Carbon('2012-01-01'), new Carbon('2012-12-31')); - - $this->assertCount(12, $set); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::lastFoundMatch - */ - public function testLastFoundMatch() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->bill_id = $bill->id; - $journal->user_id = $bill->user_id; - $journal->save(); - - $this->be($bill->user); - - $date = $this->object->lastFoundMatch($bill); - - $this->assertEquals($journal->date->format('Y-m-d'), $date->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::lastFoundMatch - */ - public function testLastFoundMatchNull() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - - $this->be($bill->user); - - $date = $this->object->lastFoundMatch($bill); - - $this->assertNull($date); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::nextExpectedMatch - */ - public function testNextExpectedMatch() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $bill->date = new Carbon('2012-01-07'); - $bill->repeat_freq = 'monthly'; - $bill->save(); - $this->be($bill->user); - - // journal: - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->date = Carbon::now()->format('Y-m-d'); - $journal->user_id = $bill->user_id; - $journal->bill_id = $bill->id; - $journal->save(); - - $next = $this->object->nextExpectedMatch($bill); - $today = Carbon::now()->endOfMonth()->addDay(); - $this->assertEquals($today->format('Y-m-d'), $next->format('Y-m-d')); - - - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::nextExpectedMatch - */ - public function testNextExpectedMatchInactive() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $bill->active = 0; - $bill->save(); - $this->be($bill->user); - - $this->assertNull($this->object->nextExpectedMatch($bill)); - - - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::nextExpectedMatch - */ - public function testNextExpectedMatchNoJournals() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $bill->date = new Carbon('2012-01-07'); - $bill->repeat_freq = 'monthly'; - $bill->save(); - - $this->be($bill->user); - - $next = $this->object->nextExpectedMatch($bill); - $today = Carbon::now()->startOfMonth(); - $this->assertEquals($today->format('Y-m-d'), $next->format('Y-m-d')); - - - } - - - /** - * One - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * - * @covers FireflyIII\Repositories\Bill\BillRepository::scan - * @covers FireflyIII\Repositories\Bill\BillRepository::doWordMatch - * @covers FireflyIII\Repositories\Bill\BillRepository::doAmountMatch - */ - public function testScanMatch() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $bill->date = new Carbon('2012-01-07'); - $bill->repeat_freq = 'monthly'; - $bill->match = 'jemoeder'; - $bill->amount_min = 90; - $bill->amount_max = 110; - $bill->save(); - $this->be($bill->user); - - // journal: - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->date = Carbon::now()->format('Y-m-d'); - $journal->description = 'jemoeder'; - $journal->user_id = $bill->user_id; - $journal->save(); - - $this->object->scan($bill, $journal); - $newJournal = TransactionJournal::find($journal->id); - - $this->assertEquals($bill->id, $newJournal->bill_id); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::scan - * @covers FireflyIII\Repositories\Bill\BillRepository::doWordMatch - * @covers FireflyIII\Repositories\Bill\BillRepository::doAmountMatch - */ - public function testScanNoMatch() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $bill->date = new Carbon('2012-01-07'); - $bill->repeat_freq = 'monthly'; - $bill->save(); - $this->be($bill->user); - - // journal: - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->date = Carbon::now()->format('Y-m-d'); - $journal->user_id = $bill->user_id; - $journal->save(); - - // two transactions: - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - Transaction::create( - [ - 'account_id' => $account1->id, - 'transaction_journal_id' => $journal->id, - 'amount' => 100, - ] - ); - Transaction::create( - [ - 'account_id' => $account2->id, - 'transaction_journal_id' => $journal->id, - 'amount' => 100, - ] - ); - - $this->object->scan($bill, $journal); - $newJournal = TransactionJournal::find($journal->id); - - $this->assertNull($newJournal->bill_id); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::scan - * @covers FireflyIII\Repositories\Bill\BillRepository::doWordMatch - * @covers FireflyIII\Repositories\Bill\BillRepository::doAmountMatch - */ - public function testScanNoMatchButAttached() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $bill->date = new Carbon('2012-01-07'); - $bill->match = 'blablabla'; - $bill->repeat_freq = 'monthly'; - $bill->save(); - $this->be($bill->user); - - // journal: - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->date = Carbon::now()->format('Y-m-d'); - $journal->user_id = $bill->user_id; - $journal->bill_id = $bill->id; - $journal->save(); - - // two transactions: - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - Transaction::create( - [ - 'account_id' => $account1->id, - 'transaction_journal_id' => $journal->id, - 'amount' => 100, - ] - ); - Transaction::create( - [ - 'account_id' => $account2->id, - 'transaction_journal_id' => $journal->id, - 'amount' => 100, - ] - ); - - $this->object->scan($bill, $journal); - $newJournal = TransactionJournal::find($journal->id); - - $this->assertNull($newJournal->bill_id); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::store - */ - public function testStore() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $data = [ - 'name' => 'Something', - 'match' => 'Something', - 'amount_min' => 100, - 'user' => $user->id, - 'amount_max' => 110, - 'date' => new Carbon, - 'repeat_freq' => 'monthly', - 'skip' => 0, - 'automatch' => 1, - 'active' => 1, - - ]; - $bill = $this->object->store($data); - - $this->assertEquals($data['name'], $bill->name); - } - - /** - * @covers FireflyIII\Repositories\Bill\BillRepository::update - */ - public function testUpdate() - { - $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); - $data = [ - 'name' => 'new Name', - 'match' => $bill->match, - 'amount_min' => 100, - 'amount_max' => 110, - 'date' => new Carbon, - 'repeat_freq' => 'monthly', - 'skip' => 0, - 'automatch' => 1, - 'active' => 1, - - ]; - $newBill = $this->object->update($bill, $data); - - $this->assertEquals($data['name'], $newBill->name); - $this->assertEquals($bill->match, $newBill->match); - } -} diff --git a/tests/repositories/BudgetRepositoryTest.php b/tests/repositories/BudgetRepositoryTest.php deleted file mode 100644 index f172274f1e..0000000000 --- a/tests/repositories/BudgetRepositoryTest.php +++ /dev/null @@ -1,399 +0,0 @@ -object = new BudgetRepository; - parent::setUp(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::cleanupBudgets - * @covers FireflyIII\Providers\EventServiceProvider::boot - */ - public function testCleanupBudgets() - { - // create some budgets: - for ($i = 0; $i < 3; $i++) { - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $limit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit'); - $limit->budget_id = $budget->id; - $limit->amount = 0; - $limit->save(); - } - - - $this->object->cleanupBudgets(); - - $this->assertCount(0, BudgetLimit::get()); - - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::destroy - */ - public function testDestroy() - { - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - - $this->object->destroy($budget); - - $this->assertCount(0, Budget::where('id', $budget->id)->whereNull('deleted_at')->get()); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::expensesOnDayCorrected - */ - public function testExpensesOnDayCorrected() - { - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - - $result = $this->object->expensesOnDayCorrected($budget, new Carbon); - - $this->assertEquals(0, $result); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getActiveBudgets - */ - public function testGetActiveBudgets() - { - $budget1 = FactoryMuffin::create('FireflyIII\Models\Budget'); - $budget2 = FactoryMuffin::create('FireflyIII\Models\Budget'); - $budget1->active = 1; - $budget2->active = 0; - $budget2->user_id = $budget1->user_id; - $budget1->save(); - $budget2->save(); - $this->be($budget1->user); - - $set = $this->object->getActiveBudgets(); - - $this->assertCount(1, $set); - $this->assertEquals($set->first()->id, $budget1->id); - - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getBudgetLimitRepetitions - */ - public function testGetBudgetLimitRepetitions() - { - $rep = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); - $limit = $rep->budgetlimit; - $limit->startdate = new Carbon('2015-02-02'); - $rep->startdate = new Carbon('2015-02-02'); - $rep->enddate = new Carbon('2015-02-28'); - $limit->save(); - $rep->save(); - - $set = $this->object->getBudgetLimitRepetitions($rep->budgetlimit->budget, new Carbon('2015-02-01'), new Carbon('2015-02-28')); - $this->assertCount(2, $set); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getBudgetLimits - */ - public function testGetBudgetLimits() - { - /** @var Budget $budget */ - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $set = $this->object->getBudgetLimits($budget); - - $this->assertCount(0, $set); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getBudgets - */ - public function testGetBudgets() - { - $budget1 = FactoryMuffin::create('FireflyIII\Models\Budget'); - $budget2 = FactoryMuffin::create('FireflyIII\Models\Budget'); - $budget1->active = 1; - $budget2->active = 0; - $budget2->user_id = $budget1->user_id; - $budget1->save(); - $budget2->save(); - $this->be($budget1->user); - - $set = $this->object->getBudgets(); - - $this->assertCount(2, $set); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getCurrentRepetition - */ - public function testGetCurrentRepetition() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - /** @var Budget $budget */ - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $rep = $this->object->getCurrentRepetition($budget, new Carbon); - $this->assertNull($rep); - - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getFirstBudgetLimitDate - */ - public function testGetFirstBudgetLimitDate() - { - /** @var BudgetLimit $budget */ - $limit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit'); - $date = $this->object->getFirstBudgetLimitDate($limit->budget); - $this->assertEquals($date->format('Y-m-d'), $limit->startdate->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getFirstBudgetLimitDate - */ - public function testGetFirstBudgetLimitDateNull() - { - /** @var Budget $budget */ - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $date = $this->object->getFirstBudgetLimitDate($budget); - $ownDate = Carbon::now()->startOfYear(); - $this->assertEquals($date->format('Y-m-d'), $ownDate->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getInactiveBudgets - */ - public function testGetInactiveBudgets() - { - $budget1 = FactoryMuffin::create('FireflyIII\Models\Budget'); - $budget2 = FactoryMuffin::create('FireflyIII\Models\Budget'); - $budget1->active = 1; - $budget2->active = 0; - $budget2->user_id = $budget1->user_id; - $budget1->save(); - $budget2->save(); - $this->be($budget1->user); - - $set = $this->object->getInactiveBudgets(); - - $this->assertCount(1, $set); - $this->assertEquals($set->first()->id, $budget2->id); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getJournals - */ - public function testGetJournals() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); - - $set = $this->object->getJournals($repetition->budgetlimit->budget, $repetition); - $this->assertTrue($set instanceof LengthAwarePaginator); - $this->assertCount(0, $set); - $this->assertEquals(1, $set->currentPage()); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getLastBudgetLimitDate - */ - public function testGetLastBudgetLimitDate() - { - /** @var BudgetLimit $budget */ - $limit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit'); - $date = $this->object->getLastBudgetLimitDate($limit->budget); - $this->assertEquals($date->format('Y-m-d'), $limit->startdate->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getLastBudgetLimitDate - */ - public function testGetLastBudgetLimitDateNull() - { - - /** @var Budget $budget */ - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $date = $this->object->getLastBudgetLimitDate($budget); - $ownDate = Carbon::now()->startOfYear(); - $this->assertEquals($date->format('Y-m-d'), $ownDate->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getLimitAmountOnDate - */ - public function testGetLimitAmountOnDate() - { - $rep = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); - - $amount = $this->object->getLimitAmountOnDate($rep->budgetlimit->budget, $rep->startdate); - - $this->assertEquals($rep->amount, $amount); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getLimitAmountOnDate - */ - public function testGetLimitAmountOnDateNull() - { - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - - $amount = $this->object->getLimitAmountOnDate($budget, new Carbon); - - $this->assertNull($amount); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getWithoutBudget - */ - public function testGetWithoutBudget() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $set = $this->object->getWithoutBudget(new Carbon, new Carbon); - $this->assertCount(0, $set); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::getWithoutBudgetSum - */ - public function testGetWithoutBudgetSum() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $sum = $this->object->getWithoutBudgetSum(new Carbon, new Carbon); - $this->assertEquals(0, $sum); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::spentInPeriodCorrected - * @covers FireflyIII\Repositories\Shared\ComponentRepository::spentInPeriod - */ - public function testSpentInPeriodCorrected() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - - $amount = $this->object->spentInPeriodCorrected($budget, new Carbon, new Carbon, false); - $this->assertEquals(0, $amount); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::spentInPeriodCorrected - * @covers FireflyIII\Repositories\Shared\ComponentRepository::spentInPeriod - */ - public function testSpentInPeriodCorrectedShared() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - - $amount = $this->object->spentInPeriodCorrected($budget, new Carbon, new Carbon, true); - $this->assertEquals(0, $amount); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::store - */ - public function testStore() - { - $user = FactoryMuffin::create('FireflyIII\User'); - - $data = [ - 'name' => 'new budget ' . rand(1, 100), - 'user' => $user->id - ]; - $result = $this->object->store($data); - - $this->assertTrue($result instanceof Budget); - $this->assertEquals($result->name, $data['name']); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::update - */ - public function testUpdate() - { - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - - $data = [ - 'name' => 'update budget ' . rand(1, 100), - 'active' => true - ]; - $result = $this->object->update($budget, $data); - - $this->assertTrue($result instanceof Budget); - $this->assertEquals($result->name, $data['name']); - $this->assertEquals($result->id, $budget->id); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::updateLimitAmount - */ - public function testUpdateLimitAmount() - { - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - - $result = $this->object->updateLimitAmount($budget, new Carbon, 100); - - $this->assertTrue($result instanceof BudgetLimit); - $this->assertEquals($result->amount, 100); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::updateLimitAmount - */ - public function testUpdateLimitAmountExisting() - { - $budgetLimit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit'); - - $result = $this->object->updateLimitAmount($budgetLimit->budget, $budgetLimit->startdate, 100); - - $this->assertTrue($result instanceof BudgetLimit); - $this->assertEquals($result->amount, 100); - } - - /** - * @covers FireflyIII\Repositories\Budget\BudgetRepository::updateLimitAmount - */ - public function testUpdateLimitAmountZero() - { - $budgetLimit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit'); - - $result = $this->object->updateLimitAmount($budgetLimit->budget, $budgetLimit->startdate, 0); - - $this->assertTrue($result instanceof BudgetLimit); - } -} diff --git a/tests/repositories/CategoryRepositoryTest.php b/tests/repositories/CategoryRepositoryTest.php deleted file mode 100644 index 63ed85ee83..0000000000 --- a/tests/repositories/CategoryRepositoryTest.php +++ /dev/null @@ -1,290 +0,0 @@ -object = new CategoryRepository; - parent::setUp(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::countJournals - */ - public function testCountJournals() - { - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $result = $this->object->countJournals($category); - - $this->assertEquals(0, $result); - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::destroy - */ - public function testDestroy() - { - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->object->destroy($category); - - $count = Category::where('id', $category->id)->whereNull('deleted_at')->count(); - $this->assertEquals(0, $count); - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::getCategories - */ - public function testGetCategories() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $cat1 = FactoryMuffin::create('FireflyIII\Models\Category'); - $cat2 = FactoryMuffin::create('FireflyIII\Models\Category'); - $cat1->name = 'BBBBB'; - $cat2->name = 'AAAAA'; - $cat1->user_id = $user->id; - $cat2->user_id = $user->id; - $cat1->save(); - $cat2->save(); - $this->be($user); - - $set = $this->object->getCategories(); - $this->assertEquals('AAAAA', $set->first()->name); - $this->assertCount(2, $set); - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::getCategoriesAndExpensesCorrected - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testGetCategoriesAndExpensesCorrected() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); // something - - // some dates: - $start = new Carbon('2014-01-01'); - $end = new Carbon('2014-01-31'); - $inRange = new Carbon('2014-01-12'); - - // generate three categories - // with ten journals each: - for ($i = 0; $i < 3; $i++) { - // category: - /** @var Category $category */ - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $category->user_id = $user->id; - $category->save(); - - for ($j = 0; $j < 10; $j++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->user_id = $user->id; - $journal->transaction_currency_id = $currency->id; - $journal->transaction_type_id = $type->id; // make it a withdrawal - $journal->date = $inRange; - $journal->save(); - // connect to category: - $category->transactionjournals()->save($journal); - } - } - - $this->be($user); - $set = $this->object->getCategoriesAndExpensesCorrected($start, $end); - $this->assertCount(3, $set); - reset($set); - - // 10 journals of 100 each = 1000. - $this->assertEquals('1000', current($set)['sum']); - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::getFirstActivityDate - */ - public function testGetFirstActivityDate() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - /** @var Category $category */ - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $journal->user_id = $user->id; - $journal->date = new Carbon('2015-02-11'); - $category->user_id = $user->id; - $category->transactionjournals()->save($journal); - $journal->save(); - $category->save(); - - $this->be($user); - - $date = $this->object->getFirstActivityDate($category); - $this->assertEquals('2015-02-11', $date->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::getFirstActivityDate - */ - public function testGetFirstActivityDateNull() - { - /** @var Category $category */ - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->be($category->user); - - $date = $this->object->getFirstActivityDate($category); - $this->assertEquals(Carbon::now()->format('Y-m-d'), $date->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::getJournals - */ - public function testGetJournals() - { - - /** @var Category $category */ - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->be($category->user); - $set = $this->object->getJournals($category, 1); - - $this->assertEquals(0, $set->count()); - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::getLatestActivity - */ - public function testGetLatestActivity() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - /** @var Category $category */ - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $journal->user_id = $user->id; - $journal->date = new Carbon('2015-02-11'); - $category->user_id = $user->id; - $category->transactionjournals()->save($journal); - $journal->save(); - $category->save(); - - $this->be($user); - - $date = $this->object->getLatestActivity($category); - $this->assertEquals('2015-02-11', $date->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::getWithoutCategory - */ - public function testGetWithoutCategory() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $set = $this->object->getWithoutCategory(new Carbon, new Carbon); - $this->assertCount(0, $set); - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::spentInPeriodCorrected - * @covers FireflyIII\Repositories\Shared\ComponentRepository::spentInPeriod - */ - public function testSpentInPeriodSumCorrected() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $sum = $this->object->spentInPeriodCorrected($category, new Carbon, new Carbon, false); - - $this->assertEquals(0, $sum); - - - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::spentInPeriodCorrected - * @covers FireflyIII\Repositories\Shared\ComponentRepository::spentInPeriod - */ - public function testSpentInPeriodSumCorrectedShared() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $sum = $this->object->spentInPeriodCorrected($category, new Carbon, new Carbon, true); - - $this->assertEquals(0, $sum); - - - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::spentOnDaySumCorrected - */ - public function testSpentOnDaySumCorrected() - { - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $sum = $this->object->spentOnDaySumCorrected($category, new Carbon); - - $this->assertEquals(0, $sum); - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::store - */ - public function testStore() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $data = [ - 'name' => 'New category' . rand(1, 100), - 'user' => $user->id - ]; - $newCategory = $this->object->store($data); - - $this->assertEquals($data['name'], $newCategory->name); - } - - /** - * @covers FireflyIII\Repositories\Category\CategoryRepository::update - */ - public function testUpdate() - { - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $data = [ - 'name' => 'New category' . rand(1, 100), - ]; - $newCategory = $this->object->update($category, $data); - - $this->assertEquals($data['name'], $newCategory->name); - } - - public function testgetLatestActivityNull() - { - /** @var Category $category */ - $category = FactoryMuffin::create('FireflyIII\Models\Category'); - $this->be($category->user); - - $date = $this->object->getLatestActivity($category); - $this->assertNull($date); - } -} diff --git a/tests/repositories/CurrencyRepositoryTest.php b/tests/repositories/CurrencyRepositoryTest.php deleted file mode 100644 index a8d09b43f3..0000000000 --- a/tests/repositories/CurrencyRepositoryTest.php +++ /dev/null @@ -1,114 +0,0 @@ -object = new CurrencyRepository; - parent::setUp(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - } - - /** - * @covers FireflyIII\Repositories\Currency\CurrencyRepository::countJournals - */ - public function testCountJournals() - { - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $count = $this->object->countJournals($currency); - $this->assertEquals(0, $count); - } - - /** - * @covers FireflyIII\Repositories\Currency\CurrencyRepository::get - */ - public function testGet() - { - FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - - $set = $this->object->get(); - $this->assertCount(3, $set); // EUR is already present. - } - - /** - * @covers FireflyIII\Repositories\Currency\CurrencyRepository::getCurrencyByPreference - */ - public function testGetCurrencyByPreference() - { - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->data = $currency->code; - $preference->save(); - $found = $this->object->getCurrencyByPreference($preference); - $this->assertEquals($currency->id, $found->id); - } - - /** - * @covers FireflyIII\Repositories\Currency\CurrencyRepository::getCurrencyByPreference - */ - public function testGetCurrencyByPreferenceNull() - { - FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->data = 'ABC'; - $preference->save(); - $found = $this->object->getCurrencyByPreference($preference); - $this->assertEquals(1, $found->id); // EUR is first and will be set. - } - - /** - * @covers FireflyIII\Repositories\Currency\CurrencyRepository::store - */ - public function testStore() - { - $data = [ - 'name' => 'Some Currency', - 'code' => 'ABC', - 'symbol' => 'S' - ]; - - $currency = $this->object->store($data); - $this->assertEquals($data['name'], $currency->name); - } - - /** - * @covers FireflyIII\Repositories\Currency\CurrencyRepository::update - */ - public function testUpdate() - { - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - - $data = [ - 'name' => 'Some Currency', - 'code' => 'ABC', - 'symbol' => 'S' - ]; - - $newCurrency = $this->object->update($currency, $data); - $this->assertEquals($data['name'], $newCurrency->name); - $this->assertEquals($currency->id, $newCurrency->id); - } -} diff --git a/tests/repositories/JournalRepositoryTest.php b/tests/repositories/JournalRepositoryTest.php deleted file mode 100644 index 92dc3596f4..0000000000 --- a/tests/repositories/JournalRepositoryTest.php +++ /dev/null @@ -1,572 +0,0 @@ -object = new JournalRepository; - parent::setUp(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::delete - * @covers FireflyIII\Providers\EventServiceProvider::boot - * @covers FireflyIII\Providers\EventServiceProvider::registerDeleteEvents - */ - public function testDelete() - { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $transaction = $journal->transactions[0]; - $this->object->delete($journal); - - $this->assertEquals(0, TransactionJournal::where('id', $journal->id)->whereNull('deleted_at')->count()); - $this->assertEquals(0, Transaction::where('id', $transaction->id)->whereNull('deleted_at')->count()); - - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::first - */ - public function testFirst() - { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $this->be($journal->user); - - $first = $this->object->first(); - - $this->assertEquals($journal->id, $first->id); - - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::getAmountBefore - */ - public function testGetAmountBefore() - { - // create some accounts: - $expense = FactoryMuffin::create('FireflyIII\Models\Account'); // expense - FactoryMuffin::create('FireflyIII\Models\Account'); // revenue - $asset = FactoryMuffin::create('FireflyIII\Models\Account'); // asset - - // transaction type - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - - // create five journals with incrementing dates: - $today = new Carbon('2015-01-01'); - $journal = null; - for ($i = 0; $i < 5; $i++) { - // create journal: - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->transaction_type_id = $withdrawal; - $journal->date = $today; - $journal->save(); - - // update transactions: - $journal->transactions[0]->amount = -100; - $journal->transactions[0]->account_id = $asset->id; - $journal->transactions[0]->save(); - - $journal->transactions[1]->amount = 100; - $journal->transactions[1]->account_id = $expense->id; - $journal->transactions[1]->save(); - - // connect to expense - $today->addDay(); - } - - - $before = $this->object->getAmountBefore($journal, $journal->transactions[1]); - // five transactions, we check the last one, so amount should be 400. - $this->assertEquals(400, $before); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::getJournalsOfType - */ - public function testGetJournalsOfType() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $this->be($user); - $result = $this->object->getJournalsOfType($type); - $this->assertCount(0, $result); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::getJournalsOfTypes - */ - public function testGetJournalsOfTypes() - { - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - $types = ['Withdrawal', 'Expense']; - $set = $this->object->getJournalsOfTypes($types, 0, 1); - - $this->assertTrue($set instanceof LengthAwarePaginator); - $this->assertEquals(1, $set->currentPage()); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::getTransactionType - */ - public function testGetTransactionType() - { - $type = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $otherType = $this->object->getTransactionType($type->type); - $this->assertEquals($type->id, $otherType->id); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::getWithDate - */ - public function testGetWithDate() - { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $this->be($journal->user); - - $found = $this->object->getWithDate($journal->id, $journal->date); - - $this->assertEquals($journal->id, $found->id); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::saveTags - */ - public function testSaveTags() - { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $tags = ['one', 'two', 'three']; - $this->be($journal->user); - - $this->object->saveTags($journal, $tags); - - $this->assertCount(3, $journal->tags()->get()); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::store - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts - */ - public function testStore() - { - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $user = FactoryMuffin::create('FireflyIII\User'); - $data = [ - 'description' => 'Some journal ' . rand(1, 100), - 'user' => $user->id, - 'what' => 'withdrawal', - 'amount_currency_id' => $currency->id, - 'account_id' => $account1->id, - 'expense_account' => 'Some expense account', - 'date' => '2014-01-01', - 'category' => 'Some category', - 'budget_id' => $budget->id, - 'amount' => 100, - 'tags' => ['one', 'two', 'three'] - - - ]; - - $journal = $this->object->store($data); - - $this->assertEquals($data['description'], $journal->description); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::store - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts - */ - public function testStoreDeposit() - { - for ($i = 0; $i < 4; $i++) { - FactoryMuffin::create('FireflyIII\Models\AccountType'); - } - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $user = FactoryMuffin::create('FireflyIII\User'); - $data = [ - 'description' => 'Some journal ' . rand(1, 100), - 'user' => $user->id, - 'what' => 'deposit', - 'amount_currency_id' => $currency->id, - 'account_id' => $account1->id, - 'revenue_account' => 'Some revenue account', - 'date' => '2014-01-01', - 'category' => 'Some category', - 'budget_id' => $budget->id, - 'amount' => 100, - 'tags' => ['one', 'two', 'three'] - - - ]; - - $journal = $this->object->store($data); - - $this->assertEquals($data['description'], $journal->description); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::store - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts - */ - public function testStoreExpenseWithCash() - { - for ($i = 0; $i < 4; $i++) { - FactoryMuffin::create('FireflyIII\Models\AccountType'); - } - - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $user = FactoryMuffin::create('FireflyIII\User'); - $data = [ - 'description' => 'Some journal ' . rand(1, 100), - 'user' => $user->id, - 'what' => 'withdrawal', - 'amount_currency_id' => $currency->id, - 'account_id' => $account1->id, - 'expense_account' => '', - 'date' => '2014-01-01', - 'category' => 'Some other category', - 'budget_id' => $budget->id, - 'amount' => 100, - 'tags' => ['one', 'two', 'three'] - - - ]; - - $journal = $this->object->store($data); - - $this->assertEquals($data['description'], $journal->description); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::store - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException - */ - public function testStoreInvalidFromAccount() - { - for ($i = 0; $i < 4; $i++) { - FactoryMuffin::create('FireflyIII\Models\AccountType'); - } - - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $user = FactoryMuffin::create('FireflyIII\User'); - $data = [ - 'description' => 'Some journal ' . rand(1, 100), - 'user' => $user->id, - 'what' => 'transfer', - 'amount_currency_id' => $currency->id, - 'account_from_id' => $account1->id, - 'account_to_id' => 17, - 'date' => '2014-01-01', - 'category' => 'Some other category', - 'budget_id' => $budget->id, - 'amount' => 100, - 'tags' => ['one', 'two', 'three'] - - - ]; - - $journal = $this->object->store($data); - - $this->assertEquals($data['description'], $journal->description); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::store - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException - */ - public function testStoreInvalidToAccount() - { - for ($i = 0; $i < 4; $i++) { - FactoryMuffin::create('FireflyIII\Models\AccountType'); - } - - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $user = FactoryMuffin::create('FireflyIII\User'); - $data = [ - 'description' => 'Some journal ' . rand(1, 100), - 'user' => $user->id, - 'what' => 'transfer', - 'amount_currency_id' => $currency->id, - 'account_from_id' => 17, - 'account_to_id' => $account1->id, - 'date' => '2014-01-01', - 'category' => 'Some other category', - 'budget_id' => $budget->id, - 'amount' => 100, - 'tags' => ['one', 'two', 'three'] - - - ]; - - $journal = $this->object->store($data); - - $this->assertEquals($data['description'], $journal->description); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::store - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts - */ - public function testStoreRevenueWithCash() - { - for ($i = 0; $i < 4; $i++) { - FactoryMuffin::create('FireflyIII\Models\AccountType'); - } - - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $user = FactoryMuffin::create('FireflyIII\User'); - $data = [ - 'description' => 'Some journal ' . rand(1, 100), - 'user' => $user->id, - 'what' => 'deposit', - 'amount_currency_id' => $currency->id, - 'account_id' => $account1->id, - 'revenue_account' => '', - 'date' => '2014-01-01', - 'category' => 'Some other category', - 'budget_id' => $budget->id, - 'amount' => 100, - 'tags' => ['one', 'two', 'three'] - - - ]; - - $journal = $this->object->store($data); - - $this->assertEquals($data['description'], $journal->description); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::store - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeWithdrawalAccounts - * @covers FireflyIII\Repositories\Journal\JournalRepository::storeDepositAccounts - */ - public function testStoreTransfer() - { - for ($i = 0; $i < 4; $i++) { - FactoryMuffin::create('FireflyIII\Models\AccountType'); - } - - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - $user = FactoryMuffin::create('FireflyIII\User'); - $data = [ - 'description' => 'Some journal ' . rand(1, 100), - 'user' => $user->id, - 'what' => 'transfer', - 'amount_currency_id' => $currency->id, - 'account_from_id' => $account1->id, - 'account_to_id' => $account2->id, - 'date' => '2014-01-01', - 'category' => 'Some other category', - 'budget_id' => $budget->id, - 'amount' => 100, - 'tags' => ['one', 'two', 'three'] - - - ]; - - $journal = $this->object->store($data); - - $this->assertEquals($data['description'], $journal->description); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::update - * @covers FireflyIII\Repositories\Journal\JournalRepository::updateTags - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testUpdate() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - for ($i = 0; $i < 4; $i++) { - FactoryMuffin::create('FireflyIII\Models\AccountType'); - } - - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - - // two transactions - Transaction::create( - [ - 'account_id' => $account1->id, - 'transaction_journal_id' => $journal->id, - 'amount' => 100, - ] - ); - Transaction::create( - [ - 'account_id' => $account1->id, - 'transaction_journal_id' => $journal->id, - 'amount' => -100, - ] - ); - - - $data = [ - 'amount_currency_id' => $currency->id, - 'description' => 'New description ' . rand(1, 100), - 'date' => '2015-01-01', - 'category' => 'SomenewCat', - 'amount' => 50, - 'user' => $journal->user_id, - 'budget_id' => $budget->id, - 'account_from_id' => $account1->id, - 'account_to_id' => $account2->id, - 'revenue_account' => 'Some revenue account', - 'expense_account' => 'Some expense account', - 'tags' => ['a', 'b', 'c'] - - ]; - - $result = $this->object->update($journal, $data); - - $this->assertEquals($result->description, $data['description']); - $this->assertEquals($result->amount, 50); - } - - /** - * @covers FireflyIII\Repositories\Journal\JournalRepository::update - * @covers FireflyIII\Repositories\Journal\JournalRepository::updateTags - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function testUpdateNoTags() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - for ($i = 0; $i < 4; $i++) { - FactoryMuffin::create('FireflyIII\Models\AccountType'); - } - - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - - // two transactions - Transaction::create( - [ - 'account_id' => $account1->id, - 'transaction_journal_id' => $journal->id, - 'amount' => 100, - ] - ); - Transaction::create( - [ - 'account_id' => $account1->id, - 'transaction_journal_id' => $journal->id, - 'amount' => -100, - ] - ); - - - $data = [ - 'amount_currency_id' => $currency->id, - 'description' => 'New description ' . rand(1, 100), - 'date' => '2015-01-01', - 'category' => 'SomenewCat', - 'amount' => 50, - 'user' => $journal->user_id, - 'budget_id' => $budget->id, - 'account_from_id' => $account1->id, - 'account_to_id' => $account2->id, - 'revenue_account' => 'Some revenue account', - 'expense_account' => 'Some expense account', - 'tags' => [] - - ]; - - $result = $this->object->update($journal, $data); - - $this->assertEquals($result->description, $data['description']); - $this->assertEquals($result->amount, 50); - } - -} diff --git a/tests/repositories/PiggyBankRepositoryTest.php b/tests/repositories/PiggyBankRepositoryTest.php deleted file mode 100644 index 79c9079c4e..0000000000 --- a/tests/repositories/PiggyBankRepositoryTest.php +++ /dev/null @@ -1,196 +0,0 @@ -object = new PiggyBankRepository; - parent::setUp(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - } - - /** - * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::createEvent - */ - public function testCreateEvent() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->object->createEvent($piggyBank, 100); - - $this->assertCount(1, $piggyBank->piggybankevents()->get()); - } - - - /** - * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::destroy - * @covers FireflyIII\Providers\EventServiceProvider::boot - * @covers FireflyIII\Providers\EventServiceProvider::registerDeleteEvents - */ - public function testDestroy() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - - $this->object->destroy($piggyBank); - - $this->assertCount(0, PiggyBank::where('id', $piggyBank->id)->whereNull('deleted_at')->get()); - - } - - /** - * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::getEventSummarySet - */ - public function testGetEventSummarySet() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $set = $this->object->getEventSummarySet($piggyBank); - - $this->assertCount(0, $set); - } - - /** - * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::getEvents - */ - public function testGetEvents() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $set = $this->object->getEvents($piggyBank); - - $this->assertCount(0, $set); - } - - /** - * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::getPiggyBanks - */ - public function testGetPiggyBanks() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $this->be($piggyBank->account->user); - $set = $this->object->getPiggyBanks(); - - $this->assertCount(1, $set); - } - - /** - * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::reset - */ - public function testReset() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $piggyBank->order = 4; - $piggyBank->save(); - $this->be($piggyBank->account->user); - $this->object->reset(); - - $this->assertCount(1, PiggyBank::where('order', 0)->get()); - } - - /** - * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::setOrder - */ - public function testSetOrder() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - $piggyBank->order = 4; - $this->be($piggyBank->account->user); - $piggyBank->save(); - - $this->object->setOrder($piggyBank->id, 3); - $newPiggy = PiggyBank::find($piggyBank->id); - $this->assertEquals(3, $newPiggy->order); - } - - /** - * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::store - * @covers FireflyIII\Providers\EventServiceProvider::boot - * @covers FireflyIII\Providers\EventServiceProvider::registerCreateEvents - */ - public function testStore() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - - $data = [ - 'account_id' => $account->id, - 'name' => 'Some piggy', - 'targetamount' => 100, - 'order' => 1, - 'remind_me' => false, - 'reminder_skip' => 0, - - ]; - - $piggyBank = $this->object->store($data); - - $this->assertEquals(1, $piggyBank->id); - } - - /** - * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::store - * @covers FireflyIII\Providers\EventServiceProvider::boot - * @covers FireflyIII\Providers\EventServiceProvider::registerCreateEvents - */ - public function testStoreRedirect() - { - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - - $data = [ - 'account_id' => $account->id, - 'name' => 'Some piggy', - 'targetamount' => 100, - 'create_another' => 1, - 'order' => 1, - 'remind_me' => false, - 'reminder_skip' => 0, - - ]; - - $piggyBank = $this->object->store($data); - - $this->assertEquals(1, $piggyBank->id); - } - - /** - * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::update - */ - public function testUpdate() - { - $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); - - $data = [ - 'name' => 'Update piggy ' . rand(1, 100), - 'account_id' => $piggyBank->account_id, - 'targetamount' => 101, - 'targetdate' => new Carbon, - 'startdate' => new Carbon, - ]; - - $new = $this->object->update($piggyBank, $data); - - $this->assertEquals($data['name'], $new->name); - $this->assertEquals($piggyBank->id, $new->id); - } -} diff --git a/tests/repositories/TagRepositoryBasicTest.php b/tests/repositories/TagRepositoryBasicTest.php deleted file mode 100644 index b49857ed34..0000000000 --- a/tests/repositories/TagRepositoryBasicTest.php +++ /dev/null @@ -1,182 +0,0 @@ -object = new TagRepository; - parent::setUp(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - } - /** - * @covers FireflyIII\Repositories\Tag\TagRepository::update - */ - public function testUpdate() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - - - $data = [ - 'tag' => 'Hello' . rand(1, 100), - 'date' => '2012-01-01', - 'description' => 'Some', - 'latitude' => 12, - 'longitude' => 13, - 'zoomLevel' => 4, - 'tagMode' => 'nothing' - ]; - $this->be($tag->user); - - $newTag = $this->object->update($tag, $data); - $this->assertEquals($data['tag'], $newTag->tag); - $this->assertEquals($tag->id, $newTag->id); - } - - /** - * @covers FireflyIII\Repositories\Tag\TagRepository::store - */ - public function testStore() - { - $user = FactoryMuffin::create('FireflyIII\User'); - - $data = [ - 'tag' => 'Hello' . rand(1, 100), - 'date' => '2012-01-01', - 'description' => 'Some', - 'latitude' => 12, - 'longitude' => 13, - 'zoomLevel' => 4, - 'tagMode' => 'nothing' - ]; - $this->be($user); - - $tag = $this->object->store($data); - $this->assertEquals($data['tag'], $tag->tag); - } - - - /** - * @covers FireflyIII\Repositories\Tag\TagRepository::destroy - */ - public function testDestroy() - { - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $this->object->destroy($tag); - - $this->assertCount(0, Tag::where('id', $tag->id)->whereNull('deleted_at')->get()); - - } - - /** - * @covers FireflyIII\Repositories\Tag\TagRepository::get - */ - public function testGet() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $tag1 = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag2 = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag1->tag = 'BBB'; - $tag2->tag = 'AAA'; - $tag1->user_id = $user->id; - $tag2->user_id = $user->id; - - $tag1->save(); - $tag2->save(); - - $this->be($user); - - $set = $this->object->get(); - - $this->assertCount(2, $set); - $this->assertEquals('AAA', $set->first()->tag); - } - - - /** - * @covers FireflyIII\Repositories\Tag\TagRepository::coveredByBalancingActs - */ - public function testCoveredByBalancingActs() - { - // create a user: - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // create transaction and account types: - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // deposit - $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType'); // transfer - FactoryMuffin::create('FireflyIII\Models\AccountType'); // expense - FactoryMuffin::create('FireflyIII\Models\AccountType'); // revenue - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); // asset - - // create two accounts: - $fromAccount = FactoryMuffin::create('FireflyIII\Models\Account'); // asset - $toAccount = FactoryMuffin::create('FireflyIII\Models\Account'); // asset - $fromAccount->account_type_id = $asset->id; - $toAccount->account_type_id = $asset->id; - $fromAccount->save(); - $toAccount->save(); - - - // create a tag - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'balancingAct'; - $tag->user_id = $user->id; - $tag->save(); - - // date - $today = new Carbon('2014-01-12'); - $start = new Carbon('2014-01-01'); - $end = new Carbon('2014-01-31'); - - // store five journals - for ($i = 0; $i < 5; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); // deposit! - // set date: - $journal->date = $today; - $journal->user_id = $user->id; - $journal->transaction_type_id = $transfer->id; - $journal->tags()->save($tag); - $journal->save(); - - // update accounts: - $journal->transactions[0]->account_id = $fromAccount->id; - $journal->transactions[0]->amount = '-100'; - $journal->transactions[0]->save(); - $journal->transactions[1]->account_id = $toAccount->id; - $journal->transactions[1]->amount = '100'; - $journal->transactions[1]->save(); - - } - - $amount = $this->object->coveredByBalancingActs($toAccount, $start, $end); - // five transactions, 100 each. - $this->assertEquals('500', $amount); - } - -} diff --git a/tests/repositories/TagRepositoryTest.php b/tests/repositories/TagRepositoryTest.php deleted file mode 100644 index bcd763cd00..0000000000 --- a/tests/repositories/TagRepositoryTest.php +++ /dev/null @@ -1,656 +0,0 @@ -object = new TagRepository; - parent::setUp(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - } - - /** - * Already connected tag and transaction journal returns FALSE. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::connect - */ - public function testConnectAlreadyConnected() - { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $journal->tags()->save($tag); - - $result = $this->object->connect($journal, $tag); - $this->assertFalse($result); - - } - - /** - * A deposit cannot be connected to a balancing act. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::connect - * @covers FireflyIII\Repositories\Tag\TagRepository::connectBalancingAct - */ - public function testConnectBalancingOneDeposit() - { - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - - $journal->transaction_type_id = $deposit->id; - $tag->tagMode = 'balancingAct'; - - $tag->save(); - $journal->save(); - - $result = $this->object->connect($journal, $tag); - $this->assertFalse($result); - - } - - /** - * Connecting a single transfer to a balancing act is possible if there are no - * other transfers already connected. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::connect - * @covers FireflyIII\Repositories\Tag\TagRepository::connectBalancingAct - */ - public function testConnectBalancingOneTransfer() - { - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - - $journal->transaction_type_id = $transfer->id; - $tag->tagMode = 'balancingAct'; - - $tag->save(); - $journal->save(); - - $result = $this->object->connect($journal, $tag); - $this->assertTrue($result); - - } - - /** - * Connecting a single withdrawal to a balancing act is possible if there are - * not other withdrawals already connected. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::connect - * @covers FireflyIII\Repositories\Tag\TagRepository::connectBalancingAct - */ - public function testConnectBalancingOneWithdrawal() - { - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - - $journal->transaction_type_id = $withdrawal->id; - $tag->tagMode = 'balancingAct'; - - $tag->save(); - $journal->save(); - - $result = $this->object->connect($journal, $tag); - $this->assertTrue($result); - - } - - /** - * Default connection between a journal and a tag. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::connect - */ - public function testConnectDefault() - { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'nothing'; - $tag->save(); - - $result = $this->object->connect($journal, $tag); - $this->assertTrue($result); - - } - - /** - * Fallback for connect then the tag mode is unknown - * - * @covers FireflyIII\Repositories\Tag\TagRepository::connect - */ - public function testConnectInvalidType() - { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'Idontknow'; - $tag->save(); - - $result = $this->object->connect($journal, $tag); - $this->assertFalse($result); - - } - - /** - * Once one or more journals have been accepted by the tag, others must match the asset account - * id. For this to work, we must also create an asset account, and a transaction. - * - * Connecting a deposit to a tag that already has a withdrawal. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::connect - * @covers FireflyIII\Repositories\Tag\TagRepository::connectAdvancePayment - * @covers FireflyIII\Repositories\Tag\TagRepository::matchAll - */ - public function testConnectPaymentMultipleMatch() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); - - $account = FactoryMuffin::create('FireflyIII\Models\Account'); - - - $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - - // transactions for both: - $journal1->transactions[0]->account_id = $account->id; - $journal2->transactions[0]->account_id = $account->id; - $journal1->transactions[1]->account_id = $account->id; - $journal2->transactions[1]->account_id = $account->id; - $journal1->transactions[0]->save(); - $journal2->transactions[0]->save(); - $journal1->transactions[1]->save(); - $journal2->transactions[1]->save(); - - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - - $journal1->transaction_type_id = $withdrawal->id; - $journal2->transaction_type_id = $deposit->id; - $tag->tagMode = 'advancePayment'; - $account->account_type_id = $asset->id; - - $tag->save(); - $journal1->save(); - $journal2->save(); - $account->save(); - // connect journal1: - - $journal1->tags()->save($tag); - - $result = $this->object->connect($journal2, $tag); - - $this->assertTrue($result); - - } - - /** - * Once one or more journals have been accepted by the tag, others must match the asset account - * id. For this to work, we must also create an asset account, and a transaction. - * - * This covers the advance payment - * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @covers FireflyIII\Repositories\Tag\TagRepository::connect - * @covers FireflyIII\Repositories\Tag\TagRepository::connectAdvancePayment - * @covers FireflyIII\Repositories\Tag\TagRepository::matchAll - */ - public function testConnectPaymentNoMatch() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); - - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - - - $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - - // transactions for both: - $journal1->transactions[0]->account_id = $account1->id; - $journal2->transactions[0]->account_id = $account2->id; - $journal1->transactions[1]->account_id = $account1->id; - $journal2->transactions[1]->account_id = $account2->id; - $journal1->transactions[0]->save(); - $journal2->transactions[0]->save(); - $journal1->transactions[1]->save(); - $journal2->transactions[1]->save(); - - - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - - $journal1->transaction_type_id = $withdrawal->id; - $journal2->transaction_type_id = $deposit->id; - $tag->tagMode = 'advancePayment'; - $account1->account_type_id = $asset->id; - $account2->account_type_id = $asset->id; - - $tag->save(); - $journal1->save(); - $journal2->save(); - $account1->save(); - $account2->save(); - // connect journal1: - $journal1->tags()->save($tag); - - $result = $this->object->connect($journal2, $tag); - // account1 and account2 are different, so false: - $this->assertFalse($result); - - } - - /** - * Once one or more journals have been accepted by the tag, others must match the asset account - * id. For this to work, we must also create an asset account, and a transaction. - * - * This covers the advance payment - * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @covers FireflyIII\Repositories\Tag\TagRepository::connect - * @covers FireflyIII\Repositories\Tag\TagRepository::connectAdvancePayment - * @covers FireflyIII\Repositories\Tag\TagRepository::matchAll - */ - public function testConnectPaymentNoMatchDeposit() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - FactoryMuffin::create('FireflyIII\Models\AccountType'); - FactoryMuffin::create('FireflyIII\Models\AccountType'); - $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); - - $account1 = FactoryMuffin::create('FireflyIII\Models\Account'); - $account2 = FactoryMuffin::create('FireflyIII\Models\Account'); - - - $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - - // transactions for both: - $journal1->transactions[0]->account_id = $account1->id; - $journal2->transactions[0]->account_id = $account2->id; - $journal1->transactions[1]->account_id = $account1->id; - $journal2->transactions[1]->account_id = $account2->id; - $journal1->transactions[0]->save(); - $journal2->transactions[0]->save(); - $journal1->transactions[1]->save(); - $journal2->transactions[1]->save(); - - - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - - $journal1->transaction_type_id = $withdrawal->id; - $journal2->transaction_type_id = $deposit->id; - $tag->tagMode = 'advancePayment'; - $account1->account_type_id = $asset->id; - $account2->account_type_id = $asset->id; - - $tag->save(); - $journal1->save(); - $journal2->save(); - $account1->save(); - $account2->save(); - // connect journal1: - $journal2->tags()->save($tag); - - $result = $this->object->connect($journal1, $tag); - // account1 and account2 are different, so false: - $this->assertFalse($result); - - } - - /** - * An advance payment accepts no transfers. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::connect - * @covers FireflyIII\Repositories\Tag\TagRepository::connectAdvancePayment - * @covers FireflyIII\Repositories\Tag\TagRepository::matchAll - */ - public function testConnectPaymentOneTransfer() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - - $journal->transaction_type_id = $transfer->id; - $tag->tagMode = 'advancePayment'; - - $tag->save(); - $journal->save(); - - $result = $this->object->connect($journal, $tag); - $this->assertFalse($result); - - } - - /** - * An advance payment accepts only one withdrawal, not two. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::connect - * @covers FireflyIII\Repositories\Tag\TagRepository::connectAdvancePayment - * @covers FireflyIII\Repositories\Tag\TagRepository::matchAll - */ - public function testConnectPaymentOneWithdrawal() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - - $journal->transaction_type_id = $withdrawal->id; - $tag->tagMode = 'advancePayment'; - - $tag->save(); - $journal->save(); - - $result = $this->object->connect($journal, $tag); - $this->assertTrue($result); - - } - - /** - * An advance payment accepts only one withdrawal, not two. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::connect - * @covers FireflyIII\Repositories\Tag\TagRepository::connectAdvancePayment - * @covers FireflyIII\Repositories\Tag\TagRepository::matchAll - */ - public function testConnectPaymentTwoWithdrawals() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $otherJournal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - - $journal->transaction_type_id = $withdrawal->id; - $otherJournal->transaction_type_id = $withdrawal->id; - $tag->tagMode = 'advancePayment'; - - $tag->save(); - $journal->save(); - $otherJournal->save(); - $otherJournal->tags()->save($tag); - - $result = $this->object->connect($journal, $tag); - $this->assertFalse($result); - - } - - /** - * An advance payment accepts only one withdrawal, not two, even not - * if the accounts are the same - * - * @covers FireflyIII\Repositories\Tag\TagRepository::connect - * @covers FireflyIII\Repositories\Tag\TagRepository::connectAdvancePayment - * @covers FireflyIII\Repositories\Tag\TagRepository::matchAll - */ - public function testConnectPaymentTwoWithdrawalsSameAccounts() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); - - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $otherJournal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - - $journal->transaction_type_id = $withdrawal->id; - $otherJournal->transaction_type_id = $withdrawal->id; - - // match up accounts: - $otherJournal->transactions[0]->account_id = $journal->transactions[0]->account_id; - $otherJournal->transactions[1]->account_id = $journal->transactions[1]->account_id; - $otherJournal->transactions[0]->save(); - $otherJournal->transactions[1]->save(); - - - $tag->tagMode = 'advancePayment'; - - $tag->save(); - $journal->save(); - $otherJournal->save(); - $otherJournal->tags()->save($tag); - - $result = $this->object->connect($journal, $tag); - $this->assertFalse($result); - } - - - /** - * By default, any tag can become an advancePayment - * - * @covers FireflyIII\Repositories\Tag\TagRepository::tagAllowAdvance - */ - public function testTagAllowAdvance() - { - // create a tag - $user = FactoryMuffin::create('FireflyIII\User'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'nothing'; - $tag->user_id = $user->id; - $tag->save(); - - $result = $this->object->tagAllowAdvance($tag); - $this->assertTrue($result); - } - - /** - * If the tag has one transfer, it can NOT become an advance payment. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::tagAllowAdvance - */ - public function testTagAllowAdvanceWithTransfer() - { - // create a tag - $user = FactoryMuffin::create('FireflyIII\User'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // deposit - $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType'); // transfer - $tag->tagMode = 'nothing'; - $tag->user_id = $user->id; - $tag->save(); - - // create withdrawal: - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->transaction_type_id = $transfer->id; - $journal->save(); - $journal->tags()->save($tag); - - $result = $this->object->tagAllowAdvance($tag); - $this->assertFalse($result); - } - - /** - * If the tag has one withdrawal, it can still become an advance payment. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::tagAllowAdvance - */ - public function testTagAllowAdvanceWithWithdrawal() - { - // create a tag - $user = FactoryMuffin::create('FireflyIII\User'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'nothing'; - $tag->user_id = $user->id; - $tag->save(); - - // create withdrawal: - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->tags()->save($tag); - - $result = $this->object->tagAllowAdvance($tag); - $this->assertTrue($result); - } - - /** - * If the tag has two withdrawals, it CANNOT become an advance payment. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::tagAllowAdvance - */ - public function testTagAllowAdvanceWithWithdrawals() - { - // create a tag - $user = FactoryMuffin::create('FireflyIII\User'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType'); - $tag->tagMode = 'nothing'; - $tag->user_id = $user->id; - $tag->save(); - - // create withdrawals - for ($i = 0; $i < 2; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->transaction_type_id = $withdrawal->id; - $journal->save(); - $journal->tags()->save($tag); - } - - $result = $this->object->tagAllowAdvance($tag); - $this->assertFalse($result); - } - - /** - * By default, an empty tag can become a balancing act. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::tagAllowBalancing - */ - public function testTagAllowBalancing() - { - // create a tag - $user = FactoryMuffin::create('FireflyIII\User'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'nothing'; - $tag->user_id = $user->id; - $tag->save(); - - $result = $this->object->tagAllowBalancing($tag); - $this->assertTrue($result); - } - - /** - * When the tag has one deposit, it can NOT become a balancing act. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::tagAllowBalancing - */ - public function testTagAllowBalancingDeposit() - { - - // create a tag - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType'); // deposit - $user = FactoryMuffin::create('FireflyIII\User'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'nothing'; - $tag->user_id = $user->id; - $tag->save(); - - // create three journals and connect them: - for ($i = 0; $i < 1; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->transaction_type_id = $deposit->id; - $journal->save(); - $journal->tags()->save($tag); - } - - $result = $this->object->tagAllowBalancing($tag); - $this->assertFalse($result); - } - - /** - * When the tag has more than 2 transactions connected to it, it cannot become abalancing act. - * - * @covers FireflyIII\Repositories\Tag\TagRepository::tagAllowBalancing - */ - public function testTagAllowBalancingManyJournals() - { - // create a tag - $user = FactoryMuffin::create('FireflyIII\User'); - $tag = FactoryMuffin::create('FireflyIII\Models\Tag'); - $tag->tagMode = 'nothing'; - $tag->user_id = $user->id; - $tag->save(); - - // create three journals and connect them: - for ($i = 0; $i < 3; $i++) { - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $journal->tags()->save($tag); - } - - $result = $this->object->tagAllowBalancing($tag); - $this->assertFalse($result); - } -} diff --git a/tests/support/AmountSupportTest.php b/tests/support/AmountSupportTest.php deleted file mode 100644 index 63631e0578..0000000000 --- a/tests/support/AmountSupportTest.php +++ /dev/null @@ -1,300 +0,0 @@ -object = new Amount; - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - public function tearDown() - { - parent::tearDown(); - } - - /** - * @covers FireflyIII\Support\Amount::format - * @covers FireflyIII\Support\Amount::getCurrencySymbol - */ - public function testFormat() - { - $amount = '123'; - $result = $this->object->format($amount, true); - $this->assertTrue(str_contains($result, $amount)); - } - - /** - * @covers FireflyIII\Support\Amount::formatJournal - */ - public function testFormatJournalColouredTransfer() - { - - - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // deposit - /** @var \FireflyIII\Models\TransactionJournal $journal */ - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $symbol = $journal->transactionCurrency->symbol; - - $result = $this->object->formatJournal($journal, true); - - // transfer is blue: - $this->assertTrue(str_contains($result, '')); - // transfer contains currency code: - $this->assertTrue(str_contains($result, $symbol)); - // all amounts are 100. - $this->assertTrue(str_contains($result, '100')); - } - - /** - * @covers FireflyIII\Support\Amount::formatJournal - */ - public function testFormatJournalUncolouredTransfer() - { - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // deposit - /** @var \FireflyIII\Models\TransactionJournal $journal */ - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $symbol = $journal->transactionCurrency->symbol; - - $result = $this->object->formatJournal($journal, false); - - // transfer is not blue: - $this->assertFalse(str_contains($result, '')); - // transfer contains currency code: - $this->assertTrue(str_contains($result, $symbol)); - // all amounts are 100. - $this->assertTrue(str_contains($result, '100')); - } - - /** - * @covers FireflyIII\Support\Amount::formatJournal - */ - public function testFormatJournalWithSymbol() - { - FactoryMuffin::create('FireflyIII\Models\TransactionType'); // withdrawal - /** @var \FireflyIII\Models\TransactionJournal $journal */ - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $symbol = $journal->transactionCurrency->symbol; - $journal->symbol = $symbol; - - $result = $this->object->formatJournal($journal, true); - - // transfer is not blue: - $this->assertFalse(str_contains($result, '')); - // transfer contains currency code: - $this->assertTrue(str_contains($result, $symbol)); - // all amounts are 100. - $this->assertTrue(str_contains($result, '100')); - } - - /** - * @covers FireflyIII\Support\Amount::formatJournal - */ - public function testFormatJournalWithdrawal() - { - /** @var \FireflyIII\Models\TransactionJournal $journal */ - $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); - $symbol = $journal->transactionCurrency->symbol; - - $result = $this->object->formatJournal($journal, true); - - // transfer is not blue: - $this->assertFalse(str_contains($result, '')); - // transfer contains currency code: - $this->assertTrue(str_contains($result, $symbol)); - // all amounts are 100. - $this->assertTrue(str_contains($result, '100')); - } - - /** - * @covers FireflyIII\Support\Amount::formatTransaction - */ - public function testFormatTransaction() - { - // is a withdrawal. - $transaction = FactoryMuffin::create('FireflyIII\Models\Transaction'); - $transaction->amount = -100; - $transaction->save(); - $result = $this->object->formatTransaction($transaction, true); - - - // withdrawal is red: - $this->assertTrue(str_contains($result, '')); - // all amounts are 100. - $this->assertTrue(str_contains($result, '100')); - } - - /** - * @covers FireflyIII\Support\Amount::formatWithSymbol - */ - public function testFormatWithSymbolColouredAboveZero() - { - $amount = 123; - $symbol = 'top'; - $coloured = true; - - $result = $this->object->formatWithSymbol($symbol, $amount, $coloured); - - // has colour: - $this->assertTrue(str_contains($result, '')); - // has symbol: - $this->assertTrue(str_contains($result, $symbol)); - // has amount: - $this->assertTrue(str_contains($result, '123')); - } - - /** - * @covers FireflyIII\Support\Amount::formatWithSymbol - */ - public function testFormatWithSymbolColouredBelowZero() - { - $amount = -123; - $symbol = 'top'; - $coloured = true; - - $result = $this->object->formatWithSymbol($symbol, $amount, $coloured); - - // has colour: - $this->assertTrue(str_contains($result, '')); - // has symbol: - $this->assertTrue(str_contains($result, $symbol)); - // has amount: - $this->assertTrue(str_contains($result, '123')); - } - - /** - * @covers FireflyIII\Support\Amount::formatWithSymbol - */ - public function testFormatWithSymbolColouredZero() - { - $amount = 0.0; - $symbol = 'top'; - $coloured = true; - - $result = $this->object->formatWithSymbol($symbol, $amount, $coloured); - - // has colour: - $this->assertTrue(str_contains($result, '#999')); - // has symbol: - $this->assertTrue(str_contains($result, $symbol)); - // has amount: - $this->assertTrue(str_contains($result, '0')); - } - - /** - * @covers FireflyIII\Support\Amount::formatWithSymbol - */ - public function testFormatWithSymbolNotColoured() - { - $amount = 0; - $symbol = 'top'; - $coloured = false; - - $result = $this->object->formatWithSymbol($symbol, $amount, $coloured); - - // has symbol: - $this->assertTrue(str_contains($result, $symbol)); - // has amount: - $this->assertTrue(str_contains($result, '0')); - } - - /** - * @covers FireflyIII\Support\Amount::getAllCurrencies - */ - public function testGetAllCurrencies() - { - $size = TransactionCurrency::count(); - $list = $this->object->getAllCurrencies(); - $this->assertCount($size, $list); - } - - /** - * @covers FireflyIII\Support\Amount::getCurrencyCode - */ - public function testGetCurrencyCode() - { - $code = $this->object->getCurrencyCode(); - $this->assertEquals('EUR', $code); - } - - /** - * @covers FireflyIII\Support\Amount::getCurrencyCode - */ - public function testGetCurrencyCodeNoSuchCurrency() - { - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - - // delete any currency preferences: - Preference::where('user_id', $user->id)->delete(); - - // delete transaction currencies: - foreach (TransactionCurrency::get() as $c) { - $c->delete(); - } - - $preference = FactoryMuffin::create('FireflyIII\Models\Preference'); - $preference->user_id = $user->id; - $preference->name = 'currencyPreference'; - $preference->data = 'SOM'; - $preference->save(); - - Preferences::shouldReceive('get')->withArgs(['currencyPreference', 'EUR'])->andReturn($preference); - - $code = $this->object->getCurrencyCode(); - $this->assertEquals('EUR', $code); - } - - /** - * @covers FireflyIII\Support\Amount::getCurrencySymbol - */ - public function testGetCurrencySymbol() - { - // will the the euro: - $eur = TransactionCurrency::whereCode('EUR')->first(); - - $result = $this->object->getCurrencySymbol(); - $this->assertEquals($eur->symbol, $result); - } - - /** - * @covers FireflyIII\Support\Amount::getDefaultCurrency - */ - public function testGetDefaultCurrency() - { - // will the the euro: - $eur = TransactionCurrency::whereCode('EUR')->first(); - - $result = $this->object->getDefaultCurrency(); - $this->assertEquals($eur->id, $result->id); - } - - -} diff --git a/tests/support/ExpandedFormTest.php b/tests/support/ExpandedFormTest.php deleted file mode 100644 index cd15532dd0..0000000000 --- a/tests/support/ExpandedFormTest.php +++ /dev/null @@ -1,202 +0,0 @@ -object = new ExpandedForm; - $user = FactoryMuffin::create('FireflyIII\User'); - $this->be($user); - } - - /** - * @covers FireflyIII\Support\ExpandedForm::amount - * @covers FireflyIII\Support\ExpandedForm::label - * @covers FireflyIII\Support\ExpandedForm::expandOptionArray - * @covers FireflyIII\Support\ExpandedForm::getHolderClasses - * @covers FireflyIII\Support\ExpandedForm::fillFieldValue - */ - public function testAmount() - { - $result = $this->object->amount('abcde', '12.23', ['label' => 'Some Label']); - - $this->assertTrue(str_contains($result, '23')); - $this->assertTrue(str_contains($result, 'abcde_holder')); - } - - /** - * @covers FireflyIII\Support\ExpandedForm::balance - * @covers FireflyIII\Support\ExpandedForm::label - */ - public function testBalance() - { - $result = $this->object->balance('abcde', '12.23', []); - - $this->assertTrue(str_contains($result, '23')); - $this->assertTrue(str_contains($result, 'abcde_holder')); - } - - /** - * @covers FireflyIII\Support\ExpandedForm::checkbox - * @covers FireflyIII\Support\ExpandedForm::getHolderClasses - */ - public function testCheckbox() - { - // add error to session for this thing: - $errors = new MessageBag; - $errors->add('abcde', 'Some error here.'); - $this->session(['errors' => $errors]); - - $result = $this->object->checkbox('abcde', 1, true); - - - $this->assertTrue(str_contains($result, 'checked="checked"')); - $this->assertTrue(str_contains($result, 'abcde_holder')); - } - - /** - * @covers FireflyIII\Support\ExpandedForm::date - * @covers FireflyIII\Support\ExpandedForm::fillFieldValue - */ - public function testDate() - { - $preFilled = [ - 'abcde' => '1998-01-01' - ]; - $this->session(['preFilled' => $preFilled]); - - $result = $this->object->date('abcde'); - - $this->assertTrue(str_contains($result, '1998')); - $this->assertTrue(str_contains($result, 'type="date"')); - $this->assertTrue(str_contains($result, 'abcde_holder')); - } - - /** - * @covers FireflyIII\Support\ExpandedForm::integer - */ - public function testInteger() - { - $result = $this->object->integer('abcde', 12345); - - $this->assertTrue(str_contains($result, '12345')); - $this->assertTrue(str_contains($result, 'type="number"')); - $this->assertTrue(str_contains($result, 'step="1"')); - $this->assertTrue(str_contains($result, 'abcde_holder')); - } - - /** - * @covers FireflyIII\Support\ExpandedForm::location - */ - public function testLocation() - { - $result = $this->object->location('abcde'); - - $this->assertTrue(str_contains($result, 'id="clearLocation"')); - $this->assertTrue(str_contains($result, 'id="map-canvas"')); - $this->assertTrue(str_contains($result, 'abcde_holder')); - } - - /** - * @covers FireflyIII\Support\ExpandedForm::makeSelectList - */ - public function testMakeSelectList() - { - $collection = new Collection; - for ($i = 0; $i < 5; $i++) { - $collection->push(FactoryMuffin::create('FireflyIII\Models\Account')); - } - $result = $this->object->makeSelectList($collection, true); - - $this->assertCount(6, $result); - } - - /** - * @covers FireflyIII\Support\ExpandedForm::multiRadio - */ - public function testMultiRadio() - { - $list = [ - 'some' => 'BlaBla', - 'other' => 'ThisIsCool' - ]; - - $result = $this->object->multiRadio('abcde', $list); - - $this->assertTrue(str_contains($result, 'ThisIsCool')); - $this->assertTrue(str_contains($result, 'other')); - $this->assertTrue(str_contains($result, 'abcde_holder')); - } - - /** - * @covers FireflyIII\Support\ExpandedForm::optionsList - */ - public function testOptionsList() - { - $result = $this->object->optionsList('update', 'MotorCycle'); - $this->assertTrue(str_contains($result, 'MotorCycle')); - } - - /** - * @covers FireflyIII\Support\ExpandedForm::select - */ - public function testSelect() - { - $list = [ - 'some' => 'BlaBla', - 'other' => 'ThisIsCool' - ]; - - $result = $this->object->select('abcde', $list); - $this->assertTrue(str_contains($result, 'ThisIsCool')); - $this->assertTrue(str_contains($result, 'abcde_holder')); - } - - /** - * @covers FireflyIII\Support\ExpandedForm::tags - */ - public function testTags() - { - $result = $this->object->tags('abcde', 'some,tags'); - $this->assertTrue(str_contains($result, 'data-role="tagsinput"')); - $this->assertTrue(str_contains($result, 'abcde_holder')); - } - - /** - * @covers FireflyIII\Support\ExpandedForm::text - */ - public function testText() - { - $result = $this->object->text('abcde', 'MotorBike!'); - $this->assertTrue(str_contains($result, 'MotorBike!')); - $this->assertTrue(str_contains($result, 'abcde_holder')); - } - - /** - * @covers FireflyIII\Support\ExpandedForm::textarea - */ - public function testTextarea() - { - $result = $this->object->textarea('abcde', 'Pillow fight!'); - $this->assertTrue(str_contains($result, 'Pillow fight!')); - $this->assertTrue(str_contains($result, 'abcde_holder')); - } -} diff --git a/tests/support/NavigationTest.php b/tests/support/NavigationTest.php deleted file mode 100644 index 7e93a09e69..0000000000 --- a/tests/support/NavigationTest.php +++ /dev/null @@ -1,287 +0,0 @@ -object = new Navigation; - } - - /** - * @covers FireflyIII\Support\Navigation::addPeriod - */ - public function testAddPeriod() - { - $date = new Carbon('2015-01-01'); - - $result = $this->object->addPeriod($date, 'quarter', 0); - $this->assertEquals('2015-04-01', $result->format('Y-m-d')); - } - - /** - * @expectedException FireflyIII\Exceptions\FireflyException - * @expectedExceptionMessage Cannot do addPeriod for $repeat_freq "something" - * @covers FireflyIII\Support\Navigation::addPeriod - */ - public function testAddPeriodError() - { - $date = new Carbon('2015-01-01'); - - $this->object->addPeriod($date, 'something', 0); - - } - - /** - * @covers FireflyIII\Support\Navigation::endOfPeriod - */ - public function testEndOfPeriod() - { - $date = new Carbon('2015-01-01'); - - $result = $this->object->endOfPeriod($date, '1D'); - $this->assertEquals('2015-01-02', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::endOfPeriod - */ - public function testEndOfPeriodModifier() - { - $date = new Carbon('2015-01-01'); - - $result = $this->object->endOfPeriod($date, 'quarter'); - $this->assertEquals('2015-03-31', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::endOfPeriod - * @expectedException FireflyIII\Exceptions\FireflyException - * @expectedExceptionMessage Cannot do endOfPeriod for $repeat_freq "something" - */ - public function testEndOfPeriodModifierError() - { - $date = new Carbon('2015-01-01'); - - $this->object->endOfPeriod($date, 'something'); - } - - /** - * @covers FireflyIII\Support\Navigation::endOfX - */ - public function testEndOfX() - { - $date = new Carbon('2015-01-01'); - $maxEnd = new Carbon('2016-01-01'); - - $result = $this->object->endOfX($date, 'month', $maxEnd); - - $this->assertEquals('2015-01-31', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::endOfX - */ - public function testEndOfXBeyondMax() - { - $date = new Carbon('2015-01-01'); - $maxEnd = new Carbon('2015-01-15'); - - $result = $this->object->endOfX($date, 'monthly', $maxEnd); - - $this->assertEquals('2015-01-15', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::periodShow - */ - public function testPeriodShow() - { - $date = new Carbon('2015-01-01'); - $result = $this->object->periodShow($date, 'month'); - $this->assertEquals('January 2015', $result); - } - - /** - * @covers FireflyIII\Support\Navigation::periodShow - * @expectedException FireflyIII\Exceptions\FireflyException - * @expectedExceptionMessage No date formats for frequency "something" - */ - public function testPeriodShowError() - { - $date = new Carbon('2015-01-01'); - $this->object->periodShow($date, 'something'); - } - - - /** - * @covers FireflyIII\Support\Navigation::startOfPeriod - */ - public function testStartOfPeriod() - { - $date = new Carbon('2015-01-15'); - $result = $this->object->startOfPeriod($date, 'month'); - $this->assertEquals('2015-01-01', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::startOfPeriod - * @expectedException FireflyIII\Exceptions\FireflyException - * @expectedExceptionMessage Cannot do startOfPeriod for $repeat_freq "something" - */ - public function testStartOfPeriodError() - { - $date = new Carbon('2015-08-15'); - $this->object->startOfPeriod($date, 'something'); - } - - /** - * @covers FireflyIII\Support\Navigation::startOfPeriod - */ - public function testStartOfPeriodHalfYear() - { - $date = new Carbon('2015-01-15'); - $result = $this->object->startOfPeriod($date, 'half-year'); - $this->assertEquals('2015-01-01', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::startOfPeriod - */ - public function testStartOfPeriodHalfYearSecondHalf() - { - $date = new Carbon('2015-08-15'); - $result = $this->object->startOfPeriod($date, 'half-year'); - $this->assertEquals('2015-07-01', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::subtractPeriod - */ - public function testSubtractPeriod() - { - $date = new Carbon('2015-01-01'); - $result = $this->object->subtractPeriod($date, 'month'); - $this->assertEquals('2014-12-01', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::subtractPeriod - * @expectedException FireflyIII\Exceptions\FireflyException - * @expectedExceptionMessage Cannot do subtractPeriod for $repeat_freq "something" - */ - public function testSubtractPeriodError() - { - $date = new Carbon('2015-01-01'); - $this->object->subtractPeriod($date, 'something'); - } - - /** - * @covers FireflyIII\Support\Navigation::subtractPeriod - */ - public function testSubtractPeriodQuarter() - { - $date = new Carbon('2015-01-01'); - $result = $this->object->subtractPeriod($date, 'quarter'); - $this->assertEquals('2014-10-01', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::updateEndDate - */ - public function testUpdateEndDate() - { - $date = new Carbon('2015-01-15'); - $result = $this->object->updateEndDate('1M', $date); - $this->assertEquals('2015-01-31', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::updateEndDate - * @expectedException FireflyIII\Exceptions\FireflyException - * @expectedExceptionMessage updateEndDate cannot handle $range "something" - */ - public function testUpdateEndDateError() - { - $date = new Carbon('2015-01-15'); - $this->object->updateEndDate('something', $date); - } - - /** - * @covers FireflyIII\Support\Navigation::updateEndDate - */ - public function testUpdateEndDateHalf() - { - $date = new Carbon('2015-01-15'); - $result = $this->object->updateEndDate('6M', $date); - $this->assertEquals('2015-07-01', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::updateEndDate - */ - public function testUpdateEndDateSecondHalf() - { - $date = new Carbon('2015-08-15'); - $result = $this->object->updateEndDate('6M', $date); - $this->assertEquals('2015-12-31', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::updateStartDate - */ - public function testUpdateStartDate() - { - $date = new Carbon('2015-01-15'); - $result = $this->object->updateStartDate('1M', $date); - $this->assertEquals('2015-01-01', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::updateStartDate - */ - public function testUpdateStartDateHalf() - { - $date = new Carbon('2015-01-15'); - $result = $this->object->updateStartDate('6M', $date); - $this->assertEquals('2015-01-01', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::updateStartDate - */ - public function testUpdateStartDateSecondHalf() - { - $date = new Carbon('2015-09-15'); - $result = $this->object->updateStartDate('6M', $date); - $this->assertEquals('2015-07-01', $result->format('Y-m-d')); - } - - /** - * @covers FireflyIII\Support\Navigation::updateStartDate - * @expectedException FireflyIII\Exceptions\FireflyException - * @expectedExceptionMessage updateStartDate cannot handle $range "something" - */ - public function testUpdateStartDateError() - { - $date = new Carbon('2015-09-15'); - $this->object->updateStartDate('something', $date); - } - - -} \ No newline at end of file From ab25edd37a0babe316bca2a544030318942f3514 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 08:13:50 +0200 Subject: [PATCH 02/60] Updated to include codeception. --- composer.json | 3 +- composer.lock | 2358 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 2289 insertions(+), 72 deletions(-) diff --git a/composer.json b/composer.json index b1134d9cd1..2bdb37e207 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ "illuminate/html": "~5.0", "league/commonmark": "0.7.*", "rcrowe/twigbridge": "0.7.x@dev", - "zizaco/entrust": "dev-laravel-5" + "zizaco/entrust": "dev-laravel-5", + "codeception/codeception": "*" }, "require-dev": { "barryvdh/laravel-debugbar": "@stable", diff --git a/composer.lock b/composer.lock index dbc3422a9f..74fa0608f8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,39 +4,33 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "c1cfabc3da3bdec86d8912a6878e0b0f", + "hash": "ac0a3c8a66984034e157599940956412", "packages": [ { "name": "classpreloader/classpreloader", - "version": "1.4.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/ClassPreloader/ClassPreloader.git", - "reference": "b76f3f4f603ebbe7e64351a7ef973431ddaf7b27" + "reference": "8c3c14b10309e3b40bce833913a6c0c0b8c8f962" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ClassPreloader/ClassPreloader/zipball/b76f3f4f603ebbe7e64351a7ef973431ddaf7b27", - "reference": "b76f3f4f603ebbe7e64351a7ef973431ddaf7b27", + "url": "https://api.github.com/repos/ClassPreloader/ClassPreloader/zipball/8c3c14b10309e3b40bce833913a6c0c0b8c8f962", + "reference": "8c3c14b10309e3b40bce833913a6c0c0b8c8f962", "shasum": "" }, "require": { "nikic/php-parser": "~1.3", - "php": ">=5.3.3", - "symfony/console": "~2.1", - "symfony/filesystem": "~2.1", - "symfony/finder": "~2.1" + "php": ">=5.5.9" }, "require-dev": { "phpunit/phpunit": "~4.0" }, - "bin": [ - "classpreloader.php" - ], "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -55,7 +49,7 @@ }, { "name": "Graham Campbell", - "email": "graham@cachethq.io" + "email": "graham@alt-three.com" } ], "description": "Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case", @@ -64,7 +58,89 @@ "class", "preload" ], - "time": "2015-05-26 10:57:51" + "time": "2015-06-28 21:39:13" + }, + { + "name": "codeception/codeception", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/Codeception/Codeception.git", + "reference": "b5af3aac061ffaeb65ed023534b3c50558e90d07" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/b5af3aac061ffaeb65ed023534b3c50558e90d07", + "reference": "b5af3aac061ffaeb65ed023534b3c50558e90d07", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "facebook/webdriver": "~0.4|~0.5", + "guzzlehttp/guzzle": ">=4.0|<7.0", + "guzzlehttp/psr7": "~1.0", + "php": ">=5.4.0", + "phpunit/phpunit": "~4.7.0", + "symfony/browser-kit": "~2.4", + "symfony/console": "~2.4", + "symfony/css-selector": "~2.4", + "symfony/dom-crawler": "~2.4,!=2.4.5", + "symfony/event-dispatcher": "~2.4", + "symfony/finder": "~2.4", + "symfony/yaml": "~2.4" + }, + "require-dev": { + "codeception/specify": "~0.3", + "facebook/php-sdk-v4": "~4.0", + "flow/jsonpath": "~0.2", + "monolog/monolog": "~1.8", + "pda/pheanstalk": "~2.0", + "videlalvaro/php-amqplib": "~2.4" + }, + "suggest": { + "codeception/phpbuiltinserver": "Extension to start and stop PHP built-in web server for your tests", + "codeception/specify": "BDD-style code blocks", + "codeception/verify": "BDD-style assertions", + "monolog/monolog": "Log test steps", + "phpseclib/phpseclib": "Extension required to use the SFTP option in the FTP Module." + }, + "bin": [ + "codecept" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "psr-4": { + "Codeception\\": "src\\Codeception", + "Codeception\\Extension\\": "ext" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Bodnarchuk", + "email": "davert@mail.ua", + "homepage": "http://codegyre.com" + } + ], + "description": "BDD-style testing framework", + "homepage": "http://codeception.com/", + "keywords": [ + "BDD", + "TDD", + "acceptance testing", + "functional testing", + "unit testing" + ], + "time": "2015-06-30 03:38:01" }, { "name": "danielstjules/stringy", @@ -619,6 +695,60 @@ ], "time": "2014-12-20 21:24:13" }, + { + "name": "doctrine/instantiator", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14 21:17:01" + }, { "name": "doctrine/lexer", "version": "v1.0.1", @@ -673,6 +803,47 @@ ], "time": "2014-09-09 13:34:57" }, + { + "name": "facebook/webdriver", + "version": "v0.6.0", + "source": { + "type": "git", + "url": "https://github.com/facebook/php-webdriver.git", + "reference": "2c5b305ea91b00ebbc433ad1663b7f16c1b31ec5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/2c5b305ea91b00ebbc433ad1663b7f16c1b31ec5", + "reference": "2c5b305ea91b00ebbc433ad1663b7f16c1b31ec5", + "shasum": "" + }, + "require": { + "php": ">=5.3.19" + }, + "require-dev": { + "phpdocumentor/phpdocumentor": "2.*", + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "autoload": { + "classmap": [ + "lib/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "A php client for WebDriver", + "homepage": "https://github.com/facebook/php-webdriver", + "keywords": [ + "facebook", + "php", + "selenium", + "webdriver" + ], + "time": "2015-02-09 19:39:34" + }, { "name": "grumpydictator/gchart", "version": "1.0.9", @@ -709,6 +880,177 @@ "description": "GChart is a small package that allows you to easily generate data for the Google Charts API.", "time": "2015-04-05 19:17:17" }, + { + "name": "guzzlehttp/guzzle", + "version": "6.0.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "f992b7b487a816c957d317442bed4966409873e0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f992b7b487a816c957d317442bed4966409873e0", + "reference": "f992b7b487a816c957d317442bed4966409873e0", + "shasum": "" + }, + "require": { + "guzzlehttp/promises": "^1.0.0", + "guzzlehttp/psr7": "^1.0.0", + "php": ">=5.5.0" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.0", + "psr/log": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.0-dev" + } + }, + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2015-05-27 16:57:51" + }, + { + "name": "guzzlehttp/promises", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7", + "reference": "2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2015-06-24 16:16:25" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "af0e1758de355eb113917ad79c3c0e3604bce4bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/af0e1758de355eb113917ad79c3c0e3604bce4bd", + "reference": "af0e1758de355eb113917ad79c3c0e3604bce4bd", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "PSR-7 message implementation", + "keywords": [ + "http", + "message", + "stream", + "uri" + ], + "time": "2015-06-24 19:55:15" + }, { "name": "illuminate/html", "version": "v5.0.0", @@ -902,20 +1244,20 @@ }, { "name": "laravel/framework", - "version": "v5.1.3", + "version": "v5.1.5", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "a7ebd043ca178c05cc7946ece03d3a268a5a3f84" + "reference": "25d872ec1945b30083f3e348039c380307b42d5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/a7ebd043ca178c05cc7946ece03d3a268a5a3f84", - "reference": "a7ebd043ca178c05cc7946ece03d3a268a5a3f84", + "url": "https://api.github.com/repos/laravel/framework/zipball/25d872ec1945b30083f3e348039c380307b42d5e", + "reference": "25d872ec1945b30083f3e348039c380307b42d5e", "shasum": "" }, "require": { - "classpreloader/classpreloader": "~1.2", + "classpreloader/classpreloader": "~2.0", "danielstjules/stringy": "~1.8", "doctrine/inflector": "~1.0", "ext-mbstring": "*", @@ -1026,7 +1368,7 @@ "framework", "laravel" ], - "time": "2015-06-24 19:38:07" + "time": "2015-07-02 02:28:22" }, { "name": "league/commonmark", @@ -1383,6 +1725,531 @@ ], "time": "2015-05-02 15:40:40" }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2015-02-03 12:10:50" + }, + { + "name": "phpspec/prophecy", + "version": "v1.4.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "phpdocumentor/reflection-docblock": "~2.0", + "sebastian/comparator": "~1.1" + }, + "require-dev": { + "phpspec/phpspec": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2015-04-27 22:15:08" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.1.7", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "07e27765596d72c378a6103e80da5d84e802f1e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/07e27765596d72c378a6103e80da5d84e802f1e4", + "reference": "07e27765596d72c378a6103e80da5d84e802f1e4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-06-30 06:52:35" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2015-04-02 05:19:05" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21 13:50:34" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/83fe1bdc5d47658b727595c14da140da92b3d66d", + "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2015-06-13 07:35:30" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/7a9b0969488c3c54fd62b4d504b3ec758fd005d9", + "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2015-06-19 03:43:16" + }, + { + "name": "phpunit/phpunit", + "version": "4.7.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "0ebabb4cda7d066be8391dfdbaf57fe70ac9a99b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0ebabb4cda7d066be8391dfdbaf57fe70ac9a99b", + "reference": "0ebabb4cda7d066be8391dfdbaf57fe70ac9a99b", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpspec/prophecy": "~1.3,>=1.3.1", + "phpunit/php-code-coverage": "~2.1", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": ">=1.0.6", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.1", + "sebastian/diff": "~1.2", + "sebastian/environment": "~1.2", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.1|~3.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.7.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2015-06-30 06:53:57" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/92408bb1968a81b3217a6fdf6c1a198da83caa35", + "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "~1.0,>=1.0.2", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2015-06-11 15:55:48" + }, + { + "name": "psr/http-message", + "version": "1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", + "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2015-05-04 20:22:00" + }, { "name": "psr/log", "version": "1.0.0", @@ -1556,6 +2423,377 @@ ], "time": "2015-05-21 13:46:00" }, + { + "name": "sebastian/comparator", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2015-01-29 16:28:08" + }, + { + "name": "sebastian/diff", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-02-22 15:13:53" + }, + { + "name": "sebastian/environment", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2015-01-01 10:01:08" + }, + { + "name": "sebastian/exporter", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "84839970d05254c73cde183a721c7af13aede943" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", + "reference": "84839970d05254c73cde183a721c7af13aede943", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2015-01-27 07:23:06" + }, + { + "name": "sebastian/global-state", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2014-10-06 09:23:50" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-01-24 09:48:32" + }, + { + "name": "sebastian/version", + "version": "1.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2015-06-21 13:59:46" + }, { "name": "swiftmailer/swiftmailer", "version": "v5.4.1", @@ -1609,6 +2847,61 @@ ], "time": "2015-06-06 14:19:39" }, + { + "name": "symfony/browser-kit", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/BrowserKit.git", + "reference": "d0a144a1a96d5dc90bed2814b2096a1322761672" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/d0a144a1a96d5dc90bed2814b2096a1322761672", + "reference": "d0a144a1a96d5dc90bed2814b2096a1322761672", + "shasum": "" + }, + "require": { + "php": ">=5.3.9", + "symfony/dom-crawler": "~2.0,>=2.0.5" + }, + "require-dev": { + "symfony/css-selector": "~2.0,>=2.0.5", + "symfony/phpunit-bridge": "~2.7", + "symfony/process": "~2.0,>=2.0.5" + }, + "suggest": { + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\BrowserKit\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony BrowserKit Component", + "homepage": "https://symfony.com", + "time": "2015-06-04 20:11:48" + }, { "name": "symfony/console", "version": "v2.7.1", @@ -1890,55 +3183,6 @@ "homepage": "https://symfony.com", "time": "2015-06-08 09:37:21" }, - { - "name": "symfony/filesystem", - "version": "v2.7.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/Filesystem.git", - "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a0d43eb3e17d4f4c6990289805a488a0482a07f3", - "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "https://symfony.com", - "time": "2015-06-08 09:37:21" - }, { "name": "symfony/finder", "version": "v2.7.1", @@ -2361,6 +3605,55 @@ ], "time": "2015-06-08 09:37:21" }, + { + "name": "symfony/yaml", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/9808e75c609a14f6db02f70fccf4ca4aab53c160", + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2015-06-10 15:30:22" + }, { "name": "twig/twig", "version": "v1.18.2", @@ -2587,7 +3880,930 @@ "time": "2015-05-25 00:17:51" } ], - "packages-dev": null, + "packages-dev": [ + { + "name": "barryvdh/laravel-debugbar", + "version": "v2.0.4", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "3edaea0e8056edde00f7d0af13ed0d406412182d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/3edaea0e8056edde00f7d0af13ed0d406412182d", + "reference": "3edaea0e8056edde00f7d0af13ed0d406412182d", + "shasum": "" + }, + "require": { + "illuminate/support": "~5.0.17|5.1.*", + "maximebf/debugbar": "~1.10.2", + "php": ">=5.4.0", + "symfony/finder": "~2.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "laravel", + "profiler", + "webprofiler" + ], + "time": "2015-06-07 07:19:29" + }, + { + "name": "barryvdh/laravel-ide-helper", + "version": "v2.0.6", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-ide-helper.git", + "reference": "037386153630a7515a1542f29410d8c267651689" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-ide-helper/zipball/037386153630a7515a1542f29410d8c267651689", + "reference": "037386153630a7515a1542f29410d8c267651689", + "shasum": "" + }, + "require": { + "illuminate/console": "5.0.x|5.1.x", + "illuminate/filesystem": "5.0.x|5.1.x", + "illuminate/support": "5.0.x|5.1.x", + "php": ">=5.4.0", + "phpdocumentor/reflection-docblock": "2.0.4", + "symfony/class-loader": "~2.3" + }, + "require-dev": { + "doctrine/dbal": "~2.3" + }, + "suggest": { + "doctrine/dbal": "Load information from the database about models for phpdocs (~2.3)" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\LaravelIdeHelper\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.", + "keywords": [ + "autocomplete", + "codeintel", + "helper", + "ide", + "laravel", + "netbeans", + "phpdoc", + "phpstorm", + "sublime" + ], + "time": "2015-06-25 08:58:59" + }, + { + "name": "codeclimate/php-test-reporter", + "version": "v0.1.2", + "source": { + "type": "git", + "url": "https://github.com/codeclimate/php-test-reporter.git", + "reference": "8ed24ff30f3663ecf40f1c12d6c97eb56c69e646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/codeclimate/php-test-reporter/zipball/8ed24ff30f3663ecf40f1c12d6c97eb56c69e646", + "reference": "8ed24ff30f3663ecf40f1c12d6c97eb56c69e646", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3", + "satooshi/php-coveralls": "0.6.*", + "symfony/console": ">=2.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*@stable" + }, + "bin": [ + "composer/bin/test-reporter" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "CodeClimate\\Component": "src/", + "CodeClimate\\Bundle": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Code Climate", + "email": "hello@codeclimate.com", + "homepage": "https://codeclimate.com" + } + ], + "description": "PHP client for reporting test coverage to Code Climate", + "homepage": "https://github.com/codeclimate/php-test-reporter", + "keywords": [ + "codeclimate", + "coverage" + ], + "time": "2014-07-23 13:42:41" + }, + { + "name": "fzaninotto/faker", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/fzaninotto/Faker.git", + "reference": "010c7efedd88bf31141a02719f51fb44c732d5a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/010c7efedd88bf31141a02719f51fb44c732d5a0", + "reference": "010c7efedd88bf31141a02719f51fb44c732d5a0", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~1.5" + }, + "type": "library", + "extra": { + "branch-alias": [] + }, + "autoload": { + "psr-0": { + "Faker": "src/", + "Faker\\PHPUnit": "test/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "time": "2014-06-04 14:43:02" + }, + { + "name": "guzzle/guzzle", + "version": "v3.9.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle3.git", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3.3", + "symfony/event-dispatcher": "~2.1" + }, + "replace": { + "guzzle/batch": "self.version", + "guzzle/cache": "self.version", + "guzzle/common": "self.version", + "guzzle/http": "self.version", + "guzzle/inflection": "self.version", + "guzzle/iterator": "self.version", + "guzzle/log": "self.version", + "guzzle/parser": "self.version", + "guzzle/plugin": "self.version", + "guzzle/plugin-async": "self.version", + "guzzle/plugin-backoff": "self.version", + "guzzle/plugin-cache": "self.version", + "guzzle/plugin-cookie": "self.version", + "guzzle/plugin-curlauth": "self.version", + "guzzle/plugin-error-response": "self.version", + "guzzle/plugin-history": "self.version", + "guzzle/plugin-log": "self.version", + "guzzle/plugin-md5": "self.version", + "guzzle/plugin-mock": "self.version", + "guzzle/plugin-oauth": "self.version", + "guzzle/service": "self.version", + "guzzle/stream": "self.version" + }, + "require-dev": { + "doctrine/cache": "~1.3", + "monolog/monolog": "~1.0", + "phpunit/phpunit": "3.7.*", + "psr/log": "~1.0", + "symfony/class-loader": "~2.1", + "zendframework/zend-cache": "2.*,<2.3", + "zendframework/zend-log": "2.*,<2.3" + }, + "suggest": { + "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.9-dev" + } + }, + "autoload": { + "psr-0": { + "Guzzle": "src/", + "Guzzle\\Tests": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Guzzle Community", + "homepage": "https://github.com/guzzle/guzzle/contributors" + } + ], + "description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2015-03-18 18:23:50" + }, + { + "name": "hamcrest/hamcrest-php", + "version": "v1.2.2", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b37020aa976fa52d3de9aa904aa2522dc518f79c", + "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "1.3.3", + "satooshi/php-coveralls": "dev-master" + }, + "type": "library", + "autoload": { + "classmap": [ + "hamcrest" + ], + "files": [ + "hamcrest/Hamcrest.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "time": "2015-05-11 14:41:42" + }, + { + "name": "league/factory-muffin", + "version": "v2.1.1", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/factory-muffin.git", + "reference": "91f0adcdac6b5f7bf2277ac2c90f94352afe65de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/factory-muffin/zipball/91f0adcdac6b5f7bf2277ac2c90f94352afe65de", + "reference": "91f0adcdac6b5f7bf2277ac2c90f94352afe65de", + "shasum": "" + }, + "require": { + "fzaninotto/faker": "1.4.*", + "php": ">=5.3.3" + }, + "replace": { + "zizaco/factory-muff": "self.version" + }, + "require-dev": { + "illuminate/database": "~4.1", + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "illuminate/database": "Factory Muffin works well with eloquent models." + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\FactoryMuffin\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "graham@mineuk.com" + }, + { + "name": "Zizaco Zizuini", + "email": "zizaco@gmail.com" + }, + { + "name": "Scott Robertson", + "email": "scottymeuk@gmail.com" + } + ], + "description": "The goal of this package is to enable the rapid creation of objects for the purpose of testing.", + "homepage": "http://factory-muffin.thephpleague.com/", + "keywords": [ + "factory", + "laravel", + "testing" + ], + "time": "2014-09-18 18:29:06" + }, + { + "name": "maximebf/debugbar", + "version": "v1.10.4", + "source": { + "type": "git", + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "7b2006e6e095126b5a061ec33fca3d90ea8a8219" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/7b2006e6e095126b5a061ec33fca3d90ea8a8219", + "reference": "7b2006e6e095126b5a061ec33fca3d90ea8a8219", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "~1.0", + "symfony/var-dumper": "~2.6" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-0": { + "DebugBar": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", + "keywords": [ + "debug" + ], + "time": "2015-02-05 07:51:20" + }, + { + "name": "mockery/mockery", + "version": "0.9.4", + "source": { + "type": "git", + "url": "https://github.com/padraic/mockery.git", + "reference": "70bba85e4aabc9449626651f48b9018ede04f86b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/padraic/mockery/zipball/70bba85e4aabc9449626651f48b9018ede04f86b", + "reference": "70bba85e4aabc9449626651f48b9018ede04f86b", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "~1.1", + "lib-pcre": ">=7.0", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.9.x-dev" + } + }, + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.", + "homepage": "http://github.com/padraic/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "time": "2015-04-02 19:54:00" + }, + { + "name": "phpspec/php-diff", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/phpspec/php-diff.git", + "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/php-diff/zipball/30e103d19519fe678ae64a60d77884ef3d71b28a", + "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Diff": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Chris Boulton", + "homepage": "http://github.com/chrisboulton", + "role": "Original developer" + } + ], + "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).", + "time": "2013-11-01 13:02:21" + }, + { + "name": "phpspec/phpspec", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/phpspec.git", + "reference": "e9a40577323e67f1de2e214abf32976a0352d8f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/phpspec/zipball/e9a40577323e67f1de2e214abf32976a0352d8f8", + "reference": "e9a40577323e67f1de2e214abf32976a0352d8f8", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.1", + "php": ">=5.3.3", + "phpspec/php-diff": "~1.0.0", + "phpspec/prophecy": "~1.4", + "sebastian/exporter": "~1.0", + "symfony/console": "~2.3", + "symfony/event-dispatcher": "~2.1", + "symfony/finder": "~2.1", + "symfony/process": "~2.1", + "symfony/yaml": "~2.1" + }, + "require-dev": { + "behat/behat": "^3.0.11", + "bossa/phpspec2-expect": "~1.0", + "phpunit/phpunit": "~4.4", + "symfony/filesystem": "~2.1", + "symfony/process": "~2.1" + }, + "suggest": { + "phpspec/nyan-formatters": "~1.0 – Adds Nyan formatters" + }, + "bin": [ + "bin/phpspec" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "PhpSpec": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "homepage": "http://marcelloduarte.net/" + } + ], + "description": "Specification-oriented BDD framework for PHP 5.3+", + "homepage": "http://phpspec.net/", + "keywords": [ + "BDD", + "SpecBDD", + "TDD", + "spec", + "specification", + "testing", + "tests" + ], + "time": "2015-05-30 15:21:40" + }, + { + "name": "satooshi/php-coveralls", + "version": "v0.6.1", + "source": { + "type": "git", + "url": "https://github.com/satooshi/php-coveralls.git", + "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", + "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-simplexml": "*", + "guzzle/guzzle": ">=3.0", + "php": ">=5.3", + "psr/log": "1.0.0", + "symfony/config": ">=2.0", + "symfony/console": ">=2.0", + "symfony/stopwatch": ">=2.2", + "symfony/yaml": ">=2.0" + }, + "require-dev": { + "apigen/apigen": "2.8.*@stable", + "pdepend/pdepend": "dev-master", + "phpmd/phpmd": "dev-master", + "phpunit/php-invoker": ">=1.1.0,<1.2.0", + "phpunit/phpunit": "3.7.*@stable", + "sebastian/finder-facade": "dev-master", + "sebastian/phpcpd": "1.4.*@stable", + "squizlabs/php_codesniffer": "1.4.*@stable", + "theseer/fdomdocument": "dev-master" + }, + "bin": [ + "composer/bin/coveralls" + ], + "type": "library", + "autoload": { + "psr-0": { + "Contrib\\Component": "src/", + "Contrib\\Bundle": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kitamura Satoshi", + "email": "with.no.parachute@gmail.com", + "homepage": "https://www.facebook.com/satooshi.jp" + } + ], + "description": "PHP client library for Coveralls API", + "homepage": "https://github.com/satooshi/php-coveralls", + "keywords": [ + "ci", + "coverage", + "github", + "test" + ], + "time": "2013-05-04 08:07:33" + }, + { + "name": "symfony/class-loader", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/ClassLoader.git", + "reference": "84843730de48ca0feba91004a03c7c952f8ea1da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/84843730de48ca0feba91004a03c7c952f8ea1da", + "reference": "84843730de48ca0feba91004a03c7c952f8ea1da", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/finder": "~2.0,>=2.0.5", + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\ClassLoader\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony ClassLoader Component", + "homepage": "https://symfony.com", + "time": "2015-06-08 09:37:21" + }, + { + "name": "symfony/config", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Config.git", + "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Config/zipball/58ded81f1f582a87c528ef3dae9a859f78b5f374", + "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374", + "shasum": "" + }, + "require": { + "php": ">=5.3.9", + "symfony/filesystem": "~2.3" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "https://symfony.com", + "time": "2015-06-11 14:06:56" + }, + { + "name": "symfony/filesystem", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a0d43eb3e17d4f4c6990289805a488a0482a07f3", + "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2015-06-08 09:37:21" + }, + { + "name": "symfony/stopwatch", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Stopwatch.git", + "reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/c653f1985f6c2b7dbffd04d48b9c0a96aaef814b", + "reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2015-06-04 20:11:48" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": { From 24e7c68243ace3a89013ad5c79421e4de93d5f95 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 08:15:30 +0200 Subject: [PATCH 03/60] Initial codeception installation. --- .gitignore | 1 + codeception.yml | 21 + tests/_bootstrap.php | 2 + tests/_output/.gitignore | 2 + tests/_support/AcceptanceTester.php | 26 + tests/_support/FunctionalTester.php | 26 + tests/_support/Helper/Acceptance.php | 9 + tests/_support/Helper/Functional.php | 9 + tests/_support/Helper/Unit.php | 9 + tests/_support/UnitTester.php | 26 + .../_generated/AcceptanceTesterActions.php | 1972 +++++++++++++++++ .../_generated/FunctionalTesterActions.php | 18 + .../_support/_generated/UnitTesterActions.php | 348 +++ tests/acceptance.suite.yml | 12 + tests/acceptance/_bootstrap.php | 2 + tests/functional.suite.yml | 11 + tests/functional/_bootstrap.php | 2 + tests/unit.suite.yml | 9 + tests/unit/_bootstrap.php | 2 + 19 files changed, 2507 insertions(+) create mode 100644 codeception.yml create mode 100644 tests/_bootstrap.php create mode 100644 tests/_output/.gitignore create mode 100644 tests/_support/AcceptanceTester.php create mode 100644 tests/_support/FunctionalTester.php create mode 100644 tests/_support/Helper/Acceptance.php create mode 100644 tests/_support/Helper/Functional.php create mode 100644 tests/_support/Helper/Unit.php create mode 100644 tests/_support/UnitTester.php create mode 100644 tests/_support/_generated/AcceptanceTesterActions.php create mode 100644 tests/_support/_generated/FunctionalTesterActions.php create mode 100644 tests/_support/_generated/UnitTesterActions.php create mode 100644 tests/acceptance.suite.yml create mode 100644 tests/acceptance/_bootstrap.php create mode 100644 tests/functional.suite.yml create mode 100644 tests/functional/_bootstrap.php create mode 100644 tests/unit.suite.yml create mode 100644 tests/unit/_bootstrap.php diff --git a/.gitignore b/.gitignore index 7ea9221a8b..2eb9714228 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,5 @@ addNewLines.php .env.backup .env.local +tests/_output/* tests/_output/* \ No newline at end of file diff --git a/codeception.yml b/codeception.yml new file mode 100644 index 0000000000..3a8fca8145 --- /dev/null +++ b/codeception.yml @@ -0,0 +1,21 @@ +actor: Tester +paths: + tests: tests + log: tests/_output + data: tests/_data + support: tests/_support + envs: tests/_envs +settings: + bootstrap: _bootstrap.php + colors: true + memory_limit: 1024M +extensions: + enabled: + - Codeception\Extension\RunFailed +modules: + config: + Db: + dsn: '' + user: '' + password: '' + dump: tests/_data/dump.sql diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php new file mode 100644 index 0000000000..243f9c85bc --- /dev/null +++ b/tests/_bootstrap.php @@ -0,0 +1,2 @@ +setHeader('X-Requested-With', 'Codeception'); + * $I->amOnPage('test-headers.php'); + * ?> + * ``` + * + * @param string $name the name of the request header + * @param string $value the value to set it to for subsequent + * requests + * @see \Codeception\Module\PhpBrowser::setHeader() + */ + public function setHeader($name, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('setHeader', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Deletes the header with the passed name. Subsequent requests + * will not have the deleted header in its request. + * + * Example: + * ```php + * setHeader('X-Requested-With', 'Codeception'); + * $I->amOnPage('test-headers.php'); + * // ... + * $I->deleteHeader('X-Requested-With'); + * $I->amOnPage('some-other-page.php'); + * ?> + * ``` + * + * @param string $name the name of the header to delete. + * @see \Codeception\Module\PhpBrowser::deleteHeader() + */ + public function deleteHeader($name) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('deleteHeader', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Authenticates user for HTTP_AUTH + * + * @param $username + * @param $password + * @see \Codeception\Module\PhpBrowser::amHttpAuthenticated() + */ + public function amHttpAuthenticated($username, $password) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Open web page at the given absolute URL and sets its hostname as the base host. + * + * ``` php + * amOnUrl('http://codeception.com'); + * $I->amOnPage('/quickstart'); // moves to http://codeception.com/quickstart + * ?> + * ``` + * @see \Codeception\Module\PhpBrowser::amOnUrl() + */ + public function amOnUrl($url) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Changes the subdomain for the 'url' configuration parameter. + * Does not open a page; use `amOnPage` for that. + * + * ``` php + * amOnSubdomain('user'); + * $I->amOnPage('/'); + * // moves to http://user.mysite.com/ + * ?> + * ``` + * + * @param $subdomain + * + * @return mixed + * @see \Codeception\Module\PhpBrowser::amOnSubdomain() + */ + public function amOnSubdomain($subdomain) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Low-level API method. + * If Codeception commands are not enough, use [Guzzle HTTP Client](http://guzzlephp.org/) methods directly + * + * Example: + * + * ``` php + * executeInGuzzle(function (\GuzzleHttp\Client $client) { + * $client->get('/get', ['query' => ['foo' => 'bar']]); + * }); + * ?> + * ``` + * + * It is not recommended to use this command on a regular basis. + * If Codeception lacks important Guzzle Client methods, implement them and submit patches. + * + * @param callable $function + * @see \Codeception\Module\PhpBrowser::executeInGuzzle() + */ + public function executeInGuzzle($function) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('executeInGuzzle', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Opens the page for the given relative URI. + * + * ``` php + * amOnPage('/'); + * // opens /register page + * $I->amOnPage('/register'); + * ?> + * ``` + * + * @param $page + * @see \Codeception\Lib\InnerBrowser::amOnPage() + */ + public function amOnPage($page) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Perform a click on a link or a button, given by a locator. + * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. + * For buttons, the "value" attribute, "name" attribute, and inner text are searched. + * For links, the link text is searched. + * For images, the "alt" attribute and inner text of any parent links are searched. + * + * The second parameter is a context (CSS or XPath locator) to narrow the search. + * + * Note that if the locator matches a button of type `submit`, the form will be submitted. + * + * ``` php + * click('Logout'); + * // button of form + * $I->click('Submit'); + * // CSS button + * $I->click('#form input[type=submit]'); + * // XPath + * $I->click('//form/*[@type=submit]'); + * // link in context + * $I->click('Logout', '#nav'); + * // using strict locator + * $I->click(['link' => 'Login']); + * ?> + * ``` + * + * @param $link + * @param $context + * @see \Codeception\Lib\InnerBrowser::click() + */ + public function click($link, $context = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('click', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string. + * Specify a locator as the second parameter to match a specific region. + * + * ``` php + * see('Logout'); // I can suppose user is logged in + * $I->see('Sign Up','h1'); // I can suppose it's a signup page + * $I->see('Sign Up','//body/h1'); // with XPath + * ?> + * ``` + * + * @param $text + * @param null $selector + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::see() + */ + public function canSee($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string. + * Specify a locator as the second parameter to match a specific region. + * + * ``` php + * see('Logout'); // I can suppose user is logged in + * $I->see('Sign Up','h1'); // I can suppose it's a signup page + * $I->see('Sign Up','//body/h1'); // with XPath + * ?> + * ``` + * + * @param $text + * @param null $selector + * @see \Codeception\Lib\InnerBrowser::see() + */ + public function see($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('see', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page doesn't contain the text specified. + * Give a locator as the second parameter to match a specific region. + * + * ```php + * dontSee('Login'); // I can suppose user is already logged in + * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page + * $I->dontSee('Sign Up','//body/h1'); // with XPath + * ?> + * ``` + * + * @param $text + * @param null $selector + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSee() + */ + public function cantSee($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page doesn't contain the text specified. + * Give a locator as the second parameter to match a specific region. + * + * ```php + * dontSee('Login'); // I can suppose user is already logged in + * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page + * $I->dontSee('Sign Up','//body/h1'); // with XPath + * ?> + * ``` + * + * @param $text + * @param null $selector + * @see \Codeception\Lib\InnerBrowser::dontSee() + */ + public function dontSee($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there's a link with the specified text. + * Give a full URL as the second parameter to match links with that exact URL. + * + * ``` php + * seeLink('Logout'); // matches Logout + * $I->seeLink('Logout','/logout'); // matches Logout + * ?> + * ``` + * + * @param $text + * @param null $url + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeLink() + */ + public function canSeeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there's a link with the specified text. + * Give a full URL as the second parameter to match links with that exact URL. + * + * ``` php + * seeLink('Logout'); // matches Logout + * $I->seeLink('Logout','/logout'); // matches Logout + * ?> + * ``` + * + * @param $text + * @param null $url + * @see \Codeception\Lib\InnerBrowser::seeLink() + */ + public function seeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page doesn't contain a link with the given string. + * If the second parameter is given, only links with a matching "href" attribute will be checked. + * + * ``` php + * dontSeeLink('Logout'); // I suppose user is not logged in + * $I->dontSeeLink('Checkout now', '/store/cart.php'); + * ?> + * ``` + * + * @param $text + * @param null $url + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeLink() + */ + public function cantSeeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page doesn't contain a link with the given string. + * If the second parameter is given, only links with a matching "href" attribute will be checked. + * + * ``` php + * dontSeeLink('Logout'); // I suppose user is not logged in + * $I->dontSeeLink('Checkout now', '/store/cart.php'); + * ?> + * ``` + * + * @param $text + * @param null $url + * @see \Codeception\Lib\InnerBrowser::dontSeeLink() + */ + public function dontSeeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current URI contains the given string. + * + * ``` php + * seeInCurrentUrl('home'); + * // to match: /users/1 + * $I->seeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() + */ + public function canSeeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current URI contains the given string. + * + * ``` php + * seeInCurrentUrl('home'); + * // to match: /users/1 + * $I->seeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() + */ + public function seeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URI doesn't contain the given string. + * + * ``` php + * dontSeeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() + */ + public function cantSeeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URI doesn't contain the given string. + * + * ``` php + * dontSeeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() + */ + public function dontSeeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL is equal to the given string. + * Unlike `seeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * seeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() + */ + public function canSeeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL is equal to the given string. + * Unlike `seeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * seeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() + */ + public function seeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL doesn't equal the given string. + * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * dontSeeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() + */ + public function cantSeeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL doesn't equal the given string. + * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * dontSeeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() + */ + public function dontSeeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL matches the given regular expression. + * + * ``` php + * seeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() + */ + public function canSeeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL matches the given regular expression. + * + * ``` php + * seeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() + */ + public function seeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url doesn't match the given regular expression. + * + * ``` php + * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() + */ + public function cantSeeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url doesn't match the given regular expression. + * + * ``` php + * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() + */ + public function dontSeeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Executes the given regular expression against the current URI and returns the first match. + * If no parameters are provided, the full URI is returned. + * + * ``` php + * grabFromCurrentUrl('~$/user/(\d+)/~'); + * $uri = $I->grabFromCurrentUrl(); + * ?> + * ``` + * + * @param null $uri + * + * @internal param $url + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl() + */ + public function grabFromCurrentUrl($uri = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the specified checkbox is checked. + * + * ``` php + * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. + * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); + * ?> + * ``` + * + * @param $checkbox + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() + */ + public function canSeeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the specified checkbox is checked. + * + * ``` php + * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. + * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); + * ?> + * ``` + * + * @param $checkbox + * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() + */ + public function seeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that the specified checkbox is unchecked. + * + * ``` php + * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. + * ?> + * ``` + * + * @param $checkbox + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() + */ + public function cantSeeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that the specified checkbox is unchecked. + * + * ``` php + * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. + * ?> + * ``` + * + * @param $checkbox + * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() + */ + public function dontSeeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given input field or textarea contains the given value. + * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. + * + * ``` php + * seeInField('Body','Type your comment here'); + * $I->seeInField('form textarea[name=body]','Type your comment here'); + * $I->seeInField('form input[type=hidden]','hidden_value'); + * $I->seeInField('#searchform input','Search'); + * $I->seeInField('//form/*[@name=search]','Search'); + * $I->seeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInField() + */ + public function canSeeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given input field or textarea contains the given value. + * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. + * + * ``` php + * seeInField('Body','Type your comment here'); + * $I->seeInField('form textarea[name=body]','Type your comment here'); + * $I->seeInField('form input[type=hidden]','hidden_value'); + * $I->seeInField('#searchform input','Search'); + * $I->seeInField('//form/*[@name=search]','Search'); + * $I->seeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Lib\InnerBrowser::seeInField() + */ + public function seeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that an input field or textarea doesn't contain the given value. + * For fuzzy locators, the field is matched by label text, CSS and XPath. + * + * ``` php + * dontSeeInField('Body','Type your comment here'); + * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); + * $I->dontSeeInField('form input[type=hidden]','hidden_value'); + * $I->dontSeeInField('#searchform input','Search'); + * $I->dontSeeInField('//form/*[@name=search]','Search'); + * $I->dontSeeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInField() + */ + public function cantSeeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that an input field or textarea doesn't contain the given value. + * For fuzzy locators, the field is matched by label text, CSS and XPath. + * + * ``` php + * dontSeeInField('Body','Type your comment here'); + * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); + * $I->dontSeeInField('form input[type=hidden]','hidden_value'); + * $I->dontSeeInField('#searchform input','Search'); + * $I->dontSeeInField('//form/*[@name=search]','Search'); + * $I->dontSeeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Lib\InnerBrowser::dontSeeInField() + */ + public function dontSeeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are set on the form matched with the + * passed selector. + * + * ``` php + * seeInFormFields('form[name=myform]', [ + * 'input1' => 'value', + * 'input2' => 'other value', + * ]); + * ?> + * ``` + * + * For multi-select elements, or to check values of multiple elements with the same name, an + * array may be passed: + * + * ``` php + * seeInFormFields('.form-class', [ + * 'multiselect' => [ + * 'value1', + * 'value2', + * ], + * 'checkbox[]' => [ + * 'a checked value', + * 'another checked value', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * seeInFormFields('#form-id', [ + * 'checkbox1' => true, // passes if checked + * 'checkbox2' => false, // passes if unchecked + * ]); + * ?> + * ``` + * + * Pair this with submitForm for quick testing magic. + * + * ``` php + * 'value', + * 'field2' => 'another value', + * 'checkbox1' => true, + * // ... + * ]; + * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); + * // $I->amOnPage('/path/to/form-page') may be needed + * $I->seeInFormFields('//form[@id=my-form]', $form); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInFormFields() + */ + public function canSeeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInFormFields', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are set on the form matched with the + * passed selector. + * + * ``` php + * seeInFormFields('form[name=myform]', [ + * 'input1' => 'value', + * 'input2' => 'other value', + * ]); + * ?> + * ``` + * + * For multi-select elements, or to check values of multiple elements with the same name, an + * array may be passed: + * + * ``` php + * seeInFormFields('.form-class', [ + * 'multiselect' => [ + * 'value1', + * 'value2', + * ], + * 'checkbox[]' => [ + * 'a checked value', + * 'another checked value', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * seeInFormFields('#form-id', [ + * 'checkbox1' => true, // passes if checked + * 'checkbox2' => false, // passes if unchecked + * ]); + * ?> + * ``` + * + * Pair this with submitForm for quick testing magic. + * + * ``` php + * 'value', + * 'field2' => 'another value', + * 'checkbox1' => true, + * // ... + * ]; + * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); + * // $I->amOnPage('/path/to/form-page') may be needed + * $I->seeInFormFields('//form[@id=my-form]', $form); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * @see \Codeception\Lib\InnerBrowser::seeInFormFields() + */ + public function seeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInFormFields', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are not set on the form matched with + * the passed selector. + * + * ``` php + * dontSeeInFormFields('form[name=myform]', [ + * 'input1' => 'non-existent value', + * 'input2' => 'other non-existent value', + * ]); + * ?> + * ``` + * + * To check that an element hasn't been assigned any one of many values, an array can be passed + * as the value: + * + * ``` php + * dontSeeInFormFields('.form-class', [ + * 'fieldName' => [ + * 'This value shouldn\'t be set', + * 'And this value shouldn\'t be set', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * dontSeeInFormFields('#form-id', [ + * 'checkbox1' => true, // fails if checked + * 'checkbox2' => false, // fails if unchecked + * ]); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() + */ + public function cantSeeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInFormFields', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are not set on the form matched with + * the passed selector. + * + * ``` php + * dontSeeInFormFields('form[name=myform]', [ + * 'input1' => 'non-existent value', + * 'input2' => 'other non-existent value', + * ]); + * ?> + * ``` + * + * To check that an element hasn't been assigned any one of many values, an array can be passed + * as the value: + * + * ``` php + * dontSeeInFormFields('.form-class', [ + * 'fieldName' => [ + * 'This value shouldn\'t be set', + * 'And this value shouldn\'t be set', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * dontSeeInFormFields('#form-id', [ + * 'checkbox1' => true, // fails if checked + * 'checkbox2' => false, // fails if unchecked + * ]); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() + */ + public function dontSeeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInFormFields', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Submits the given form on the page, optionally with the given form + * values. Give the form fields values as an array. + * + * Skipped fields will be filled by their values from the page. + * You don't need to click the 'Submit' button afterwards. + * This command itself triggers the request to form's action. + * + * You can optionally specify what button's value to include + * in the request with the last parameter as an alternative to + * explicitly setting its value in the second parameter, as + * button values are not otherwise included in the request. + * + * Examples: + * + * ``` php + * submitForm('#login', [ + * 'login' => 'davert', + * 'password' => '123456' + * ]); + * // or + * $I->submitForm('#login', [ + * 'login' => 'davert', + * 'password' => '123456' + * ], 'submitButtonName'); + * + * ``` + * + * For example, given this sample "Sign Up" form: + * + * ``` html + *
+ * Login: + *
+ * Password: + *
+ * Do you agree to out terms? + *
+ * Select pricing plan: + * + * + *
+ * ``` + * + * You could write the following to submit it: + * + * ``` php + * submitForm( + * '#userForm', + * [ + * 'user' => [ + * 'login' => 'Davert', + * 'password' => '123456', + * 'agree' => true + * ] + * ], + * 'submitButton' + * ); + * ``` + * Note that "2" will be the submitted value for the "plan" field, as it is + * the selected option. + * + * You can also emulate a JavaScript submission by not specifying any + * buttons in the third parameter to submitForm. + * + * ```php + * submitForm( + * '#userForm', + * [ + * 'user' => [ + * 'login' => 'Davert', + * 'password' => '123456', + * 'agree' => true + * ] + * ] + * ); + * ``` + * + * Pair this with seeInFormFields for quick testing magic. + * + * ``` php + * 'value', + * 'field2' => 'another value', + * 'checkbox1' => true, + * // ... + * ]; + * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); + * // $I->amOnPage('/path/to/form-page') may be needed + * $I->seeInFormFields('//form[@id=my-form]', $form); + * ?> + * ``` + * + * Parameter values can be set to arrays for multiple input fields + * of the same name, or multi-select combo boxes. For checkboxes, + * either the string value can be used, or boolean values which will + * be replaced by the checkbox's value in the DOM. + * + * ``` php + * submitForm('#my-form', [ + * 'field1' => 'value', + * 'checkbox' => [ + * 'value of first checkbox', + * 'value of second checkbox, + * ], + * 'otherCheckboxes' => [ + * true, + * false, + * false + * ], + * 'multiselect' => [ + * 'first option value', + * 'second option value' + * ] + * ]); + * ?> + * ``` + * + * Mixing string and boolean values for a checkbox's value is not supported + * and may produce unexpected results. + * + * Field names ending in "[]" must be passed without the trailing square + * bracket characters, and must contain an array for its value. This allows + * submitting multiple values with the same name, consider: + * + * ```php + * $I->submitForm('#my-form', [ + * 'field[]' => 'value', + * 'field[]' => 'another value', // 'field[]' is already a defined key + * ]); + * ``` + * + * The solution is to pass an array value: + * + * ```php + * // this way both values are submitted + * $I->submitForm('#my-form', [ + * 'field' => [ + * 'value', + * 'another value', + * ] + * ]); + * ``` + * + * @param $selector + * @param $params + * @param $button + * @see \Codeception\Lib\InnerBrowser::submitForm() + */ + public function submitForm($selector, $params, $button = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('submitForm', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Fills a text field or textarea with the given string. + * + * ``` php + * fillField("//input[@type='text']", "Hello World!"); + * $I->fillField(['name' => 'email'], 'jon@mail.com'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Lib\InnerBrowser::fillField() + */ + public function fillField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('fillField', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Selects an option in a select tag or in radio button group. + * + * ``` php + * selectOption('form select[name=account]', 'Premium'); + * $I->selectOption('form input[name=payment]', 'Monthly'); + * $I->selectOption('//form/select[@name=account]', 'Monthly'); + * ?> + * ``` + * + * Provide an array for the second argument to select multiple options: + * + * ``` php + * selectOption('Which OS do you use?', array('Windows','Linux')); + * ?> + * ``` + * + * @param $select + * @param $option + * @see \Codeception\Lib\InnerBrowser::selectOption() + */ + public function selectOption($select, $option) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('selectOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Ticks a checkbox. For radio buttons, use the `selectOption` method instead. + * + * ``` php + * checkOption('#agree'); + * ?> + * ``` + * + * @param $option + * @see \Codeception\Lib\InnerBrowser::checkOption() + */ + public function checkOption($option) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('checkOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Unticks a checkbox. + * + * ``` php + * uncheckOption('#notify'); + * ?> + * ``` + * + * @param $option + * @see \Codeception\Lib\InnerBrowser::uncheckOption() + */ + public function uncheckOption($option) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Attaches a file relative to the Codeception data directory to the given file upload field. + * + * ``` php + * attachFile('input[@type="file"]', 'prices.xls'); + * ?> + * ``` + * + * @param $field + * @param $filename + * @see \Codeception\Lib\InnerBrowser::attachFile() + */ + public function attachFile($field, $filename) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('attachFile', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * If your page triggers an ajax request, you can perform it manually. + * This action sends a GET ajax request with specified params. + * + * See ->sendAjaxPostRequest for examples. + * + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxGetRequest() + */ + public function sendAjaxGetRequest($uri, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * If your page triggers an ajax request, you can perform it manually. + * This action sends a POST ajax request with specified params. + * Additional params can be passed as array. + * + * Example: + * + * Imagine that by clicking checkbox you trigger ajax request which updates user settings. + * We emulate that click by running this ajax request manually. + * + * ``` php + * sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST + * $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET + * + * ``` + * + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxPostRequest() + */ + public function sendAjaxPostRequest($uri, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * If your page triggers an ajax request, you can perform it manually. + * This action sends an ajax request with specified method and params. + * + * Example: + * + * You need to perform an ajax request specifying the HTTP method. + * + * ``` php + * sendAjaxRequest('PUT', '/posts/7', array('title' => 'new title')); + * + * ``` + * + * @param $method + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxRequest() + */ + public function sendAjaxRequest($method, $uri, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxRequest', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Finds and returns the text contents of the given element. + * If a fuzzy locator is used, the element is found using CSS, XPath, and by matching the full page source by regular expression. + * + * ``` php + * grabTextFrom('h1'); + * $heading = $I->grabTextFrom('descendant-or-self::h1'); + * $value = $I->grabTextFrom('~ + * ``` + * + * @param $cssOrXPathOrRegex + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabTextFrom() + */ + public function grabTextFrom($cssOrXPathOrRegex) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Grabs the value of the given attribute value from the given element. + * Fails if element is not found. + * + * ``` php + * grabAttributeFrom('#tooltip', 'title'); + * ?> + * ``` + * + * + * @param $cssOrXpath + * @param $attribute + * @internal param $element + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabAttributeFrom() + */ + public function grabAttributeFrom($cssOrXpath, $attribute) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * + * @see \Codeception\Lib\InnerBrowser::grabMultiple() + */ + public function grabMultiple($cssOrXpath, $attribute = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabMultiple', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * @param $field + * + * @return array|mixed|null|string + * @see \Codeception\Lib\InnerBrowser::grabValueFrom() + */ + public function grabValueFrom($field) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Sets a cookie with the given name and value. + * You can set additional cookie params like `domain`, `path`, `expire`, `secure` in array passed as last argument. + * + * ``` php + * setCookie('PHPSESSID', 'el4ukv0kqbvoirg7nkp4dncpk3'); + * ?> + * ``` + * + * @param $name + * @param $val + * @param array $params + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::setCookie() + */ + public function setCookie($name, $val, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Grabs a cookie value. + * You can set additional cookie params like `domain`, `path` in array passed as last argument. + * + * @param $cookie + * + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabCookie() + */ + public function grabCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that a cookie with the given name is set. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. + * + * ``` php + * seeCookie('PHPSESSID'); + * ?> + * ``` + * + * @param $cookie + * @param array $params + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCookie() + */ + public function canSeeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that a cookie with the given name is set. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. + * + * ``` php + * seeCookie('PHPSESSID'); + * ?> + * ``` + * + * @param $cookie + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeCookie() + */ + public function seeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there isn't a cookie with the given name. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. + * + * @param $cookie + * + * @param array $params + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() + */ + public function cantSeeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there isn't a cookie with the given name. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. + * + * @param $cookie + * + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() + */ + public function dontSeeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Unsets cookie with the given name. + * You can set additional cookie params like `domain`, `path` in array passed as last argument. + * + * @param $cookie + * + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::resetCookie() + */ + public function resetCookie($name, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given element exists on the page and is visible. + * You can also specify expected attributes of this element. + * + * ``` php + * seeElement('.error'); + * $I->seeElement('//form/input[1]'); + * $I->seeElement('input', ['name' => 'login']); + * $I->seeElement('input', ['value' => '123456']); + * + * // strict locator in first arg, attributes in second + * $I->seeElement(['css' => 'form input'], ['name' => 'login']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * @return + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeElement() + */ + public function canSeeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given element exists on the page and is visible. + * You can also specify expected attributes of this element. + * + * ``` php + * seeElement('.error'); + * $I->seeElement('//form/input[1]'); + * $I->seeElement('input', ['name' => 'login']); + * $I->seeElement('input', ['value' => '123456']); + * + * // strict locator in first arg, attributes in second + * $I->seeElement(['css' => 'form input'], ['name' => 'login']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * @return + * @see \Codeception\Lib\InnerBrowser::seeElement() + */ + public function seeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given element is invisible or not present on the page. + * You can also specify expected attributes of this element. + * + * ``` php + * dontSeeElement('.error'); + * $I->dontSeeElement('//form/input[1]'); + * $I->dontSeeElement('input', ['name' => 'login']); + * $I->dontSeeElement('input', ['value' => '123456']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeElement() + */ + public function cantSeeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given element is invisible or not present on the page. + * You can also specify expected attributes of this element. + * + * ``` php + * dontSeeElement('.error'); + * $I->dontSeeElement('//form/input[1]'); + * $I->dontSeeElement('input', ['name' => 'login']); + * $I->dontSeeElement('input', ['value' => '123456']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * @see \Codeception\Lib\InnerBrowser::dontSeeElement() + */ + public function dontSeeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there are a certain number of elements matched by the given locator on the page. + * + * ``` php + * seeNumberOfElements('tr', 10); + * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements + * ?> + * ``` + * @param $selector + * @param mixed $expected : + * - string: strict number + * - array: range of numbers [0,10] + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() + */ + public function canSeeNumberOfElements($selector, $expected) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElements', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there are a certain number of elements matched by the given locator on the page. + * + * ``` php + * seeNumberOfElements('tr', 10); + * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements + * ?> + * ``` + * @param $selector + * @param mixed $expected : + * - string: strict number + * - array: range of numbers [0,10] + * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() + */ + public function seeNumberOfElements($selector, $expected) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberOfElements', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given option is selected. + * + * ``` php + * seeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() + */ + public function canSeeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given option is selected. + * + * ``` php + * seeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() + */ + public function seeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given option is not selected. + * + * ``` php + * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() + */ + public function cantSeeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given option is not selected. + * + * ``` php + * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() + */ + public function dontSeeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Asserts that current page has 404 response status code. + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seePageNotFound() + */ + public function canSeePageNotFound() { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seePageNotFound', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Asserts that current page has 404 response status code. + * @see \Codeception\Lib\InnerBrowser::seePageNotFound() + */ + public function seePageNotFound() { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seePageNotFound', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that response code is equal to value provided. + * + * @param $code + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() + */ + public function canSeeResponseCodeIs($code) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIs', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that response code is equal to value provided. + * + * @param $code + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() + */ + public function seeResponseCodeIs($code) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResponseCodeIs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title contains the given string. + * + * ``` php + * seeInTitle('Blog - Post #1'); + * ?> + * ``` + * + * @param $title + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInTitle() + */ + public function canSeeInTitle($title) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title contains the given string. + * + * ``` php + * seeInTitle('Blog - Post #1'); + * ?> + * ``` + * + * @param $title + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeInTitle() + */ + public function seeInTitle($title) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title does not contain the given string. + * + * @param $title + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() + */ + public function cantSeeInTitle($title) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title does not contain the given string. + * + * @param $title + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() + */ + public function dontSeeInTitle($title) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args())); + } +} diff --git a/tests/_support/_generated/FunctionalTesterActions.php b/tests/_support/_generated/FunctionalTesterActions.php new file mode 100644 index 0000000000..0d6c61fe91 --- /dev/null +++ b/tests/_support/_generated/FunctionalTesterActions.php @@ -0,0 +1,18 @@ +getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that two variables are not equal + * + * @param $expected + * @param $actual + * @param string $message + * @see \Codeception\Module\Asserts::assertNotEquals() + */ + public function assertNotEquals($expected, $actual, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that two variables are same + * + * @param $expected + * @param $actual + * @param string $message + * + * @return mixed + * @see \Codeception\Module\Asserts::assertSame() + */ + public function assertSame($expected, $actual, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertSame', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that two variables are not same + * + * @param $expected + * @param $actual + * @param string $message + * @see \Codeception\Module\Asserts::assertNotSame() + */ + public function assertNotSame($expected, $actual, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotSame', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that actual is greater than expected + * + * @param $expected + * @param $actual + * @param string $message + * @see \Codeception\Module\Asserts::assertGreaterThan() + */ + public function assertGreaterThan($expected, $actual, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThan', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * @deprecated + * @see \Codeception\Module\Asserts::assertGreaterThen() + */ + public function assertGreaterThen($expected, $actual, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThen', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that actual is greater or equal than expected + * + * @param $expected + * @param $actual + * @param string $message + * @see \Codeception\Module\Asserts::assertGreaterThanOrEqual() + */ + public function assertGreaterThanOrEqual($expected, $actual, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThanOrEqual', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * @deprecated + * @see \Codeception\Module\Asserts::assertGreaterThenOrEqual() + */ + public function assertGreaterThenOrEqual($expected, $actual, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThenOrEqual', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that actual is less than expected + * + * @param $expected + * @param $actual + * @param string $message + * @see \Codeception\Module\Asserts::assertLessThan() + */ + public function assertLessThan($expected, $actual, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThan', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that actual is less or equal than expected + * + * @param $expected + * @param $actual + * @param string $message + * @see \Codeception\Module\Asserts::assertLessThanOrEqual() + */ + public function assertLessThanOrEqual($expected, $actual, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThanOrEqual', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that haystack contains needle + * + * @param $needle + * @param $haystack + * @param string $message + * @see \Codeception\Module\Asserts::assertContains() + */ + public function assertContains($needle, $haystack, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContains', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that haystack doesn't contain needle. + * + * @param $needle + * @param $haystack + * @param string $message + * @see \Codeception\Module\Asserts::assertNotContains() + */ + public function assertNotContains($needle, $haystack, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContains', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that string match with pattern + * + * @param string $pattern + * @param string $string + * @param string $message + * @see \Codeception\Module\Asserts::assertRegExp() + */ + public function assertRegExp($pattern, $string, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertRegExp', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that string not match with pattern + * + * @param string $pattern + * @param string $string + * @param string $message + * @see \Codeception\Module\Asserts::assertNotRegExp() + */ + public function assertNotRegExp($pattern, $string, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotRegExp', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that variable is empty. + * + * @param $actual + * @param string $message + * @see \Codeception\Module\Asserts::assertEmpty() + */ + public function assertEmpty($actual, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEmpty', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that variable is not empty. + * + * @param $actual + * @param string $message + * @see \Codeception\Module\Asserts::assertNotEmpty() + */ + public function assertNotEmpty($actual, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEmpty', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that variable is NULL + * + * @param $actual + * @param string $message + * @see \Codeception\Module\Asserts::assertNull() + */ + public function assertNull($actual, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNull', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that variable is not NULL + * + * @param $actual + * @param string $message + * @see \Codeception\Module\Asserts::assertNotNull() + */ + public function assertNotNull($actual, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotNull', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that condition is positive. + * + * @param $condition + * @param string $message + * @see \Codeception\Module\Asserts::assertTrue() + */ + public function assertTrue($condition, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertTrue', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that condition is negative. + * + * @param $condition + * @param string $message + * @see \Codeception\Module\Asserts::assertFalse() + */ + public function assertFalse($condition, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFalse', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if file exists + * + * @param string $filename + * @param string $message + * @see \Codeception\Module\Asserts::assertFileExists() + */ + public function assertFileExists($filename, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileExists', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if file doesn't exists + * + * @param string $filename + * @param string $message + * @see \Codeception\Module\Asserts::assertFileNotExists() + */ + public function assertFileNotExists($filename, $message = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotExists', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Fails the test with message. + * + * @param $message + * @see \Codeception\Module\Asserts::fail() + */ + public function fail($message) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('fail', func_get_args())); + } +} diff --git a/tests/acceptance.suite.yml b/tests/acceptance.suite.yml new file mode 100644 index 0000000000..2269e0c298 --- /dev/null +++ b/tests/acceptance.suite.yml @@ -0,0 +1,12 @@ +# Codeception Test Suite Configuration +# +# Suite for acceptance tests. +# Perform tests in browser using the WebDriver or PhpBrowser. +# If you need both WebDriver and PHPBrowser tests - create a separate suite. + +class_name: AcceptanceTester +modules: + enabled: + - PhpBrowser: + url: http://localhost/myapp + - \Helper\Acceptance \ No newline at end of file diff --git a/tests/acceptance/_bootstrap.php b/tests/acceptance/_bootstrap.php new file mode 100644 index 0000000000..8a88555806 --- /dev/null +++ b/tests/acceptance/_bootstrap.php @@ -0,0 +1,2 @@ + Date: Fri, 3 Jul 2015 08:16:14 +0200 Subject: [PATCH 04/60] Remove database setup from single test. --- tests/TestCase.php | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 8b972b79d0..dc5d0dda48 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -32,41 +32,6 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase public function setUp() { parent::setUp(); - - // if the database copy does not exist, call migrate. - $copy = __DIR__ . '/../storage/database/testing-copy.db'; - $original = __DIR__ . '/../storage/database/testing.db'; - - FactoryMuffin::loadFactories(__DIR__ . '/factories'); - - if (!file_exists($copy)) { - touch($original); - Artisan::call('migrate'); - - - // create EUR currency - /** @var TransactionCurrency $currency */ - $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); - $currency->code = 'EUR'; - $currency->save(); - copy($original, $copy); - } else { - - if (file_exists($copy)) { - copy($copy, $original); - } - } - // if the database copy does exists, copy back as original. - - $this->session( - [ - 'start' => Carbon::now()->startOfMonth(), - 'end' => Carbon::now()->endOfMonth(), - 'first' => Carbon::now()->startOfYear() - ] - ); - - } /** @@ -86,11 +51,6 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase public function tearDown() { parent::tearDown(); - - // delete copy original. - //$original = __DIR__.'/../storage/database/testing.db'; - //unlink($original); - } /** From ad6700c1145e61fa6b42dd7b6a4beecea7a522c9 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 10:28:40 +0200 Subject: [PATCH 05/60] An example test. Will continue later. --- .../_support/_generated/UnitTesterActions.php | 2405 ++++++++++++++++- tests/unit.suite.yml | 1 + tests/unit/ExampleTest.php | 20 + 3 files changed, 2425 insertions(+), 1 deletion(-) create mode 100644 tests/unit/ExampleTest.php diff --git a/tests/_support/_generated/UnitTesterActions.php b/tests/_support/_generated/UnitTesterActions.php index e7bd502159..32aa10351e 100644 --- a/tests/_support/_generated/UnitTesterActions.php +++ b/tests/_support/_generated/UnitTesterActions.php @@ -1,10 +1,11 @@ -getScenario()->runStep(new \Codeception\Step\Action('getApplication', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Opens web page using route name and parameters. + * + * ``` php + * amOnRoute('posts.create'); + * ?> + * ``` + * + * @param $routeName + * @param array $params + * @see \Codeception\Module\Laravel5::amOnRoute() + */ + public function amOnRoute($routeName, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnRoute', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Opens web page by action name + * + * ``` php + * amOnAction('PostsController@index'); + * ?> + * ``` + * + * @param $action + * @param array $params + * @see \Codeception\Module\Laravel5::amOnAction() + */ + public function amOnAction($action, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnAction', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url matches route + * + * ``` php + * seeCurrentRouteIs('posts.index'); + * ?> + * ``` + * @param $route + * @param array $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel5::seeCurrentRouteIs() + */ + public function canSeeCurrentRouteIs($route, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentRouteIs', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url matches route + * + * ``` php + * seeCurrentRouteIs('posts.index'); + * ?> + * ``` + * @param $route + * @param array $params + * @see \Codeception\Module\Laravel5::seeCurrentRouteIs() + */ + public function seeCurrentRouteIs($route, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentRouteIs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url matches action + * + * ``` php + * seeCurrentActionIs('PostsController@index'); + * ?> + * ``` + * + * @param $action + * @param array $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel5::seeCurrentActionIs() + */ + public function canSeeCurrentActionIs($action, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentActionIs', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url matches action + * + * ``` php + * seeCurrentActionIs('PostsController@index'); + * ?> + * ``` + * + * @param $action + * @param array $params + * @see \Codeception\Module\Laravel5::seeCurrentActionIs() + */ + public function seeCurrentActionIs($action, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentActionIs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that a session variable exists. + * + * ``` php + * seeInSession('key'); + * $I->seeInSession('key', 'value'); + * ?> + * ``` + * + * @param string|array $key + * @param mixed $value + * @return void + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel5::seeInSession() + */ + public function canSeeInSession($key, $value = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInSession', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that a session variable exists. + * + * ``` php + * seeInSession('key'); + * $I->seeInSession('key', 'value'); + * ?> + * ``` + * + * @param string|array $key + * @param mixed $value + * @return void + * @see \Codeception\Module\Laravel5::seeInSession() + */ + public function seeInSession($key, $value = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInSession', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has a given list of values. + * + * ``` php + * seeSessionHasValues(['key1', 'key2']); + * $I->seeSessionHasValues(['key1' => 'value1', 'key2' => 'value2']); + * ?> + * ``` + * + * @param array $bindings + * @return void + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel5::seeSessionHasValues() + */ + public function canSeeSessionHasValues($bindings) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeSessionHasValues', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that the session has a given list of values. + * + * ``` php + * seeSessionHasValues(['key1', 'key2']); + * $I->seeSessionHasValues(['key1' => 'value1', 'key2' => 'value2']); + * ?> + * ``` + * + * @param array $bindings + * @return void + * @see \Codeception\Module\Laravel5::seeSessionHasValues() + */ + public function seeSessionHasValues($bindings) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeSessionHasValues', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that form errors are bound to the View. + * + * ``` php + * seeFormHasErrors(); + * ?> + * ``` + * + * @return bool + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel5::seeFormHasErrors() + */ + public function canSeeFormHasErrors() { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeFormHasErrors', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that form errors are bound to the View. + * + * ``` php + * seeFormHasErrors(); + * ?> + * ``` + * + * @return bool + * @see \Codeception\Module\Laravel5::seeFormHasErrors() + */ + public function seeFormHasErrors() { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeFormHasErrors', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that specific form error messages are set in the view. + * + * Useful for validation messages e.g. + * return `Redirect::to('register')->withErrors($validator);` + * + * Example of Usage + * + * ``` php + * seeFormErrorMessages(array('username'=>'Invalid Username')); + * ?> + * ``` + * @param array $bindings + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel5::seeFormErrorMessages() + */ + public function canSeeFormErrorMessages($bindings) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeFormErrorMessages', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that specific form error messages are set in the view. + * + * Useful for validation messages e.g. + * return `Redirect::to('register')->withErrors($validator);` + * + * Example of Usage + * + * ``` php + * seeFormErrorMessages(array('username'=>'Invalid Username')); + * ?> + * ``` + * @param array $bindings + * @see \Codeception\Module\Laravel5::seeFormErrorMessages() + */ + public function seeFormErrorMessages($bindings) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeFormErrorMessages', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that specific form error message is set in the view. + * + * Useful for validation messages and generally messages array + * e.g. + * return `Redirect::to('register')->withErrors($validator);` + * + * Example of Usage + * + * ``` php + * seeFormErrorMessage('username', 'Invalid Username'); + * ?> + * ``` + * @param string $key + * @param string $errorMessage + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel5::seeFormErrorMessage() + */ + public function canSeeFormErrorMessage($key, $errorMessage) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeFormErrorMessage', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Assert that specific form error message is set in the view. + * + * Useful for validation messages and generally messages array + * e.g. + * return `Redirect::to('register')->withErrors($validator);` + * + * Example of Usage + * + * ``` php + * seeFormErrorMessage('username', 'Invalid Username'); + * ?> + * ``` + * @param string $key + * @param string $errorMessage + * @see \Codeception\Module\Laravel5::seeFormErrorMessage() + */ + public function seeFormErrorMessage($key, $errorMessage) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeFormErrorMessage', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Set the currently logged in user for the application. + * Takes either an object that implements the User interface or + * an array of credentials. + * + * @param \Illuminate\Contracts\Auth\User|array $user + * @param string $driver + * @return void + * @see \Codeception\Module\Laravel5::amLoggedAs() + */ + public function amLoggedAs($user, $driver = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amLoggedAs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Logs user out + * @see \Codeception\Module\Laravel5::logout() + */ + public function logout() { + return $this->getScenario()->runStep(new \Codeception\Step\Action('logout', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that user is authenticated + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel5::seeAuthentication() + */ + public function canSeeAuthentication() { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeAuthentication', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that user is authenticated + * @see \Codeception\Module\Laravel5::seeAuthentication() + */ + public function seeAuthentication() { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeAuthentication', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that user is not authenticated + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel5::dontSeeAuthentication() + */ + public function cantSeeAuthentication() { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeAuthentication', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that user is not authenticated + * @see \Codeception\Module\Laravel5::dontSeeAuthentication() + */ + public function dontSeeAuthentication() { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeAuthentication', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Return an instance of a class from the IoC Container. + * (http://laravel.com/docs/ioc) + * + * Example + * ``` php + * grabService('foo'); + * + * // Will return an instance of FooBar, also works for singletons. + * ?> + * ``` + * + * @param string $class + * @return mixed + * @see \Codeception\Module\Laravel5::grabService() + */ + public function grabService($class) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabService', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Inserts record into the database. + * + * ``` php + * haveRecord('users', array('name' => 'Davert')); + * ?> + * ``` + * + * @param $tableName + * @param array $attributes + * @return mixed + * @part orm + * @see \Codeception\Module\Laravel5::haveRecord() + */ + public function haveRecord($tableName, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('haveRecord', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that record exists in database. + * + * ``` php + * seeRecord('users', array('name' => 'davert')); + * ?> + * ``` + * + * @param $tableName + * @param array $attributes + * @part orm + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel5::seeRecord() + */ + public function canSeeRecord($tableName, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeRecord', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that record exists in database. + * + * ``` php + * seeRecord('users', array('name' => 'davert')); + * ?> + * ``` + * + * @param $tableName + * @param array $attributes + * @part orm + * @see \Codeception\Module\Laravel5::seeRecord() + */ + public function seeRecord($tableName, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeRecord', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that record does not exist in database. + * + * ``` php + * dontSeeRecord('users', array('name' => 'davert')); + * ?> + * ``` + * + * @param $tableName + * @param array $attributes + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Laravel5::dontSeeRecord() + */ + public function cantSeeRecord($tableName, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeRecord', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that record does not exist in database. + * + * ``` php + * dontSeeRecord('users', array('name' => 'davert')); + * ?> + * ``` + * + * @param $tableName + * @param array $attributes + * @see \Codeception\Module\Laravel5::dontSeeRecord() + */ + public function dontSeeRecord($tableName, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeRecord', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Retrieves record from database + * + * ``` php + * grabRecord('users', array('name' => 'davert')); + * ?> + * ``` + * + * @param $tableName + * @param array $attributes + * @return mixed + * @part orm + * @see \Codeception\Module\Laravel5::grabRecord() + */ + public function grabRecord($tableName, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabRecord', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Authenticates user for HTTP_AUTH + * + * @param $username + * @param $password + * @see \Codeception\Lib\InnerBrowser::amHttpAuthenticated() + */ + public function amHttpAuthenticated($username, $password) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Opens the page for the given relative URI. + * + * ``` php + * amOnPage('/'); + * // opens /register page + * $I->amOnPage('/register'); + * ?> + * ``` + * + * @param $page + * @see \Codeception\Lib\InnerBrowser::amOnPage() + */ + public function amOnPage($page) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Perform a click on a link or a button, given by a locator. + * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. + * For buttons, the "value" attribute, "name" attribute, and inner text are searched. + * For links, the link text is searched. + * For images, the "alt" attribute and inner text of any parent links are searched. + * + * The second parameter is a context (CSS or XPath locator) to narrow the search. + * + * Note that if the locator matches a button of type `submit`, the form will be submitted. + * + * ``` php + * click('Logout'); + * // button of form + * $I->click('Submit'); + * // CSS button + * $I->click('#form input[type=submit]'); + * // XPath + * $I->click('//form/*[@type=submit]'); + * // link in context + * $I->click('Logout', '#nav'); + * // using strict locator + * $I->click(['link' => 'Login']); + * ?> + * ``` + * + * @param $link + * @param $context + * @see \Codeception\Lib\InnerBrowser::click() + */ + public function click($link, $context = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('click', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string. + * Specify a locator as the second parameter to match a specific region. + * + * ``` php + * see('Logout'); // I can suppose user is logged in + * $I->see('Sign Up','h1'); // I can suppose it's a signup page + * $I->see('Sign Up','//body/h1'); // with XPath + * ?> + * ``` + * + * @param $text + * @param null $selector + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::see() + */ + public function canSee($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string. + * Specify a locator as the second parameter to match a specific region. + * + * ``` php + * see('Logout'); // I can suppose user is logged in + * $I->see('Sign Up','h1'); // I can suppose it's a signup page + * $I->see('Sign Up','//body/h1'); // with XPath + * ?> + * ``` + * + * @param $text + * @param null $selector + * @see \Codeception\Lib\InnerBrowser::see() + */ + public function see($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('see', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page doesn't contain the text specified. + * Give a locator as the second parameter to match a specific region. + * + * ```php + * dontSee('Login'); // I can suppose user is already logged in + * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page + * $I->dontSee('Sign Up','//body/h1'); // with XPath + * ?> + * ``` + * + * @param $text + * @param null $selector + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSee() + */ + public function cantSee($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page doesn't contain the text specified. + * Give a locator as the second parameter to match a specific region. + * + * ```php + * dontSee('Login'); // I can suppose user is already logged in + * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page + * $I->dontSee('Sign Up','//body/h1'); // with XPath + * ?> + * ``` + * + * @param $text + * @param null $selector + * @see \Codeception\Lib\InnerBrowser::dontSee() + */ + public function dontSee($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there's a link with the specified text. + * Give a full URL as the second parameter to match links with that exact URL. + * + * ``` php + * seeLink('Logout'); // matches Logout + * $I->seeLink('Logout','/logout'); // matches Logout + * ?> + * ``` + * + * @param $text + * @param null $url + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeLink() + */ + public function canSeeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there's a link with the specified text. + * Give a full URL as the second parameter to match links with that exact URL. + * + * ``` php + * seeLink('Logout'); // matches Logout + * $I->seeLink('Logout','/logout'); // matches Logout + * ?> + * ``` + * + * @param $text + * @param null $url + * @see \Codeception\Lib\InnerBrowser::seeLink() + */ + public function seeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page doesn't contain a link with the given string. + * If the second parameter is given, only links with a matching "href" attribute will be checked. + * + * ``` php + * dontSeeLink('Logout'); // I suppose user is not logged in + * $I->dontSeeLink('Checkout now', '/store/cart.php'); + * ?> + * ``` + * + * @param $text + * @param null $url + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeLink() + */ + public function cantSeeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page doesn't contain a link with the given string. + * If the second parameter is given, only links with a matching "href" attribute will be checked. + * + * ``` php + * dontSeeLink('Logout'); // I suppose user is not logged in + * $I->dontSeeLink('Checkout now', '/store/cart.php'); + * ?> + * ``` + * + * @param $text + * @param null $url + * @see \Codeception\Lib\InnerBrowser::dontSeeLink() + */ + public function dontSeeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current URI contains the given string. + * + * ``` php + * seeInCurrentUrl('home'); + * // to match: /users/1 + * $I->seeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() + */ + public function canSeeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current URI contains the given string. + * + * ``` php + * seeInCurrentUrl('home'); + * // to match: /users/1 + * $I->seeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() + */ + public function seeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URI doesn't contain the given string. + * + * ``` php + * dontSeeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() + */ + public function cantSeeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URI doesn't contain the given string. + * + * ``` php + * dontSeeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() + */ + public function dontSeeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL is equal to the given string. + * Unlike `seeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * seeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() + */ + public function canSeeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL is equal to the given string. + * Unlike `seeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * seeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() + */ + public function seeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL doesn't equal the given string. + * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * dontSeeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() + */ + public function cantSeeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL doesn't equal the given string. + * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * dontSeeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() + */ + public function dontSeeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL matches the given regular expression. + * + * ``` php + * seeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() + */ + public function canSeeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL matches the given regular expression. + * + * ``` php + * seeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() + */ + public function seeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url doesn't match the given regular expression. + * + * ``` php + * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() + */ + public function cantSeeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url doesn't match the given regular expression. + * + * ``` php + * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() + */ + public function dontSeeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Executes the given regular expression against the current URI and returns the first match. + * If no parameters are provided, the full URI is returned. + * + * ``` php + * grabFromCurrentUrl('~$/user/(\d+)/~'); + * $uri = $I->grabFromCurrentUrl(); + * ?> + * ``` + * + * @param null $uri + * + * @internal param $url + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl() + */ + public function grabFromCurrentUrl($uri = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the specified checkbox is checked. + * + * ``` php + * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. + * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); + * ?> + * ``` + * + * @param $checkbox + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() + */ + public function canSeeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the specified checkbox is checked. + * + * ``` php + * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. + * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); + * ?> + * ``` + * + * @param $checkbox + * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() + */ + public function seeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that the specified checkbox is unchecked. + * + * ``` php + * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. + * ?> + * ``` + * + * @param $checkbox + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() + */ + public function cantSeeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that the specified checkbox is unchecked. + * + * ``` php + * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. + * ?> + * ``` + * + * @param $checkbox + * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() + */ + public function dontSeeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given input field or textarea contains the given value. + * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. + * + * ``` php + * seeInField('Body','Type your comment here'); + * $I->seeInField('form textarea[name=body]','Type your comment here'); + * $I->seeInField('form input[type=hidden]','hidden_value'); + * $I->seeInField('#searchform input','Search'); + * $I->seeInField('//form/*[@name=search]','Search'); + * $I->seeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInField() + */ + public function canSeeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given input field or textarea contains the given value. + * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. + * + * ``` php + * seeInField('Body','Type your comment here'); + * $I->seeInField('form textarea[name=body]','Type your comment here'); + * $I->seeInField('form input[type=hidden]','hidden_value'); + * $I->seeInField('#searchform input','Search'); + * $I->seeInField('//form/*[@name=search]','Search'); + * $I->seeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Lib\InnerBrowser::seeInField() + */ + public function seeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that an input field or textarea doesn't contain the given value. + * For fuzzy locators, the field is matched by label text, CSS and XPath. + * + * ``` php + * dontSeeInField('Body','Type your comment here'); + * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); + * $I->dontSeeInField('form input[type=hidden]','hidden_value'); + * $I->dontSeeInField('#searchform input','Search'); + * $I->dontSeeInField('//form/*[@name=search]','Search'); + * $I->dontSeeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInField() + */ + public function cantSeeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that an input field or textarea doesn't contain the given value. + * For fuzzy locators, the field is matched by label text, CSS and XPath. + * + * ``` php + * dontSeeInField('Body','Type your comment here'); + * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); + * $I->dontSeeInField('form input[type=hidden]','hidden_value'); + * $I->dontSeeInField('#searchform input','Search'); + * $I->dontSeeInField('//form/*[@name=search]','Search'); + * $I->dontSeeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Lib\InnerBrowser::dontSeeInField() + */ + public function dontSeeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are set on the form matched with the + * passed selector. + * + * ``` php + * seeInFormFields('form[name=myform]', [ + * 'input1' => 'value', + * 'input2' => 'other value', + * ]); + * ?> + * ``` + * + * For multi-select elements, or to check values of multiple elements with the same name, an + * array may be passed: + * + * ``` php + * seeInFormFields('.form-class', [ + * 'multiselect' => [ + * 'value1', + * 'value2', + * ], + * 'checkbox[]' => [ + * 'a checked value', + * 'another checked value', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * seeInFormFields('#form-id', [ + * 'checkbox1' => true, // passes if checked + * 'checkbox2' => false, // passes if unchecked + * ]); + * ?> + * ``` + * + * Pair this with submitForm for quick testing magic. + * + * ``` php + * 'value', + * 'field2' => 'another value', + * 'checkbox1' => true, + * // ... + * ]; + * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); + * // $I->amOnPage('/path/to/form-page') may be needed + * $I->seeInFormFields('//form[@id=my-form]', $form); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInFormFields() + */ + public function canSeeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInFormFields', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are set on the form matched with the + * passed selector. + * + * ``` php + * seeInFormFields('form[name=myform]', [ + * 'input1' => 'value', + * 'input2' => 'other value', + * ]); + * ?> + * ``` + * + * For multi-select elements, or to check values of multiple elements with the same name, an + * array may be passed: + * + * ``` php + * seeInFormFields('.form-class', [ + * 'multiselect' => [ + * 'value1', + * 'value2', + * ], + * 'checkbox[]' => [ + * 'a checked value', + * 'another checked value', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * seeInFormFields('#form-id', [ + * 'checkbox1' => true, // passes if checked + * 'checkbox2' => false, // passes if unchecked + * ]); + * ?> + * ``` + * + * Pair this with submitForm for quick testing magic. + * + * ``` php + * 'value', + * 'field2' => 'another value', + * 'checkbox1' => true, + * // ... + * ]; + * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); + * // $I->amOnPage('/path/to/form-page') may be needed + * $I->seeInFormFields('//form[@id=my-form]', $form); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * @see \Codeception\Lib\InnerBrowser::seeInFormFields() + */ + public function seeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInFormFields', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are not set on the form matched with + * the passed selector. + * + * ``` php + * dontSeeInFormFields('form[name=myform]', [ + * 'input1' => 'non-existent value', + * 'input2' => 'other non-existent value', + * ]); + * ?> + * ``` + * + * To check that an element hasn't been assigned any one of many values, an array can be passed + * as the value: + * + * ``` php + * dontSeeInFormFields('.form-class', [ + * 'fieldName' => [ + * 'This value shouldn\'t be set', + * 'And this value shouldn\'t be set', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * dontSeeInFormFields('#form-id', [ + * 'checkbox1' => true, // fails if checked + * 'checkbox2' => false, // fails if unchecked + * ]); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() + */ + public function cantSeeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInFormFields', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are not set on the form matched with + * the passed selector. + * + * ``` php + * dontSeeInFormFields('form[name=myform]', [ + * 'input1' => 'non-existent value', + * 'input2' => 'other non-existent value', + * ]); + * ?> + * ``` + * + * To check that an element hasn't been assigned any one of many values, an array can be passed + * as the value: + * + * ``` php + * dontSeeInFormFields('.form-class', [ + * 'fieldName' => [ + * 'This value shouldn\'t be set', + * 'And this value shouldn\'t be set', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * dontSeeInFormFields('#form-id', [ + * 'checkbox1' => true, // fails if checked + * 'checkbox2' => false, // fails if unchecked + * ]); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() + */ + public function dontSeeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInFormFields', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Submits the given form on the page, optionally with the given form + * values. Give the form fields values as an array. + * + * Skipped fields will be filled by their values from the page. + * You don't need to click the 'Submit' button afterwards. + * This command itself triggers the request to form's action. + * + * You can optionally specify what button's value to include + * in the request with the last parameter as an alternative to + * explicitly setting its value in the second parameter, as + * button values are not otherwise included in the request. + * + * Examples: + * + * ``` php + * submitForm('#login', [ + * 'login' => 'davert', + * 'password' => '123456' + * ]); + * // or + * $I->submitForm('#login', [ + * 'login' => 'davert', + * 'password' => '123456' + * ], 'submitButtonName'); + * + * ``` + * + * For example, given this sample "Sign Up" form: + * + * ``` html + *
+ * Login: + *
+ * Password: + *
+ * Do you agree to out terms? + *
+ * Select pricing plan: + * + * + *
+ * ``` + * + * You could write the following to submit it: + * + * ``` php + * submitForm( + * '#userForm', + * [ + * 'user' => [ + * 'login' => 'Davert', + * 'password' => '123456', + * 'agree' => true + * ] + * ], + * 'submitButton' + * ); + * ``` + * Note that "2" will be the submitted value for the "plan" field, as it is + * the selected option. + * + * You can also emulate a JavaScript submission by not specifying any + * buttons in the third parameter to submitForm. + * + * ```php + * submitForm( + * '#userForm', + * [ + * 'user' => [ + * 'login' => 'Davert', + * 'password' => '123456', + * 'agree' => true + * ] + * ] + * ); + * ``` + * + * Pair this with seeInFormFields for quick testing magic. + * + * ``` php + * 'value', + * 'field2' => 'another value', + * 'checkbox1' => true, + * // ... + * ]; + * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); + * // $I->amOnPage('/path/to/form-page') may be needed + * $I->seeInFormFields('//form[@id=my-form]', $form); + * ?> + * ``` + * + * Parameter values can be set to arrays for multiple input fields + * of the same name, or multi-select combo boxes. For checkboxes, + * either the string value can be used, or boolean values which will + * be replaced by the checkbox's value in the DOM. + * + * ``` php + * submitForm('#my-form', [ + * 'field1' => 'value', + * 'checkbox' => [ + * 'value of first checkbox', + * 'value of second checkbox, + * ], + * 'otherCheckboxes' => [ + * true, + * false, + * false + * ], + * 'multiselect' => [ + * 'first option value', + * 'second option value' + * ] + * ]); + * ?> + * ``` + * + * Mixing string and boolean values for a checkbox's value is not supported + * and may produce unexpected results. + * + * Field names ending in "[]" must be passed without the trailing square + * bracket characters, and must contain an array for its value. This allows + * submitting multiple values with the same name, consider: + * + * ```php + * $I->submitForm('#my-form', [ + * 'field[]' => 'value', + * 'field[]' => 'another value', // 'field[]' is already a defined key + * ]); + * ``` + * + * The solution is to pass an array value: + * + * ```php + * // this way both values are submitted + * $I->submitForm('#my-form', [ + * 'field' => [ + * 'value', + * 'another value', + * ] + * ]); + * ``` + * + * @param $selector + * @param $params + * @param $button + * @see \Codeception\Lib\InnerBrowser::submitForm() + */ + public function submitForm($selector, $params, $button = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('submitForm', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Fills a text field or textarea with the given string. + * + * ``` php + * fillField("//input[@type='text']", "Hello World!"); + * $I->fillField(['name' => 'email'], 'jon@mail.com'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Lib\InnerBrowser::fillField() + */ + public function fillField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('fillField', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Selects an option in a select tag or in radio button group. + * + * ``` php + * selectOption('form select[name=account]', 'Premium'); + * $I->selectOption('form input[name=payment]', 'Monthly'); + * $I->selectOption('//form/select[@name=account]', 'Monthly'); + * ?> + * ``` + * + * Provide an array for the second argument to select multiple options: + * + * ``` php + * selectOption('Which OS do you use?', array('Windows','Linux')); + * ?> + * ``` + * + * @param $select + * @param $option + * @see \Codeception\Lib\InnerBrowser::selectOption() + */ + public function selectOption($select, $option) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('selectOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Ticks a checkbox. For radio buttons, use the `selectOption` method instead. + * + * ``` php + * checkOption('#agree'); + * ?> + * ``` + * + * @param $option + * @see \Codeception\Lib\InnerBrowser::checkOption() + */ + public function checkOption($option) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('checkOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Unticks a checkbox. + * + * ``` php + * uncheckOption('#notify'); + * ?> + * ``` + * + * @param $option + * @see \Codeception\Lib\InnerBrowser::uncheckOption() + */ + public function uncheckOption($option) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Attaches a file relative to the Codeception data directory to the given file upload field. + * + * ``` php + * attachFile('input[@type="file"]', 'prices.xls'); + * ?> + * ``` + * + * @param $field + * @param $filename + * @see \Codeception\Lib\InnerBrowser::attachFile() + */ + public function attachFile($field, $filename) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('attachFile', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * If your page triggers an ajax request, you can perform it manually. + * This action sends a GET ajax request with specified params. + * + * See ->sendAjaxPostRequest for examples. + * + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxGetRequest() + */ + public function sendAjaxGetRequest($uri, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * If your page triggers an ajax request, you can perform it manually. + * This action sends a POST ajax request with specified params. + * Additional params can be passed as array. + * + * Example: + * + * Imagine that by clicking checkbox you trigger ajax request which updates user settings. + * We emulate that click by running this ajax request manually. + * + * ``` php + * sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST + * $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET + * + * ``` + * + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxPostRequest() + */ + public function sendAjaxPostRequest($uri, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * If your page triggers an ajax request, you can perform it manually. + * This action sends an ajax request with specified method and params. + * + * Example: + * + * You need to perform an ajax request specifying the HTTP method. + * + * ``` php + * sendAjaxRequest('PUT', '/posts/7', array('title' => 'new title')); + * + * ``` + * + * @param $method + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxRequest() + */ + public function sendAjaxRequest($method, $uri, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxRequest', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Finds and returns the text contents of the given element. + * If a fuzzy locator is used, the element is found using CSS, XPath, and by matching the full page source by regular expression. + * + * ``` php + * grabTextFrom('h1'); + * $heading = $I->grabTextFrom('descendant-or-self::h1'); + * $value = $I->grabTextFrom('~ + * ``` + * + * @param $cssOrXPathOrRegex + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabTextFrom() + */ + public function grabTextFrom($cssOrXPathOrRegex) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Grabs the value of the given attribute value from the given element. + * Fails if element is not found. + * + * ``` php + * grabAttributeFrom('#tooltip', 'title'); + * ?> + * ``` + * + * + * @param $cssOrXpath + * @param $attribute + * @internal param $element + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabAttributeFrom() + */ + public function grabAttributeFrom($cssOrXpath, $attribute) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * + * @see \Codeception\Lib\InnerBrowser::grabMultiple() + */ + public function grabMultiple($cssOrXpath, $attribute = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabMultiple', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * @param $field + * + * @return array|mixed|null|string + * @see \Codeception\Lib\InnerBrowser::grabValueFrom() + */ + public function grabValueFrom($field) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Sets a cookie with the given name and value. + * You can set additional cookie params like `domain`, `path`, `expire`, `secure` in array passed as last argument. + * + * ``` php + * setCookie('PHPSESSID', 'el4ukv0kqbvoirg7nkp4dncpk3'); + * ?> + * ``` + * + * @param $name + * @param $val + * @param array $params + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::setCookie() + */ + public function setCookie($name, $val, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Grabs a cookie value. + * You can set additional cookie params like `domain`, `path` in array passed as last argument. + * + * @param $cookie + * + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabCookie() + */ + public function grabCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that a cookie with the given name is set. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. + * + * ``` php + * seeCookie('PHPSESSID'); + * ?> + * ``` + * + * @param $cookie + * @param array $params + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCookie() + */ + public function canSeeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that a cookie with the given name is set. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. + * + * ``` php + * seeCookie('PHPSESSID'); + * ?> + * ``` + * + * @param $cookie + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeCookie() + */ + public function seeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there isn't a cookie with the given name. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. + * + * @param $cookie + * + * @param array $params + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() + */ + public function cantSeeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there isn't a cookie with the given name. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. + * + * @param $cookie + * + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() + */ + public function dontSeeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Unsets cookie with the given name. + * You can set additional cookie params like `domain`, `path` in array passed as last argument. + * + * @param $cookie + * + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::resetCookie() + */ + public function resetCookie($name, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given element exists on the page and is visible. + * You can also specify expected attributes of this element. + * + * ``` php + * seeElement('.error'); + * $I->seeElement('//form/input[1]'); + * $I->seeElement('input', ['name' => 'login']); + * $I->seeElement('input', ['value' => '123456']); + * + * // strict locator in first arg, attributes in second + * $I->seeElement(['css' => 'form input'], ['name' => 'login']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * @return + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeElement() + */ + public function canSeeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given element exists on the page and is visible. + * You can also specify expected attributes of this element. + * + * ``` php + * seeElement('.error'); + * $I->seeElement('//form/input[1]'); + * $I->seeElement('input', ['name' => 'login']); + * $I->seeElement('input', ['value' => '123456']); + * + * // strict locator in first arg, attributes in second + * $I->seeElement(['css' => 'form input'], ['name' => 'login']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * @return + * @see \Codeception\Lib\InnerBrowser::seeElement() + */ + public function seeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given element is invisible or not present on the page. + * You can also specify expected attributes of this element. + * + * ``` php + * dontSeeElement('.error'); + * $I->dontSeeElement('//form/input[1]'); + * $I->dontSeeElement('input', ['name' => 'login']); + * $I->dontSeeElement('input', ['value' => '123456']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeElement() + */ + public function cantSeeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given element is invisible or not present on the page. + * You can also specify expected attributes of this element. + * + * ``` php + * dontSeeElement('.error'); + * $I->dontSeeElement('//form/input[1]'); + * $I->dontSeeElement('input', ['name' => 'login']); + * $I->dontSeeElement('input', ['value' => '123456']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * @see \Codeception\Lib\InnerBrowser::dontSeeElement() + */ + public function dontSeeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there are a certain number of elements matched by the given locator on the page. + * + * ``` php + * seeNumberOfElements('tr', 10); + * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements + * ?> + * ``` + * @param $selector + * @param mixed $expected : + * - string: strict number + * - array: range of numbers [0,10] + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() + */ + public function canSeeNumberOfElements($selector, $expected) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElements', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there are a certain number of elements matched by the given locator on the page. + * + * ``` php + * seeNumberOfElements('tr', 10); + * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements + * ?> + * ``` + * @param $selector + * @param mixed $expected : + * - string: strict number + * - array: range of numbers [0,10] + * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() + */ + public function seeNumberOfElements($selector, $expected) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberOfElements', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given option is selected. + * + * ``` php + * seeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() + */ + public function canSeeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given option is selected. + * + * ``` php + * seeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() + */ + public function seeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given option is not selected. + * + * ``` php + * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() + */ + public function cantSeeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given option is not selected. + * + * ``` php + * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() + */ + public function dontSeeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Asserts that current page has 404 response status code. + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seePageNotFound() + */ + public function canSeePageNotFound() { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seePageNotFound', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Asserts that current page has 404 response status code. + * @see \Codeception\Lib\InnerBrowser::seePageNotFound() + */ + public function seePageNotFound() { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seePageNotFound', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that response code is equal to value provided. + * + * @param $code + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() + */ + public function canSeeResponseCodeIs($code) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIs', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that response code is equal to value provided. + * + * @param $code + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() + */ + public function seeResponseCodeIs($code) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResponseCodeIs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title contains the given string. + * + * ``` php + * seeInTitle('Blog - Post #1'); + * ?> + * ``` + * + * @param $title + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInTitle() + */ + public function canSeeInTitle($title) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title contains the given string. + * + * ``` php + * seeInTitle('Blog - Post #1'); + * ?> + * ``` + * + * @param $title + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeInTitle() + */ + public function seeInTitle($title) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title does not contain the given string. + * + * @param $title + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() + */ + public function cantSeeInTitle($title) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title does not contain the given string. + * + * @param $title + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() + */ + public function dontSeeInTitle($title) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args())); + } + + /** * [!] Method is generated. Documentation taken from corresponding module. * diff --git a/tests/unit.suite.yml b/tests/unit.suite.yml index 02dc9b1e0a..bba650c30e 100644 --- a/tests/unit.suite.yml +++ b/tests/unit.suite.yml @@ -5,5 +5,6 @@ class_name: UnitTester modules: enabled: + - Laravel5 - Asserts - \Helper\Unit \ No newline at end of file diff --git a/tests/unit/ExampleTest.php b/tests/unit/ExampleTest.php new file mode 100644 index 0000000000..05b642ccaf --- /dev/null +++ b/tests/unit/ExampleTest.php @@ -0,0 +1,20 @@ + Date: Fri, 3 Jul 2015 10:45:00 +0200 Subject: [PATCH 06/60] Initial commit for CSV import. --- app/Http/Controllers/CsvController.php | 35 +++++++++++++++++++++++ app/Http/routes.php | 6 ++++ resources/lang/en/firefly.php | 3 ++ resources/lang/nl/firefly.php | 3 ++ resources/twig/csv/index.twig | 12 ++++++++ resources/twig/partials/menu-sidebar.twig | 3 ++ 6 files changed, 62 insertions(+) create mode 100644 app/Http/Controllers/CsvController.php create mode 100644 resources/twig/csv/index.twig diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php new file mode 100644 index 0000000000..723b1a33e1 --- /dev/null +++ b/app/Http/Controllers/CsvController.php @@ -0,0 +1,35 @@ + 'CategoryController@update', 'as' => 'categories.update']); Route::post('/categories/destroy/{category}', ['uses' => 'CategoryController@destroy', 'as' => 'categories.destroy']); + + /** + * CSV controller + */ + Route::get('/csv', ['uses' => 'CsvController@index', 'as' => 'csv.index']); + /** * Currency Controller */ diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php index d6feb0f661..f7d834653a 100644 --- a/resources/lang/en/firefly.php +++ b/resources/lang/en/firefly.php @@ -19,6 +19,9 @@ return [ 'never' => 'Never', 'search_results_for' => 'Search results for ":query"', + // csv import: + 'csv_import' => 'Import CSV file', + // create new stuff: 'create_new_withdrawal' => 'Create new withdrawal', 'create_new_deposit' => 'Create new deposit', diff --git a/resources/lang/nl/firefly.php b/resources/lang/nl/firefly.php index bdab21f817..6c03404832 100644 --- a/resources/lang/nl/firefly.php +++ b/resources/lang/nl/firefly.php @@ -19,6 +19,9 @@ return [ 'never' => 'Nooit', 'search_results_for' => 'Zoekresultaten voor ":query"', + // csv import: + 'csv_import' => 'Import CSV file', + // create new stuff: 'create_new_withdrawal' => 'Nieuwe uitgave', 'create_new_deposit' => 'Nieuwe inkomsten', diff --git a/resources/twig/csv/index.twig b/resources/twig/csv/index.twig new file mode 100644 index 0000000000..5dd98e4135 --- /dev/null +++ b/resources/twig/csv/index.twig @@ -0,0 +1,12 @@ +{% extends "./layout/default.twig" %} + +{% block breadcrumbs %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +{% endblock %} + +{% block content %} + + + Bla bla. + +{% endblock %} diff --git a/resources/twig/partials/menu-sidebar.twig b/resources/twig/partials/menu-sidebar.twig index ba080666f2..76bc4f4cfb 100644 --- a/resources/twig/partials/menu-sidebar.twig +++ b/resources/twig/partials/menu-sidebar.twig @@ -123,6 +123,9 @@
  • {{ 'currencies'|_ }}
  • +
  • + {{ 'csv_import'|_ }} +
  • From 16374bce9b19fe1db599d102007fc93d3a7ca064 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 11:52:51 +0200 Subject: [PATCH 07/60] Fixed upload form, made a new form element, added some processing. --- app/Http/Controllers/CsvController.php | 61 +- app/Http/routes.php | 1 + app/Support/ExpandedForm.php | 18 + composer.json | 3 +- composer.lock | 2415 +++++++++++++++++++++++- config/twigbridge.php | 4 +- resources/lang/en/firefly.php | 7 + resources/lang/en/form.php | 2 + resources/lang/nl/firefly.php | 9 +- resources/lang/nl/form.php | 2 + resources/twig/csv/index.twig | 77 +- resources/twig/form/checkbox.twig | 1 + resources/twig/form/file.twig | 9 + storage/upload/.gitignore | 2 + 14 files changed, 2533 insertions(+), 78 deletions(-) create mode 100644 resources/twig/form/file.twig create mode 100644 storage/upload/.gitignore diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 723b1a33e1..3f2504a7a4 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -7,6 +7,12 @@ */ namespace FireflyIII\Http\Controllers; + +use Illuminate\Http\Request; +use Input; +use League\Csv\Reader; +use Redirect; +use Session; use View; /** @@ -23,13 +29,64 @@ class CsvController extends Controller public function __construct() { parent::__construct(); - View::share('title', 'CSV'); + View::share('title', trans('firefly.csv')); View::share('mainTitleIcon', 'fa-file-text-o'); } + /** + * @return View + */ public function index() { - return view('csv.index'); + $subTitle = trans('firefly.csv_import'); + + // can actually upload? + $uploadPossible = !is_writable(storage_path('upload')); + $path = storage_path('upload'); + + + return view('csv.index', compact('subTitle', 'uploadPossible', 'path')); + } + + /** + * + */ + public function upload(Request $request) + { + if (!$request->hasFile('csv')) { + Session::flash('warning', 'No file uploaded.'); + + + return Redirect::route('csv.index'); + } + $hasHeaders = intval(Input::get('has_headers')) === 1; + $reader = Reader::createFromPath($request->file('csv')->getRealPath()); + $data = $reader->query(); + $data->next(); // go to first row: + if ($hasHeaders) { + + // first row = headers. + $headers = $data->current(); + } else { + $count = count($data->current()); + $headers = []; + for ($i = 1; $i <= $count; $i++) { + $headers[] = trans('firefly.csv_row') . ' #' . $i; + } + } + + // example data is always the second row: + $data->next(); + $example = $data->current(); + + var_dump($headers); + var_dump($example); + + // store file somewhere temporary? + + + exit; + } } \ No newline at end of file diff --git a/app/Http/routes.php b/app/Http/routes.php index 0c5d9174ee..e0447eba0c 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -224,6 +224,7 @@ Route::group( * CSV controller */ Route::get('/csv', ['uses' => 'CsvController@index', 'as' => 'csv.index']); + Route::post('/csv/upload', ['uses' => 'CsvController@upload', 'as' => 'csv.upload']); /** * Currency Controller diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index 4bae2bcbbb..62505adac6 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -347,6 +347,24 @@ class ExpandedForm return $html; } + /** + * @param $name + * @param null $value + * @param array $options + * + * @return string + */ + public function file($name, array $options = []) + { + $label = $this->label($name, $options); + $options = $this->expandOptionArray($name, $label, $options); + $classes = $this->getHolderClasses($name); + $html = View::make('form.file', compact('classes', 'name', 'label', 'options'))->render(); + + return $html; + + } + /** * @param $name * @param null $value diff --git a/composer.json b/composer.json index b1134d9cd1..54b352de13 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ "illuminate/html": "~5.0", "league/commonmark": "0.7.*", "rcrowe/twigbridge": "0.7.x@dev", - "zizaco/entrust": "dev-laravel-5" + "zizaco/entrust": "dev-laravel-5", + "league/csv": "^7.1" }, "require-dev": { "barryvdh/laravel-debugbar": "@stable", diff --git a/composer.lock b/composer.lock index dbc3422a9f..87162d93ae 100644 --- a/composer.lock +++ b/composer.lock @@ -4,39 +4,33 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "c1cfabc3da3bdec86d8912a6878e0b0f", + "hash": "9747e35883b8d868d434b5d887963634", "packages": [ { "name": "classpreloader/classpreloader", - "version": "1.4.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/ClassPreloader/ClassPreloader.git", - "reference": "b76f3f4f603ebbe7e64351a7ef973431ddaf7b27" + "reference": "8c3c14b10309e3b40bce833913a6c0c0b8c8f962" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ClassPreloader/ClassPreloader/zipball/b76f3f4f603ebbe7e64351a7ef973431ddaf7b27", - "reference": "b76f3f4f603ebbe7e64351a7ef973431ddaf7b27", + "url": "https://api.github.com/repos/ClassPreloader/ClassPreloader/zipball/8c3c14b10309e3b40bce833913a6c0c0b8c8f962", + "reference": "8c3c14b10309e3b40bce833913a6c0c0b8c8f962", "shasum": "" }, "require": { "nikic/php-parser": "~1.3", - "php": ">=5.3.3", - "symfony/console": "~2.1", - "symfony/filesystem": "~2.1", - "symfony/finder": "~2.1" + "php": ">=5.5.9" }, "require-dev": { "phpunit/phpunit": "~4.0" }, - "bin": [ - "classpreloader.php" - ], "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -55,7 +49,7 @@ }, { "name": "Graham Campbell", - "email": "graham@cachethq.io" + "email": "graham@alt-three.com" } ], "description": "Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case", @@ -64,7 +58,7 @@ "class", "preload" ], - "time": "2015-05-26 10:57:51" + "time": "2015-06-28 21:39:13" }, { "name": "danielstjules/stringy", @@ -902,20 +896,20 @@ }, { "name": "laravel/framework", - "version": "v5.1.3", + "version": "v5.1.5", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "a7ebd043ca178c05cc7946ece03d3a268a5a3f84" + "reference": "25d872ec1945b30083f3e348039c380307b42d5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/a7ebd043ca178c05cc7946ece03d3a268a5a3f84", - "reference": "a7ebd043ca178c05cc7946ece03d3a268a5a3f84", + "url": "https://api.github.com/repos/laravel/framework/zipball/25d872ec1945b30083f3e348039c380307b42d5e", + "reference": "25d872ec1945b30083f3e348039c380307b42d5e", "shasum": "" }, "require": { - "classpreloader/classpreloader": "~1.2", + "classpreloader/classpreloader": "~2.0", "danielstjules/stringy": "~1.8", "doctrine/inflector": "~1.0", "ext-mbstring": "*", @@ -1026,7 +1020,7 @@ "framework", "laravel" ], - "time": "2015-06-24 19:38:07" + "time": "2015-07-02 02:28:22" }, { "name": "league/commonmark", @@ -1087,6 +1081,63 @@ ], "time": "2015-03-08 17:48:53" }, + { + "name": "league/csv", + "version": "7.1.2", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/csv.git", + "reference": "2ee1760c262c41986f6371775907fc9e8603fd26" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/csv/zipball/2ee1760c262c41986f6371775907fc9e8603fd26", + "reference": "2ee1760c262c41986f6371775907fc9e8603fd26", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "scrutinizer/ocular": "~1.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.1-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Csv\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignace Nyamagana Butera", + "email": "nyamsprod@gmail.com", + "homepage": "https://github.com/nyamsprod/", + "role": "Developer" + } + ], + "description": "Csv data manipulation made easy in PHP", + "homepage": "http://csv.thephpleague.com", + "keywords": [ + "csv", + "export", + "filter", + "import", + "read", + "write" + ], + "time": "2015-06-10 11:12:37" + }, { "name": "league/flysystem", "version": "1.0.4", @@ -1890,55 +1941,6 @@ "homepage": "https://symfony.com", "time": "2015-06-08 09:37:21" }, - { - "name": "symfony/filesystem", - "version": "v2.7.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/Filesystem.git", - "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a0d43eb3e17d4f4c6990289805a488a0482a07f3", - "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "https://symfony.com", - "time": "2015-06-08 09:37:21" - }, { "name": "symfony/finder", "version": "v2.7.1", @@ -2587,7 +2589,2278 @@ "time": "2015-05-25 00:17:51" } ], - "packages-dev": null, + "packages-dev": [ + { + "name": "barryvdh/laravel-debugbar", + "version": "v2.0.4", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "3edaea0e8056edde00f7d0af13ed0d406412182d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/3edaea0e8056edde00f7d0af13ed0d406412182d", + "reference": "3edaea0e8056edde00f7d0af13ed0d406412182d", + "shasum": "" + }, + "require": { + "illuminate/support": "~5.0.17|5.1.*", + "maximebf/debugbar": "~1.10.2", + "php": ">=5.4.0", + "symfony/finder": "~2.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "laravel", + "profiler", + "webprofiler" + ], + "time": "2015-06-07 07:19:29" + }, + { + "name": "barryvdh/laravel-ide-helper", + "version": "v2.0.6", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-ide-helper.git", + "reference": "037386153630a7515a1542f29410d8c267651689" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-ide-helper/zipball/037386153630a7515a1542f29410d8c267651689", + "reference": "037386153630a7515a1542f29410d8c267651689", + "shasum": "" + }, + "require": { + "illuminate/console": "5.0.x|5.1.x", + "illuminate/filesystem": "5.0.x|5.1.x", + "illuminate/support": "5.0.x|5.1.x", + "php": ">=5.4.0", + "phpdocumentor/reflection-docblock": "2.0.4", + "symfony/class-loader": "~2.3" + }, + "require-dev": { + "doctrine/dbal": "~2.3" + }, + "suggest": { + "doctrine/dbal": "Load information from the database about models for phpdocs (~2.3)" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\LaravelIdeHelper\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.", + "keywords": [ + "autocomplete", + "codeintel", + "helper", + "ide", + "laravel", + "netbeans", + "phpdoc", + "phpstorm", + "sublime" + ], + "time": "2015-06-25 08:58:59" + }, + { + "name": "codeception/codeception", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/Codeception/Codeception.git", + "reference": "b5af3aac061ffaeb65ed023534b3c50558e90d07" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/b5af3aac061ffaeb65ed023534b3c50558e90d07", + "reference": "b5af3aac061ffaeb65ed023534b3c50558e90d07", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "facebook/webdriver": "~0.4|~0.5", + "guzzlehttp/guzzle": ">=4.0|<7.0", + "guzzlehttp/psr7": "~1.0", + "php": ">=5.4.0", + "phpunit/phpunit": "~4.7.0", + "symfony/browser-kit": "~2.4", + "symfony/console": "~2.4", + "symfony/css-selector": "~2.4", + "symfony/dom-crawler": "~2.4,!=2.4.5", + "symfony/event-dispatcher": "~2.4", + "symfony/finder": "~2.4", + "symfony/yaml": "~2.4" + }, + "require-dev": { + "codeception/specify": "~0.3", + "facebook/php-sdk-v4": "~4.0", + "flow/jsonpath": "~0.2", + "monolog/monolog": "~1.8", + "pda/pheanstalk": "~2.0", + "videlalvaro/php-amqplib": "~2.4" + }, + "suggest": { + "codeception/phpbuiltinserver": "Extension to start and stop PHP built-in web server for your tests", + "codeception/specify": "BDD-style code blocks", + "codeception/verify": "BDD-style assertions", + "monolog/monolog": "Log test steps", + "phpseclib/phpseclib": "Extension required to use the SFTP option in the FTP Module." + }, + "bin": [ + "codecept" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "psr-4": { + "Codeception\\": "src\\Codeception", + "Codeception\\Extension\\": "ext" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Bodnarchuk", + "email": "davert@mail.ua", + "homepage": "http://codegyre.com" + } + ], + "description": "BDD-style testing framework", + "homepage": "http://codeception.com/", + "keywords": [ + "BDD", + "TDD", + "acceptance testing", + "functional testing", + "unit testing" + ], + "time": "2015-06-30 03:38:01" + }, + { + "name": "codeclimate/php-test-reporter", + "version": "v0.1.2", + "source": { + "type": "git", + "url": "https://github.com/codeclimate/php-test-reporter.git", + "reference": "8ed24ff30f3663ecf40f1c12d6c97eb56c69e646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/codeclimate/php-test-reporter/zipball/8ed24ff30f3663ecf40f1c12d6c97eb56c69e646", + "reference": "8ed24ff30f3663ecf40f1c12d6c97eb56c69e646", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3", + "satooshi/php-coveralls": "0.6.*", + "symfony/console": ">=2.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*@stable" + }, + "bin": [ + "composer/bin/test-reporter" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "CodeClimate\\Component": "src/", + "CodeClimate\\Bundle": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Code Climate", + "email": "hello@codeclimate.com", + "homepage": "https://codeclimate.com" + } + ], + "description": "PHP client for reporting test coverage to Code Climate", + "homepage": "https://github.com/codeclimate/php-test-reporter", + "keywords": [ + "codeclimate", + "coverage" + ], + "time": "2014-07-23 13:42:41" + }, + { + "name": "doctrine/instantiator", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14 21:17:01" + }, + { + "name": "facebook/webdriver", + "version": "v0.6.0", + "source": { + "type": "git", + "url": "https://github.com/facebook/php-webdriver.git", + "reference": "2c5b305ea91b00ebbc433ad1663b7f16c1b31ec5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/2c5b305ea91b00ebbc433ad1663b7f16c1b31ec5", + "reference": "2c5b305ea91b00ebbc433ad1663b7f16c1b31ec5", + "shasum": "" + }, + "require": { + "php": ">=5.3.19" + }, + "require-dev": { + "phpdocumentor/phpdocumentor": "2.*", + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "autoload": { + "classmap": [ + "lib/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "A php client for WebDriver", + "homepage": "https://github.com/facebook/php-webdriver", + "keywords": [ + "facebook", + "php", + "selenium", + "webdriver" + ], + "time": "2015-02-09 19:39:34" + }, + { + "name": "fzaninotto/faker", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/fzaninotto/Faker.git", + "reference": "010c7efedd88bf31141a02719f51fb44c732d5a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/010c7efedd88bf31141a02719f51fb44c732d5a0", + "reference": "010c7efedd88bf31141a02719f51fb44c732d5a0", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~1.5" + }, + "type": "library", + "extra": { + "branch-alias": [] + }, + "autoload": { + "psr-0": { + "Faker": "src/", + "Faker\\PHPUnit": "test/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "time": "2014-06-04 14:43:02" + }, + { + "name": "guzzle/guzzle", + "version": "v3.9.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle3.git", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3.3", + "symfony/event-dispatcher": "~2.1" + }, + "replace": { + "guzzle/batch": "self.version", + "guzzle/cache": "self.version", + "guzzle/common": "self.version", + "guzzle/http": "self.version", + "guzzle/inflection": "self.version", + "guzzle/iterator": "self.version", + "guzzle/log": "self.version", + "guzzle/parser": "self.version", + "guzzle/plugin": "self.version", + "guzzle/plugin-async": "self.version", + "guzzle/plugin-backoff": "self.version", + "guzzle/plugin-cache": "self.version", + "guzzle/plugin-cookie": "self.version", + "guzzle/plugin-curlauth": "self.version", + "guzzle/plugin-error-response": "self.version", + "guzzle/plugin-history": "self.version", + "guzzle/plugin-log": "self.version", + "guzzle/plugin-md5": "self.version", + "guzzle/plugin-mock": "self.version", + "guzzle/plugin-oauth": "self.version", + "guzzle/service": "self.version", + "guzzle/stream": "self.version" + }, + "require-dev": { + "doctrine/cache": "~1.3", + "monolog/monolog": "~1.0", + "phpunit/phpunit": "3.7.*", + "psr/log": "~1.0", + "symfony/class-loader": "~2.1", + "zendframework/zend-cache": "2.*,<2.3", + "zendframework/zend-log": "2.*,<2.3" + }, + "suggest": { + "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.9-dev" + } + }, + "autoload": { + "psr-0": { + "Guzzle": "src/", + "Guzzle\\Tests": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Guzzle Community", + "homepage": "https://github.com/guzzle/guzzle/contributors" + } + ], + "description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2015-03-18 18:23:50" + }, + { + "name": "guzzlehttp/guzzle", + "version": "6.0.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "f992b7b487a816c957d317442bed4966409873e0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f992b7b487a816c957d317442bed4966409873e0", + "reference": "f992b7b487a816c957d317442bed4966409873e0", + "shasum": "" + }, + "require": { + "guzzlehttp/promises": "^1.0.0", + "guzzlehttp/psr7": "^1.0.0", + "php": ">=5.5.0" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.0", + "psr/log": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.0-dev" + } + }, + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2015-05-27 16:57:51" + }, + { + "name": "guzzlehttp/promises", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7", + "reference": "2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2015-06-24 16:16:25" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "af0e1758de355eb113917ad79c3c0e3604bce4bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/af0e1758de355eb113917ad79c3c0e3604bce4bd", + "reference": "af0e1758de355eb113917ad79c3c0e3604bce4bd", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "PSR-7 message implementation", + "keywords": [ + "http", + "message", + "stream", + "uri" + ], + "time": "2015-06-24 19:55:15" + }, + { + "name": "hamcrest/hamcrest-php", + "version": "v1.2.2", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b37020aa976fa52d3de9aa904aa2522dc518f79c", + "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "1.3.3", + "satooshi/php-coveralls": "dev-master" + }, + "type": "library", + "autoload": { + "classmap": [ + "hamcrest" + ], + "files": [ + "hamcrest/Hamcrest.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "time": "2015-05-11 14:41:42" + }, + { + "name": "league/factory-muffin", + "version": "v2.1.1", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/factory-muffin.git", + "reference": "91f0adcdac6b5f7bf2277ac2c90f94352afe65de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/factory-muffin/zipball/91f0adcdac6b5f7bf2277ac2c90f94352afe65de", + "reference": "91f0adcdac6b5f7bf2277ac2c90f94352afe65de", + "shasum": "" + }, + "require": { + "fzaninotto/faker": "1.4.*", + "php": ">=5.3.3" + }, + "replace": { + "zizaco/factory-muff": "self.version" + }, + "require-dev": { + "illuminate/database": "~4.1", + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "illuminate/database": "Factory Muffin works well with eloquent models." + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\FactoryMuffin\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "graham@mineuk.com" + }, + { + "name": "Zizaco Zizuini", + "email": "zizaco@gmail.com" + }, + { + "name": "Scott Robertson", + "email": "scottymeuk@gmail.com" + } + ], + "description": "The goal of this package is to enable the rapid creation of objects for the purpose of testing.", + "homepage": "http://factory-muffin.thephpleague.com/", + "keywords": [ + "factory", + "laravel", + "testing" + ], + "time": "2014-09-18 18:29:06" + }, + { + "name": "maximebf/debugbar", + "version": "v1.10.4", + "source": { + "type": "git", + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "7b2006e6e095126b5a061ec33fca3d90ea8a8219" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/7b2006e6e095126b5a061ec33fca3d90ea8a8219", + "reference": "7b2006e6e095126b5a061ec33fca3d90ea8a8219", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "~1.0", + "symfony/var-dumper": "~2.6" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-0": { + "DebugBar": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", + "keywords": [ + "debug" + ], + "time": "2015-02-05 07:51:20" + }, + { + "name": "mockery/mockery", + "version": "0.9.4", + "source": { + "type": "git", + "url": "https://github.com/padraic/mockery.git", + "reference": "70bba85e4aabc9449626651f48b9018ede04f86b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/padraic/mockery/zipball/70bba85e4aabc9449626651f48b9018ede04f86b", + "reference": "70bba85e4aabc9449626651f48b9018ede04f86b", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "~1.1", + "lib-pcre": ">=7.0", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.9.x-dev" + } + }, + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.", + "homepage": "http://github.com/padraic/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "time": "2015-04-02 19:54:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2015-02-03 12:10:50" + }, + { + "name": "phpspec/php-diff", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/phpspec/php-diff.git", + "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/php-diff/zipball/30e103d19519fe678ae64a60d77884ef3d71b28a", + "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Diff": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Chris Boulton", + "homepage": "http://github.com/chrisboulton", + "role": "Original developer" + } + ], + "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).", + "time": "2013-11-01 13:02:21" + }, + { + "name": "phpspec/phpspec", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/phpspec.git", + "reference": "e9a40577323e67f1de2e214abf32976a0352d8f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/phpspec/zipball/e9a40577323e67f1de2e214abf32976a0352d8f8", + "reference": "e9a40577323e67f1de2e214abf32976a0352d8f8", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.1", + "php": ">=5.3.3", + "phpspec/php-diff": "~1.0.0", + "phpspec/prophecy": "~1.4", + "sebastian/exporter": "~1.0", + "symfony/console": "~2.3", + "symfony/event-dispatcher": "~2.1", + "symfony/finder": "~2.1", + "symfony/process": "~2.1", + "symfony/yaml": "~2.1" + }, + "require-dev": { + "behat/behat": "^3.0.11", + "bossa/phpspec2-expect": "~1.0", + "phpunit/phpunit": "~4.4", + "symfony/filesystem": "~2.1", + "symfony/process": "~2.1" + }, + "suggest": { + "phpspec/nyan-formatters": "~1.0 – Adds Nyan formatters" + }, + "bin": [ + "bin/phpspec" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "PhpSpec": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "homepage": "http://marcelloduarte.net/" + } + ], + "description": "Specification-oriented BDD framework for PHP 5.3+", + "homepage": "http://phpspec.net/", + "keywords": [ + "BDD", + "SpecBDD", + "TDD", + "spec", + "specification", + "testing", + "tests" + ], + "time": "2015-05-30 15:21:40" + }, + { + "name": "phpspec/prophecy", + "version": "v1.4.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "phpdocumentor/reflection-docblock": "~2.0", + "sebastian/comparator": "~1.1" + }, + "require-dev": { + "phpspec/phpspec": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2015-04-27 22:15:08" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.1.7", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "07e27765596d72c378a6103e80da5d84e802f1e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/07e27765596d72c378a6103e80da5d84e802f1e4", + "reference": "07e27765596d72c378a6103e80da5d84e802f1e4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-06-30 06:52:35" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2015-04-02 05:19:05" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21 13:50:34" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/83fe1bdc5d47658b727595c14da140da92b3d66d", + "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2015-06-13 07:35:30" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/7a9b0969488c3c54fd62b4d504b3ec758fd005d9", + "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2015-06-19 03:43:16" + }, + { + "name": "phpunit/phpunit", + "version": "4.7.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "0ebabb4cda7d066be8391dfdbaf57fe70ac9a99b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0ebabb4cda7d066be8391dfdbaf57fe70ac9a99b", + "reference": "0ebabb4cda7d066be8391dfdbaf57fe70ac9a99b", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpspec/prophecy": "~1.3,>=1.3.1", + "phpunit/php-code-coverage": "~2.1", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": ">=1.0.6", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.1", + "sebastian/diff": "~1.2", + "sebastian/environment": "~1.2", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.1|~3.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.7.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2015-06-30 06:53:57" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/92408bb1968a81b3217a6fdf6c1a198da83caa35", + "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "~1.0,>=1.0.2", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2015-06-11 15:55:48" + }, + { + "name": "psr/http-message", + "version": "1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", + "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2015-05-04 20:22:00" + }, + { + "name": "satooshi/php-coveralls", + "version": "v0.6.1", + "source": { + "type": "git", + "url": "https://github.com/satooshi/php-coveralls.git", + "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", + "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-simplexml": "*", + "guzzle/guzzle": ">=3.0", + "php": ">=5.3", + "psr/log": "1.0.0", + "symfony/config": ">=2.0", + "symfony/console": ">=2.0", + "symfony/stopwatch": ">=2.2", + "symfony/yaml": ">=2.0" + }, + "require-dev": { + "apigen/apigen": "2.8.*@stable", + "pdepend/pdepend": "dev-master", + "phpmd/phpmd": "dev-master", + "phpunit/php-invoker": ">=1.1.0,<1.2.0", + "phpunit/phpunit": "3.7.*@stable", + "sebastian/finder-facade": "dev-master", + "sebastian/phpcpd": "1.4.*@stable", + "squizlabs/php_codesniffer": "1.4.*@stable", + "theseer/fdomdocument": "dev-master" + }, + "bin": [ + "composer/bin/coveralls" + ], + "type": "library", + "autoload": { + "psr-0": { + "Contrib\\Component": "src/", + "Contrib\\Bundle": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kitamura Satoshi", + "email": "with.no.parachute@gmail.com", + "homepage": "https://www.facebook.com/satooshi.jp" + } + ], + "description": "PHP client library for Coveralls API", + "homepage": "https://github.com/satooshi/php-coveralls", + "keywords": [ + "ci", + "coverage", + "github", + "test" + ], + "time": "2013-05-04 08:07:33" + }, + { + "name": "sebastian/comparator", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2015-01-29 16:28:08" + }, + { + "name": "sebastian/diff", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-02-22 15:13:53" + }, + { + "name": "sebastian/environment", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2015-01-01 10:01:08" + }, + { + "name": "sebastian/exporter", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "84839970d05254c73cde183a721c7af13aede943" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", + "reference": "84839970d05254c73cde183a721c7af13aede943", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2015-01-27 07:23:06" + }, + { + "name": "sebastian/global-state", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2014-10-06 09:23:50" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-01-24 09:48:32" + }, + { + "name": "sebastian/version", + "version": "1.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2015-06-21 13:59:46" + }, + { + "name": "symfony/browser-kit", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/BrowserKit.git", + "reference": "d0a144a1a96d5dc90bed2814b2096a1322761672" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/d0a144a1a96d5dc90bed2814b2096a1322761672", + "reference": "d0a144a1a96d5dc90bed2814b2096a1322761672", + "shasum": "" + }, + "require": { + "php": ">=5.3.9", + "symfony/dom-crawler": "~2.0,>=2.0.5" + }, + "require-dev": { + "symfony/css-selector": "~2.0,>=2.0.5", + "symfony/phpunit-bridge": "~2.7", + "symfony/process": "~2.0,>=2.0.5" + }, + "suggest": { + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\BrowserKit\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony BrowserKit Component", + "homepage": "https://symfony.com", + "time": "2015-06-04 20:11:48" + }, + { + "name": "symfony/class-loader", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/ClassLoader.git", + "reference": "84843730de48ca0feba91004a03c7c952f8ea1da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/84843730de48ca0feba91004a03c7c952f8ea1da", + "reference": "84843730de48ca0feba91004a03c7c952f8ea1da", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/finder": "~2.0,>=2.0.5", + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\ClassLoader\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony ClassLoader Component", + "homepage": "https://symfony.com", + "time": "2015-06-08 09:37:21" + }, + { + "name": "symfony/config", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Config.git", + "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Config/zipball/58ded81f1f582a87c528ef3dae9a859f78b5f374", + "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374", + "shasum": "" + }, + "require": { + "php": ">=5.3.9", + "symfony/filesystem": "~2.3" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "https://symfony.com", + "time": "2015-06-11 14:06:56" + }, + { + "name": "symfony/filesystem", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a0d43eb3e17d4f4c6990289805a488a0482a07f3", + "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2015-06-08 09:37:21" + }, + { + "name": "symfony/stopwatch", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Stopwatch.git", + "reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/c653f1985f6c2b7dbffd04d48b9c0a96aaef814b", + "reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2015-06-04 20:11:48" + }, + { + "name": "symfony/yaml", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/9808e75c609a14f6db02f70fccf4ca4aab53c160", + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2015-06-10 15:30:22" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": { diff --git a/config/twigbridge.php b/config/twigbridge.php index 04d882d65e..8d5621c253 100644 --- a/config/twigbridge.php +++ b/config/twigbridge.php @@ -145,12 +145,12 @@ return [ 'ExpandedForm' => [ 'is_safe' => [ 'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location', - 'multiRadio' + 'multiRadio','file' ] ], 'Form' => [ 'is_safe' => [ - 'input', 'select', 'checkbox', 'model', 'open', 'radio', 'textarea' + 'input', 'select', 'checkbox', 'model', 'open', 'radio', 'textarea','file' ] ], ], diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php index f7d834653a..d58d2cc632 100644 --- a/resources/lang/en/firefly.php +++ b/resources/lang/en/firefly.php @@ -21,6 +21,13 @@ return [ // csv import: 'csv_import' => 'Import CSV file', + 'csv' => 'CSV', + 'csv_index_text' => 'Here be explanation.', + 'csv_upload_form' => 'Upload form', + 'upload_csv_file' => 'Upload CSV file', + 'csv_header_help' => 'Check this when bla bla', + 'csv_row' => 'row', + 'upload_not_writeable' => 'Cannot write to the path mentioned here. Cannot upload', // create new stuff: 'create_new_withdrawal' => 'Create new withdrawal', diff --git a/resources/lang/en/form.php b/resources/lang/en/form.php index 4fbb9a44f3..8b9530ec10 100644 --- a/resources/lang/en/form.php +++ b/resources/lang/en/form.php @@ -45,6 +45,8 @@ return [ 'under' => 'Under', 'symbol' => 'Symbol', 'code' => 'Code', + 'csv' => 'CSV file', + 'has_headers' => 'Headers', 'store_new_withdrawal' => 'Store new withdrawal', 'store_new_deposit' => 'Store new deposit', diff --git a/resources/lang/nl/firefly.php b/resources/lang/nl/firefly.php index 6c03404832..aaa2a9a90e 100644 --- a/resources/lang/nl/firefly.php +++ b/resources/lang/nl/firefly.php @@ -20,7 +20,14 @@ return [ 'search_results_for' => 'Zoekresultaten voor ":query"', // csv import: - 'csv_import' => 'Import CSV file', + 'csv_import' => 'Importeer CSV-bestand', + 'csv' => 'CSV', + 'csv_index_text' => 'Hier komt uitleg.', + 'csv_upload_form' => 'Upload formulier', + 'upload_csv_file' => 'Upload CSV-bestand', + 'csv_header_help' => 'Check dit als bla bla', + 'csv_row' => 'rij', + 'upload_not_writeable' => 'Cannot write to the path mentioned here. Cannot upload', // create new stuff: 'create_new_withdrawal' => 'Nieuwe uitgave', diff --git a/resources/lang/nl/form.php b/resources/lang/nl/form.php index 5ab0cd308b..837ec1d3a8 100644 --- a/resources/lang/nl/form.php +++ b/resources/lang/nl/form.php @@ -45,6 +45,8 @@ return [ 'under' => 'Onder', 'symbol' => 'Symbool', 'code' => 'Code', + 'csv' => 'CSV-bestand', + 'has_headers' => 'Eerste rij zijn kolomnamen', 'store_new_withdrawal' => 'Nieuwe uitgave opslaan', 'store_new_deposit' => 'Nieuwe inkomsten opslaan', diff --git a/resources/twig/csv/index.twig b/resources/twig/csv/index.twig index 5dd98e4135..023d0b2fe0 100644 --- a/resources/twig/csv/index.twig +++ b/resources/twig/csv/index.twig @@ -7,6 +7,81 @@ {% block content %} - Bla bla. +
    +
    +
    +
    +

    {{ 'csv'|_ }}

    + + +
    + +
    + +
    +
    + {{ 'csv_index_text'|_ }} +
    +
    + +
    +
    +
    +
    +
    +
    +

    {{ 'csv_upload_form'|_ }}

    + + +
    + +
    + +
    +
    + +
    + + + {{ ExpandedForm.checkbox('has_headers',false,null,{helpText: 'csv_header_help'|_}) }} + + {{ ExpandedForm.file('csv') }} + + {% if uploadPossible %} +
    +
    +   +
    + +
    + +
    +
    + {% else %} +
    +
    +   +
    + +
    +
    {{ path }}
    +

    + {{ 'upload_not_writeable'|_ }} +

    +
    +
    + {% endif %} + + + +
    + + +
    +
    +
    +
    {% endblock %} diff --git a/resources/twig/form/checkbox.twig b/resources/twig/form/checkbox.twig index bea165b856..b2bc258cd0 100644 --- a/resources/twig/form/checkbox.twig +++ b/resources/twig/form/checkbox.twig @@ -7,6 +7,7 @@ {{ Form.checkbox(name, value, options.checked, options) }} + {% include 'form/help.twig' %} {% include 'form/feedback.twig' %} diff --git a/resources/twig/form/file.twig b/resources/twig/form/file.twig new file mode 100644 index 0000000000..0596ef7dbd --- /dev/null +++ b/resources/twig/form/file.twig @@ -0,0 +1,9 @@ +
    + + +
    + {{ Form.file(name, options) }} + {% include 'form/help.twig' %} + {% include 'form/feedback.twig' %} +
    +
    diff --git a/storage/upload/.gitignore b/storage/upload/.gitignore new file mode 100644 index 0000000000..d6b7ef32c8 --- /dev/null +++ b/storage/upload/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore From 26c9b2c3531b6a69f34f485cd46d2803020b2921 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 12:22:20 +0200 Subject: [PATCH 08/60] Initial process form. --- app/Http/Controllers/CsvController.php | 49 ++++++++++++------ resources/twig/csv/upload.twig | 71 ++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 15 deletions(-) create mode 100644 resources/twig/csv/upload.twig diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 3f2504a7a4..4e40bbeed7 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -8,6 +8,8 @@ namespace FireflyIII\Http\Controllers; +use Auth; +use Crypt; use Illuminate\Http\Request; use Input; use League\Csv\Reader; @@ -42,7 +44,7 @@ class CsvController extends Controller $subTitle = trans('firefly.csv_import'); // can actually upload? - $uploadPossible = !is_writable(storage_path('upload')); + $uploadPossible = is_writable(storage_path('upload')); $path = storage_path('upload'); @@ -54,6 +56,21 @@ class CsvController extends Controller */ public function upload(Request $request) { + // possible column roles: + $roles = [ + '(ignore this column)', + 'Asset account name', + 'Expense or revenue account name', + 'Amount', + 'Date', + 'Currency', + 'Description', + 'Category', + 'Budget', + + ]; + + if (!$request->hasFile('csv')) { Session::flash('warning', 'No file uploaded.'); @@ -64,29 +81,31 @@ class CsvController extends Controller $reader = Reader::createFromPath($request->file('csv')->getRealPath()); $data = $reader->query(); $data->next(); // go to first row: - if ($hasHeaders) { - // first row = headers. + $count = count($data->current()); + $headers = []; + for ($i = 1; $i <= $count; $i++) { + $headers[] = trans('firefly.csv_row') . ' #' . $i; + } + if ($hasHeaders) { $headers = $data->current(); - } else { - $count = count($data->current()); - $headers = []; - for ($i = 1; $i <= $count; $i++) { - $headers[] = trans('firefly.csv_row') . ' #' . $i; - } } // example data is always the second row: $data->next(); $example = $data->current(); + // store file somewhere temporary (encrypted)? + $time = str_replace(' ', '-', microtime()); + $fileName = 'csv-upload-' . Auth::user()->id . '-' . $time . '.csv.encrypted'; + $fullPath = storage_path('upload') . DIRECTORY_SEPARATOR . $fileName; + $content = file_get_contents($request->file('csv')->getRealPath()); + $content = Crypt::encrypt($content); + file_put_contents($fullPath, $content); + Session::put('latestCSVUpload', $fullPath); - var_dump($headers); - var_dump($example); + $subTitle = trans('firefly.csv_process'); - // store file somewhere temporary? - - - exit; + return view('csv.upload', compact('headers', 'example', 'roles', 'subTitle')); } } \ No newline at end of file diff --git a/resources/twig/csv/upload.twig b/resources/twig/csv/upload.twig new file mode 100644 index 0000000000..4b0b34cd07 --- /dev/null +++ b/resources/twig/csv/upload.twig @@ -0,0 +1,71 @@ +{% extends "./layout/default.twig" %} + +{% block breadcrumbs %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +{% endblock %} + +{% block content %} + + +
    +
    +
    +
    +

    {{ 'csv_process'|_ }}

    + + +
    + +
    + +
    +
    + {{ 'csv_process_text'|_ }} +
    +
    + +
    +
    +
    +
    +
    +
    +

    {{ 'csv_process_form'|_ }}

    + + +
    + +
    + +
    +
    + + + + + + + + + {% for index,header in headers %} + + + + + + + + {% endfor %} +
    {{ 'cvs_column_name'|_ }}{{ 'cvs_column_example'|_ }}{{ 'cvs_column_role'|_ }}{{ 'do_map_value'|_ }}
    {{ header }}{{ example[index] }} + {{ Form.select(('role_'~index), roles) }} + + {{ Form.checkbox(('map_'~index),false) }} +
    + + +
    +
    +
    +
    + +{% endblock %} From 4a20eef35181d41308242821bb69cf07c4fa741c Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 12:27:49 +0200 Subject: [PATCH 09/60] Add IBAN field. --- .../2015_06_23_050233_changes_for_v3451.php | 16 +++++++---- .../2015_07_03_102450_changes_for_v3462.php | 28 +++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 database/migrations/2015_07_03_102450_changes_for_v3462.php diff --git a/database/migrations/2015_06_23_050233_changes_for_v3451.php b/database/migrations/2015_06_23_050233_changes_for_v3451.php index 7c2ee2ccaa..72c6f799f2 100644 --- a/database/migrations/2015_06_23_050233_changes_for_v3451.php +++ b/database/migrations/2015_06_23_050233_changes_for_v3451.php @@ -1,6 +1,7 @@ dropColumn('iban'); + } + ); } - //$table->smallInteger('reminder_skip')->unsigned(); - //$table->boolean('remind_me'); - /** * Run the migrations. * @@ -27,7 +29,11 @@ class ChangesForV3451 extends Migration */ public function up() { - + Schema::table( + 'accounts', function (Blueprint $table) { + $table->string('iban', 38)->nullable(); + } + ); } } diff --git a/database/migrations/2015_07_03_102450_changes_for_v3462.php b/database/migrations/2015_07_03_102450_changes_for_v3462.php new file mode 100644 index 0000000000..7dd6e4b833 --- /dev/null +++ b/database/migrations/2015_07_03_102450_changes_for_v3462.php @@ -0,0 +1,28 @@ + Date: Fri, 3 Jul 2015 12:51:14 +0200 Subject: [PATCH 10/60] Accounts can now have IBAN. --- app/Http/Controllers/AccountController.php | 2 + app/Http/Requests/AccountFormRequest.php | 1 + app/Models/Account.php | 29 ++++++++++++++ .../Account/AccountRepository.php | 6 ++- app/Validation/FireflyValidator.php | 27 +++++++++++++ .../2015_06_23_050233_changes_for_v3451.php | 39 ------------------- .../2015_07_03_102450_changes_for_v3462.php | 35 +++++++++++------ database/seeds/TestDataSeeder.php | 1 + resources/lang/en/form.php | 1 + resources/lang/nl/form.php | 1 + resources/twig/accounts/create.twig | 1 + resources/twig/accounts/edit.twig | 1 + 12 files changed, 92 insertions(+), 52 deletions(-) delete mode 100644 database/migrations/2015_06_23_050233_changes_for_v3451.php diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index be1a8545c8..f9dc21694b 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -199,6 +199,7 @@ class AccountController extends Controller 'virtualBalance' => floatval($request->input('virtualBalance')), 'active' => true, 'user' => Auth::user()->id, + 'iban' => $request->input('iban'), 'accountRole' => $request->input('accountRole'), 'openingBalance' => floatval($request->input('openingBalance')), 'openingBalanceDate' => new Carbon((string)$request->input('openingBalanceDate')), @@ -237,6 +238,7 @@ class AccountController extends Controller 'name' => $request->input('name'), 'active' => $request->input('active'), 'user' => Auth::user()->id, + 'iban' => $request->input('iban'), 'accountRole' => $request->input('accountRole'), 'virtualBalance' => floatval($request->input('virtualBalance')), 'openingBalance' => floatval($request->input('openingBalance')), diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.php index 83275c966d..a0ff4e9617 100644 --- a/app/Http/Requests/AccountFormRequest.php +++ b/app/Http/Requests/AccountFormRequest.php @@ -44,6 +44,7 @@ class AccountFormRequest extends Request 'id' => $idRule, 'name' => $nameRule, 'openingBalance' => 'numeric', + 'iban' => 'iban', 'virtualBalance' => 'numeric', 'openingBalanceDate' => 'date', 'accountRole' => 'in:' . $accountRoles, diff --git a/app/Models/Account.php b/app/Models/Account.php index a09825c266..9c061021d3 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -47,6 +47,9 @@ use Watson\Validating\ValidatingTrait; * @property mixed piggyBalance * @property mixed difference * @property mixed percentage + * @property string $iban + * @property-read mixed $name_for_editform + * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereIban($value) */ class Account extends Model { @@ -143,6 +146,22 @@ class Account extends Model return ['created_at', 'updated_at', 'deleted_at']; } + /** + * @codeCoverageIgnore + * + * @param $value + * + * @return string + */ + public function getIbanAttribute($value) + { + if (is_null($value)) { + return null; + } + + return Crypt::decrypt($value); + } + /** * * @param string $fieldName @@ -236,6 +255,16 @@ class Account extends Model $query->where($joinName . '.data', json_encode($value)); } + /** + * @codeCoverageIgnore + * + * @param $value + */ + public function setIbanAttribute($value) + { + $this->attributes['iban'] = Crypt::encrypt($value); + } + /** * @codeCoverageIgnore * diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 8785c588ef..9ee8e6dca2 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -401,6 +401,7 @@ class AccountRepository implements AccountRepositoryInterface 'virtualBalance' => 0, 'name' => $data['name'] . ' initial balance', 'active' => false, + 'iban' => '', ]; $opposing = $this->storeAccount($opposingData); $this->storeInitialBalance($newAccount, $opposing, $data); @@ -431,6 +432,7 @@ class AccountRepository implements AccountRepositoryInterface $account->name = $data['name']; $account->active = $data['active'] == '1' ? true : false; $account->virtual_balance = $data['virtualBalance']; + $account->iban = $data['iban']; $account->save(); $this->updateMetadata($account, $data); @@ -481,6 +483,7 @@ class AccountRepository implements AccountRepositoryInterface 'name' => $data['name'], 'virtual_balance' => $data['virtualBalance'], 'active' => $data['active'] === true ? true : false, + 'iban' => $data['iban'], ] ); @@ -490,7 +493,8 @@ class AccountRepository implements AccountRepositoryInterface 'user_id' => $data['user'], 'account_type_id' => $accountType->id, 'virtual_balance' => $data['virtualBalance'], - 'name' => $data['name'] + 'name' => $data['name'], + 'iban' => $data['iban'], ]; $existingAccount = Account::firstOrNullEncrypted($searchData); if (!$existingAccount) { diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 4e6e1397cb..6c177af69d 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -54,6 +54,33 @@ class FireflyValidator extends Validator } + /** + * @param $attribute + * @param $value + * @param $parameters + */ + public function validateIban($attribute, $value, $parameters) + { + + $value = strtoupper($value); + if (strlen($value) < 6) { + return false; + } + + $search = [' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; + $replace = ['', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', + '32', '33', '34', '35']; + + // take + $first = substr($value, 0, 4); + $last = substr($value, 4); + $iban = $last . $first; + $iban = str_replace($search, $replace, $iban); + $checksum = bcmod($iban, '97'); + + return (intval($checksum) === 1); + } + /** * @param $attribute * @param $value diff --git a/database/migrations/2015_06_23_050233_changes_for_v3451.php b/database/migrations/2015_06_23_050233_changes_for_v3451.php deleted file mode 100644 index 72c6f799f2..0000000000 --- a/database/migrations/2015_06_23_050233_changes_for_v3451.php +++ /dev/null @@ -1,39 +0,0 @@ -dropColumn('iban'); - } - ); - } - - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table( - 'accounts', function (Blueprint $table) { - $table->string('iban', 38)->nullable(); - } - ); - - } -} diff --git a/database/migrations/2015_07_03_102450_changes_for_v3462.php b/database/migrations/2015_07_03_102450_changes_for_v3462.php index 7dd6e4b833..930c8b0bab 100644 --- a/database/migrations/2015_07_03_102450_changes_for_v3462.php +++ b/database/migrations/2015_07_03_102450_changes_for_v3462.php @@ -1,10 +1,27 @@ dropColumn('iban'); + } + ); + } + /** * Run the migrations. * @@ -13,16 +30,10 @@ class ChangesForV3462 extends Migration public function up() { // add IBAN to accounts: - - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - // + Schema::table( + 'accounts', function (Blueprint $table) { + $table->string('iban')->nullable(); + } + ); } } diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php index 2ef6f90674..fedf19c97a 100644 --- a/database/seeds/TestDataSeeder.php +++ b/database/seeds/TestDataSeeder.php @@ -126,6 +126,7 @@ class TestDataSeeder extends Seeder 'name' => $name, 'active' => 1, 'encrypted' => 1, + 'iban' => 'GB82WEST12345698765432' ] ); foreach ($assetMeta[$index] as $name => $value) { diff --git a/resources/lang/en/form.php b/resources/lang/en/form.php index 4fbb9a44f3..4edfa130f8 100644 --- a/resources/lang/en/form.php +++ b/resources/lang/en/form.php @@ -45,6 +45,7 @@ return [ 'under' => 'Under', 'symbol' => 'Symbol', 'code' => 'Code', + 'iban' => 'IBAN', 'store_new_withdrawal' => 'Store new withdrawal', 'store_new_deposit' => 'Store new deposit', diff --git a/resources/lang/nl/form.php b/resources/lang/nl/form.php index 5ab0cd308b..f2ce23701f 100644 --- a/resources/lang/nl/form.php +++ b/resources/lang/nl/form.php @@ -45,6 +45,7 @@ return [ 'under' => 'Onder', 'symbol' => 'Symbool', 'code' => 'Code', + 'iban' => 'IBAN', 'store_new_withdrawal' => 'Nieuwe uitgave opslaan', 'store_new_deposit' => 'Nieuwe inkomsten opslaan', diff --git a/resources/twig/accounts/create.twig b/resources/twig/accounts/create.twig index da6437d0e7..c52b5321ea 100644 --- a/resources/twig/accounts/create.twig +++ b/resources/twig/accounts/create.twig @@ -29,6 +29,7 @@
    + {{ ExpandedForm.text('iban') }} {{ ExpandedForm.balance('openingBalance') }} {{ ExpandedForm.date('openingBalanceDate', phpdate('Y-m-d')) }} {{ ExpandedForm.select('accountRole', Config.get('firefly.accountRoles'),null,{'helpText' : 'Any extra options resulting from your choice can be set later.'}) }} diff --git a/resources/twig/accounts/edit.twig b/resources/twig/accounts/edit.twig index 78d846f546..32e0c55972 100644 --- a/resources/twig/accounts/edit.twig +++ b/resources/twig/accounts/edit.twig @@ -27,6 +27,7 @@

    {{ 'optionalFields'|_ }}

    + {{ ExpandedForm.text('iban') }} {% if account.accounttype.type == 'Default account' or account.accounttype.type == 'Asset account' %} {{ ExpandedForm.balance('openingBalance',null, {'currency' : openingBalance ? openingBalance.transactionCurrency : null}) }} {{ ExpandedForm.date('openingBalanceDate') }} From ee50b58e0014e53e857fb7393659b907de1f9602 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 12:52:03 +0200 Subject: [PATCH 11/60] Update model info. --- app/Models/AccountMeta.php | 2 +- app/Models/AccountType.php | 2 +- app/Models/Bill.php | 2 +- app/Models/Budget.php | 2 +- app/Models/BudgetLimit.php | 2 +- app/Models/Component.php | 2 +- app/Models/LimitRepetition.php | 2 +- app/Models/PiggyBank.php | 8 +++++++- app/Models/PiggyBankEvent.php | 2 +- app/Models/PiggyBankRepetition.php | 2 +- app/Models/Preference.php | 2 +- app/Models/Transaction.php | 2 +- app/Models/TransactionCurrency.php | 2 +- app/Models/TransactionGroup.php | 2 +- app/Models/TransactionRelation.php | 2 +- app/Models/TransactionType.php | 2 +- app/User.php | 3 +-- 17 files changed, 23 insertions(+), 18 deletions(-) diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.php index 279fe60765..1e2d0ce3c3 100644 --- a/app/Models/AccountMeta.php +++ b/app/Models/AccountMeta.php @@ -6,7 +6,7 @@ use Watson\Validating\ValidatingTrait; /** * Class AccountMeta * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php index 2148b9e961..6de461749b 100644 --- a/app/Models/AccountType.php +++ b/app/Models/AccountType.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class AccountType * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/Bill.php b/app/Models/Bill.php index 76ce0b66ad..4cc50a19da 100644 --- a/app/Models/Bill.php +++ b/app/Models/Bill.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model; * FireflyIII\Models\Bill * * @codeCoverageIgnore Class Bill - * @package FireflyIII\Models + * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $updated_at diff --git a/app/Models/Budget.php b/app/Models/Budget.php index 83ab460422..96886037f0 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class Budget * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php index 42e72dc502..97f2b16dab 100644 --- a/app/Models/BudgetLimit.php +++ b/app/Models/BudgetLimit.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class BudgetLimit * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/Component.php b/app/Models/Component.php index 84686751be..c65a9c8812 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class Component * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/LimitRepetition.php b/app/Models/LimitRepetition.php index d5fd692dae..5f6ea2a6cf 100644 --- a/app/Models/LimitRepetition.php +++ b/app/Models/LimitRepetition.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class LimitRepetition * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index ebe5379da2..cdabb6d4e8 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class PiggyBank * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at @@ -37,6 +37,12 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereOrder($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereEncrypted($value) * @property PiggyBankRepetition currentRep + * @property string $reminder + * @property integer $reminder_skip + * @property boolean $remind_me + * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereReminder($value) + * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereReminderSkip($value) + * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereRemindMe($value) */ class PiggyBank extends Model { diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php index 6b9bdceda1..98de0f04ef 100644 --- a/app/Models/PiggyBankEvent.php +++ b/app/Models/PiggyBankEvent.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class PiggyBankEvent * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php index a24066f2ee..68d2388acc 100644 --- a/app/Models/PiggyBankRepetition.php +++ b/app/Models/PiggyBankRepetition.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class PiggyBankRepetition * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/Preference.php b/app/Models/Preference.php index 56bc6f7cfd..263e7e33bc 100644 --- a/app/Models/Preference.php +++ b/app/Models/Preference.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class Preference * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 26ca48ef45..43f9928439 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -9,7 +9,7 @@ use Watson\Validating\ValidatingTrait; /** * Class Transaction * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php index 27b21f36c3..4adad9b216 100644 --- a/app/Models/TransactionCurrency.php +++ b/app/Models/TransactionCurrency.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class TransactionCurrency * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/TransactionGroup.php b/app/Models/TransactionGroup.php index bb41749ca2..6c980bfac0 100644 --- a/app/Models/TransactionGroup.php +++ b/app/Models/TransactionGroup.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class TransactionGroup * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/TransactionRelation.php b/app/Models/TransactionRelation.php index aa4d3810af..056d61fdd8 100644 --- a/app/Models/TransactionRelation.php +++ b/app/Models/TransactionRelation.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class TransactionRelation * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models */ class TransactionRelation extends Model diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php index 098d5bcfc7..886858bb2c 100644 --- a/app/Models/TransactionType.php +++ b/app/Models/TransactionType.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class TransactionType * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/User.php b/app/User.php index 408b621188..0763ff9e56 100644 --- a/app/User.php +++ b/app/User.php @@ -10,8 +10,7 @@ use Zizaco\Entrust\Traits\EntrustUserTrait; /** * Class User * - * @codeCoverageIgnore - * + * @codeCoverageIgnore * @package FireflyIII * @property integer $id * @property \Carbon\Carbon $created_at From 7653a34aea07f506ebd948b64cb8b499b3751939 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 10:32:16 +0200 Subject: [PATCH 12/60] New read me. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 6f6bf573ba..a601b48810 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ [![Total Downloads](https://poser.pugx.org/grumpydictator/firefly-iii/downloads)](https://packagist.org/packages/grumpydictator/firefly-iii) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/JC5/firefly-iii/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/JC5/firefly-iii/?branch=master) -[![Code Coverage](https://scrutinizer-ci.com/g/JC5/firefly-iii/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/JC5/firefly-iii/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/JC5/firefly-iii/badges/build.png?b=master)](https://scrutinizer-ci.com/g/JC5/firefly-iii/build-status/master) ## About From 854368a8f3f19ea0f67e29b4151cf856a15fb859 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 12:27:49 +0200 Subject: [PATCH 13/60] Add IBAN field. --- .../2015_06_23_050233_changes_for_v3451.php | 16 +++++++---- .../2015_07_03_102450_changes_for_v3462.php | 28 +++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 database/migrations/2015_07_03_102450_changes_for_v3462.php diff --git a/database/migrations/2015_06_23_050233_changes_for_v3451.php b/database/migrations/2015_06_23_050233_changes_for_v3451.php index 7c2ee2ccaa..72c6f799f2 100644 --- a/database/migrations/2015_06_23_050233_changes_for_v3451.php +++ b/database/migrations/2015_06_23_050233_changes_for_v3451.php @@ -1,6 +1,7 @@ dropColumn('iban'); + } + ); } - //$table->smallInteger('reminder_skip')->unsigned(); - //$table->boolean('remind_me'); - /** * Run the migrations. * @@ -27,7 +29,11 @@ class ChangesForV3451 extends Migration */ public function up() { - + Schema::table( + 'accounts', function (Blueprint $table) { + $table->string('iban', 38)->nullable(); + } + ); } } diff --git a/database/migrations/2015_07_03_102450_changes_for_v3462.php b/database/migrations/2015_07_03_102450_changes_for_v3462.php new file mode 100644 index 0000000000..7dd6e4b833 --- /dev/null +++ b/database/migrations/2015_07_03_102450_changes_for_v3462.php @@ -0,0 +1,28 @@ + Date: Fri, 3 Jul 2015 12:51:14 +0200 Subject: [PATCH 14/60] Accounts can now have IBAN. --- app/Http/Controllers/AccountController.php | 2 + app/Http/Requests/AccountFormRequest.php | 1 + app/Models/Account.php | 29 ++++++++++++++ .../Account/AccountRepository.php | 6 ++- app/Validation/FireflyValidator.php | 27 +++++++++++++ .../2015_06_23_050233_changes_for_v3451.php | 39 ------------------- .../2015_07_03_102450_changes_for_v3462.php | 35 +++++++++++------ database/seeds/TestDataSeeder.php | 1 + resources/lang/en/form.php | 1 + resources/lang/nl/form.php | 1 + resources/twig/accounts/create.twig | 1 + resources/twig/accounts/edit.twig | 1 + 12 files changed, 92 insertions(+), 52 deletions(-) delete mode 100644 database/migrations/2015_06_23_050233_changes_for_v3451.php diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index be1a8545c8..f9dc21694b 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -199,6 +199,7 @@ class AccountController extends Controller 'virtualBalance' => floatval($request->input('virtualBalance')), 'active' => true, 'user' => Auth::user()->id, + 'iban' => $request->input('iban'), 'accountRole' => $request->input('accountRole'), 'openingBalance' => floatval($request->input('openingBalance')), 'openingBalanceDate' => new Carbon((string)$request->input('openingBalanceDate')), @@ -237,6 +238,7 @@ class AccountController extends Controller 'name' => $request->input('name'), 'active' => $request->input('active'), 'user' => Auth::user()->id, + 'iban' => $request->input('iban'), 'accountRole' => $request->input('accountRole'), 'virtualBalance' => floatval($request->input('virtualBalance')), 'openingBalance' => floatval($request->input('openingBalance')), diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.php index 83275c966d..a0ff4e9617 100644 --- a/app/Http/Requests/AccountFormRequest.php +++ b/app/Http/Requests/AccountFormRequest.php @@ -44,6 +44,7 @@ class AccountFormRequest extends Request 'id' => $idRule, 'name' => $nameRule, 'openingBalance' => 'numeric', + 'iban' => 'iban', 'virtualBalance' => 'numeric', 'openingBalanceDate' => 'date', 'accountRole' => 'in:' . $accountRoles, diff --git a/app/Models/Account.php b/app/Models/Account.php index a09825c266..9c061021d3 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -47,6 +47,9 @@ use Watson\Validating\ValidatingTrait; * @property mixed piggyBalance * @property mixed difference * @property mixed percentage + * @property string $iban + * @property-read mixed $name_for_editform + * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereIban($value) */ class Account extends Model { @@ -143,6 +146,22 @@ class Account extends Model return ['created_at', 'updated_at', 'deleted_at']; } + /** + * @codeCoverageIgnore + * + * @param $value + * + * @return string + */ + public function getIbanAttribute($value) + { + if (is_null($value)) { + return null; + } + + return Crypt::decrypt($value); + } + /** * * @param string $fieldName @@ -236,6 +255,16 @@ class Account extends Model $query->where($joinName . '.data', json_encode($value)); } + /** + * @codeCoverageIgnore + * + * @param $value + */ + public function setIbanAttribute($value) + { + $this->attributes['iban'] = Crypt::encrypt($value); + } + /** * @codeCoverageIgnore * diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 8785c588ef..9ee8e6dca2 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -401,6 +401,7 @@ class AccountRepository implements AccountRepositoryInterface 'virtualBalance' => 0, 'name' => $data['name'] . ' initial balance', 'active' => false, + 'iban' => '', ]; $opposing = $this->storeAccount($opposingData); $this->storeInitialBalance($newAccount, $opposing, $data); @@ -431,6 +432,7 @@ class AccountRepository implements AccountRepositoryInterface $account->name = $data['name']; $account->active = $data['active'] == '1' ? true : false; $account->virtual_balance = $data['virtualBalance']; + $account->iban = $data['iban']; $account->save(); $this->updateMetadata($account, $data); @@ -481,6 +483,7 @@ class AccountRepository implements AccountRepositoryInterface 'name' => $data['name'], 'virtual_balance' => $data['virtualBalance'], 'active' => $data['active'] === true ? true : false, + 'iban' => $data['iban'], ] ); @@ -490,7 +493,8 @@ class AccountRepository implements AccountRepositoryInterface 'user_id' => $data['user'], 'account_type_id' => $accountType->id, 'virtual_balance' => $data['virtualBalance'], - 'name' => $data['name'] + 'name' => $data['name'], + 'iban' => $data['iban'], ]; $existingAccount = Account::firstOrNullEncrypted($searchData); if (!$existingAccount) { diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 4e6e1397cb..6c177af69d 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -54,6 +54,33 @@ class FireflyValidator extends Validator } + /** + * @param $attribute + * @param $value + * @param $parameters + */ + public function validateIban($attribute, $value, $parameters) + { + + $value = strtoupper($value); + if (strlen($value) < 6) { + return false; + } + + $search = [' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; + $replace = ['', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', + '32', '33', '34', '35']; + + // take + $first = substr($value, 0, 4); + $last = substr($value, 4); + $iban = $last . $first; + $iban = str_replace($search, $replace, $iban); + $checksum = bcmod($iban, '97'); + + return (intval($checksum) === 1); + } + /** * @param $attribute * @param $value diff --git a/database/migrations/2015_06_23_050233_changes_for_v3451.php b/database/migrations/2015_06_23_050233_changes_for_v3451.php deleted file mode 100644 index 72c6f799f2..0000000000 --- a/database/migrations/2015_06_23_050233_changes_for_v3451.php +++ /dev/null @@ -1,39 +0,0 @@ -dropColumn('iban'); - } - ); - } - - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table( - 'accounts', function (Blueprint $table) { - $table->string('iban', 38)->nullable(); - } - ); - - } -} diff --git a/database/migrations/2015_07_03_102450_changes_for_v3462.php b/database/migrations/2015_07_03_102450_changes_for_v3462.php index 7dd6e4b833..930c8b0bab 100644 --- a/database/migrations/2015_07_03_102450_changes_for_v3462.php +++ b/database/migrations/2015_07_03_102450_changes_for_v3462.php @@ -1,10 +1,27 @@ dropColumn('iban'); + } + ); + } + /** * Run the migrations. * @@ -13,16 +30,10 @@ class ChangesForV3462 extends Migration public function up() { // add IBAN to accounts: - - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - // + Schema::table( + 'accounts', function (Blueprint $table) { + $table->string('iban')->nullable(); + } + ); } } diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php index 2ef6f90674..fedf19c97a 100644 --- a/database/seeds/TestDataSeeder.php +++ b/database/seeds/TestDataSeeder.php @@ -126,6 +126,7 @@ class TestDataSeeder extends Seeder 'name' => $name, 'active' => 1, 'encrypted' => 1, + 'iban' => 'GB82WEST12345698765432' ] ); foreach ($assetMeta[$index] as $name => $value) { diff --git a/resources/lang/en/form.php b/resources/lang/en/form.php index 4fbb9a44f3..4edfa130f8 100644 --- a/resources/lang/en/form.php +++ b/resources/lang/en/form.php @@ -45,6 +45,7 @@ return [ 'under' => 'Under', 'symbol' => 'Symbol', 'code' => 'Code', + 'iban' => 'IBAN', 'store_new_withdrawal' => 'Store new withdrawal', 'store_new_deposit' => 'Store new deposit', diff --git a/resources/lang/nl/form.php b/resources/lang/nl/form.php index 5ab0cd308b..f2ce23701f 100644 --- a/resources/lang/nl/form.php +++ b/resources/lang/nl/form.php @@ -45,6 +45,7 @@ return [ 'under' => 'Onder', 'symbol' => 'Symbool', 'code' => 'Code', + 'iban' => 'IBAN', 'store_new_withdrawal' => 'Nieuwe uitgave opslaan', 'store_new_deposit' => 'Nieuwe inkomsten opslaan', diff --git a/resources/twig/accounts/create.twig b/resources/twig/accounts/create.twig index da6437d0e7..c52b5321ea 100644 --- a/resources/twig/accounts/create.twig +++ b/resources/twig/accounts/create.twig @@ -29,6 +29,7 @@
    + {{ ExpandedForm.text('iban') }} {{ ExpandedForm.balance('openingBalance') }} {{ ExpandedForm.date('openingBalanceDate', phpdate('Y-m-d')) }} {{ ExpandedForm.select('accountRole', Config.get('firefly.accountRoles'),null,{'helpText' : 'Any extra options resulting from your choice can be set later.'}) }} diff --git a/resources/twig/accounts/edit.twig b/resources/twig/accounts/edit.twig index 78d846f546..32e0c55972 100644 --- a/resources/twig/accounts/edit.twig +++ b/resources/twig/accounts/edit.twig @@ -27,6 +27,7 @@

    {{ 'optionalFields'|_ }}

    + {{ ExpandedForm.text('iban') }} {% if account.accounttype.type == 'Default account' or account.accounttype.type == 'Asset account' %} {{ ExpandedForm.balance('openingBalance',null, {'currency' : openingBalance ? openingBalance.transactionCurrency : null}) }} {{ ExpandedForm.date('openingBalanceDate') }} From c303e03f762e80d71c1f46e4b15f041935aed877 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 12:52:03 +0200 Subject: [PATCH 15/60] Update model info. --- app/Models/AccountMeta.php | 2 +- app/Models/AccountType.php | 2 +- app/Models/Bill.php | 2 +- app/Models/Budget.php | 2 +- app/Models/BudgetLimit.php | 2 +- app/Models/Component.php | 2 +- app/Models/LimitRepetition.php | 2 +- app/Models/PiggyBank.php | 8 +++++++- app/Models/PiggyBankEvent.php | 2 +- app/Models/PiggyBankRepetition.php | 2 +- app/Models/Preference.php | 2 +- app/Models/Transaction.php | 2 +- app/Models/TransactionCurrency.php | 2 +- app/Models/TransactionGroup.php | 2 +- app/Models/TransactionRelation.php | 2 +- app/Models/TransactionType.php | 2 +- app/User.php | 3 +-- 17 files changed, 23 insertions(+), 18 deletions(-) diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.php index 279fe60765..1e2d0ce3c3 100644 --- a/app/Models/AccountMeta.php +++ b/app/Models/AccountMeta.php @@ -6,7 +6,7 @@ use Watson\Validating\ValidatingTrait; /** * Class AccountMeta * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php index 2148b9e961..6de461749b 100644 --- a/app/Models/AccountType.php +++ b/app/Models/AccountType.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class AccountType * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/Bill.php b/app/Models/Bill.php index 76ce0b66ad..4cc50a19da 100644 --- a/app/Models/Bill.php +++ b/app/Models/Bill.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model; * FireflyIII\Models\Bill * * @codeCoverageIgnore Class Bill - * @package FireflyIII\Models + * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $updated_at diff --git a/app/Models/Budget.php b/app/Models/Budget.php index 83ab460422..96886037f0 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class Budget * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php index 42e72dc502..97f2b16dab 100644 --- a/app/Models/BudgetLimit.php +++ b/app/Models/BudgetLimit.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class BudgetLimit * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/Component.php b/app/Models/Component.php index 84686751be..c65a9c8812 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class Component * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/LimitRepetition.php b/app/Models/LimitRepetition.php index d5fd692dae..5f6ea2a6cf 100644 --- a/app/Models/LimitRepetition.php +++ b/app/Models/LimitRepetition.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class LimitRepetition * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index ebe5379da2..cdabb6d4e8 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class PiggyBank * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at @@ -37,6 +37,12 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereOrder($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereEncrypted($value) * @property PiggyBankRepetition currentRep + * @property string $reminder + * @property integer $reminder_skip + * @property boolean $remind_me + * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereReminder($value) + * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereReminderSkip($value) + * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereRemindMe($value) */ class PiggyBank extends Model { diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php index 6b9bdceda1..98de0f04ef 100644 --- a/app/Models/PiggyBankEvent.php +++ b/app/Models/PiggyBankEvent.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class PiggyBankEvent * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php index a24066f2ee..68d2388acc 100644 --- a/app/Models/PiggyBankRepetition.php +++ b/app/Models/PiggyBankRepetition.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class PiggyBankRepetition * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/Preference.php b/app/Models/Preference.php index 56bc6f7cfd..263e7e33bc 100644 --- a/app/Models/Preference.php +++ b/app/Models/Preference.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class Preference * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 26ca48ef45..43f9928439 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -9,7 +9,7 @@ use Watson\Validating\ValidatingTrait; /** * Class Transaction * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php index 27b21f36c3..4adad9b216 100644 --- a/app/Models/TransactionCurrency.php +++ b/app/Models/TransactionCurrency.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class TransactionCurrency * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/TransactionGroup.php b/app/Models/TransactionGroup.php index bb41749ca2..6c980bfac0 100644 --- a/app/Models/TransactionGroup.php +++ b/app/Models/TransactionGroup.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class TransactionGroup * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/TransactionRelation.php b/app/Models/TransactionRelation.php index aa4d3810af..056d61fdd8 100644 --- a/app/Models/TransactionRelation.php +++ b/app/Models/TransactionRelation.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class TransactionRelation * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models */ class TransactionRelation extends Model diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php index 098d5bcfc7..886858bb2c 100644 --- a/app/Models/TransactionType.php +++ b/app/Models/TransactionType.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class TransactionType * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/User.php b/app/User.php index 408b621188..0763ff9e56 100644 --- a/app/User.php +++ b/app/User.php @@ -10,8 +10,7 @@ use Zizaco\Entrust\Traits\EntrustUserTrait; /** * Class User * - * @codeCoverageIgnore - * + * @codeCoverageIgnore * @package FireflyIII * @property integer $id * @property \Carbon\Carbon $created_at From d2c018f7daa202885af37bbff6272b2047111632 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 4 Jul 2015 07:53:37 +0200 Subject: [PATCH 16/60] First (almost) functional CSV importer. --- app/Http/Controllers/CsvController.php | 468 ++++++++++++++++-- app/Http/routes.php | 5 + config/csv.php | 113 +++++ database/seeds/TestDataSeeder.php | 8 +- resources/lang/en/firefly.php | 5 +- resources/lang/en/form.php | 1 + resources/lang/nl/form.php | 1 + .../csv/{upload.twig => column-roles.twig} | 18 +- resources/twig/csv/index.twig | 3 + resources/twig/csv/map.twig | 83 ++++ resources/twig/form/help.twig | 2 +- resources/twig/form/text.twig | 1 + 12 files changed, 664 insertions(+), 44 deletions(-) create mode 100644 config/csv.php rename resources/twig/csv/{upload.twig => column-roles.twig} (73%) create mode 100644 resources/twig/csv/map.twig diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 4e40bbeed7..0302be11ff 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -9,10 +9,16 @@ namespace FireflyIII\Http\Controllers; use Auth; +use Carbon\Carbon; +use Config; use Crypt; +use FireflyIII\Exceptions\FireflyException; +use FireflyIII\Models\Account; +use FireflyIII\Models\TransactionCurrency; use Illuminate\Http\Request; use Input; use League\Csv\Reader; +use Log; use Redirect; use Session; use View; @@ -37,75 +43,465 @@ class CsvController extends Controller } /** + * Define column roles and mapping. + * + * + * STEP THREE + * + * @return View + */ + public function columnRoles() + { + $fields = ['csv-file', 'csv-date-format', 'csv-has-headers']; + foreach ($fields as $field) { + if (!Session::has($field)) { + Session::flash('warning', 'Could not recover upload (' . $field . ' missing).'); + + return Redirect::route('csv.index'); + } + } + + $subTitle = trans('firefly.csv_process'); + $fullPath = Session::get('csv-file'); + $hasHeaders = Session::get('csv-has-headers'); + $content = file_get_contents($fullPath); + $contentDecrypted = Crypt::decrypt($content); + $reader = Reader::createFromString($contentDecrypted); + + + Log::debug('Get uploaded content from ' . $fullPath); + Log::debug('Strlen of original content is ' . strlen($contentDecrypted)); + Log::debug('MD5 of original content is ' . md5($contentDecrypted)); + + $firstRow = $reader->fetchOne(); + + $count = count($firstRow); + $headers = []; + for ($i = 1; $i <= $count; $i++) { + $headers[] = trans('firefly.csv_row') . ' #' . $i; + } + if ($hasHeaders) { + $headers = $firstRow; + } + + // example data is always the second row: + $example = $reader->fetchOne(); + $roles = []; + foreach (Config::get('csv.roles') as $name => $role) { + $roles[$name] = $role['name']; + } + ksort($roles); + + + return view('csv.column-roles', compact('roles', 'headers', 'example', 'subTitle')); + } + + /** + * This method shows the initial upload form. + * + * STEP ONE + * * @return View */ public function index() { $subTitle = trans('firefly.csv_import'); + Session::forget('csv-date-format'); + Session::forget('csv-has-headers'); + Session::forget('csv-file'); + + // can actually upload? $uploadPossible = is_writable(storage_path('upload')); $path = storage_path('upload'); - return view('csv.index', compact('subTitle', 'uploadPossible', 'path')); } /** + * Parse the file. * + * STEP FOUR + * + * @return \Illuminate\Http\RedirectResponse + */ + public function initialParse() + { + $fields = ['csv-file', 'csv-date-format', 'csv-has-headers']; + foreach ($fields as $field) { + if (!Session::has($field)) { + Session::flash('warning', 'Could not recover upload (' . $field . ' missing).'); + + return Redirect::route('csv.index'); + } + } + $configRoles = Config::get('csv.roles'); + $roles = []; + + /* + * Store all rows for each column: + */ + if (is_array(Input::get('role'))) { + $roles = []; + foreach (Input::get('role') as $index => $role) { + if ($role != '_ignore') { + $roles[$index] = $role; + } + + } + } + /* + * Go back when no roles defined: + */ + if (count($roles) === 0) { + Session::flash('warning', 'Please select some roles.'); + + return Redirect::route('csv.column-roles'); + } + Session::put('csv-roles', $roles); + + /* + * Show user map thing: + */ + if (is_array(Input::get('map'))) { + $maps = []; + foreach (Input::get('map') as $index => $map) { + $name = $roles[$index]; + if ($configRoles[$name]['mappable']) { + $maps[$index] = $name; + } + } + // redirect to map routine. + Session::put('csv-map', $maps); + + return Redirect::route('csv.map'); + } + + var_dump($roles); + var_dump($_POST); + exit; + + } + + /** + * + * Map first if necessary, + * + * STEP FIVE. + * + * @return \Illuminate\Http\RedirectResponse|View + * @throws FireflyException + */ + public function map() + { + + /* + * Make sure all fields we need are accounted for. + */ + $fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-map', 'csv-roles']; + foreach ($fields as $field) { + if (!Session::has($field)) { + Session::flash('warning', 'Could not recover upload (' . $field . ' missing).'); + + return Redirect::route('csv.index'); + } + } + + /* + * The $map array contains all columns + * the user wishes to map on to data already in the system. + */ + $map = Session::get('csv-map'); + + /* + * The "options" array contains all options the user has + * per column, where the key represents the column. + * + * For each key there is an array which in turn represents + * all the options available: grouped by ID. + */ + $options = []; + + /* + * Loop each field the user whishes to map. + */ + foreach ($map as $index => $columnRole) { + + /* + * Depending on the column role, get the relevant data from the database. + * This needs some work to be optimal. + */ + switch ($columnRole) { + default: + throw new FireflyException('Cannot map field of type "' . $columnRole . '".'); + break; + case 'account-iban': + // get content for this column. + $content = Auth::user()->accounts()->where('account_type_id', 3)->get(['accounts.*']); + $list = []; + // make user friendly list: + + foreach ($content as $account) { + $list[$account->id] = $account->name; + //if(!is_null($account->iban)) { + //$list[$account->id] .= ' ('.$account->iban.')'; + //} + } + $options[$index] = $list; + break; + case 'currency-code': + $currencies = TransactionCurrency::get(); + $list = []; + foreach ($currencies as $currency) { + $list[$currency->id] = $currency->name . ' (' . $currency->code . ')'; + } + $options[$index] = $list; + break; + case 'opposing-name': + // get content for this column. + $content = Auth::user()->accounts()->whereIn('account_type_id', [4, 5])->get(['accounts.*']); + $list = []; + // make user friendly list: + + foreach ($content as $account) { + $list[$account->id] = $account->name . ' (' . $account->accountType->type . ')'; + } + $options[$index] = $list; + break; + + } + + } + + + /* + * After these values are prepped, read the actual CSV file + */ + $content = file_get_contents(Session::get('csv-file')); + $hasHeaders = Session::get('csv-has-headers'); + $reader = Reader::createFromString(Crypt::decrypt($content)); + $values = []; + + /* + * Loop over the CSV and collect mappable data: + */ + foreach ($reader as $index => $row) { + if (($hasHeaders && $index > 1) || !$hasHeaders) { + // collect all map values + foreach ($map as $column => $irrelevant) { + // check if $irrelevant is mappable! + $values[$column][] = $row[$column]; + } + } + } + foreach ($values as $column => $found) { + $values[$column] = array_unique($found); + } + + return view('csv.map', compact('map', 'options', 'values')); + } + + /** + * Finally actually process the CSV file. + * + * STEP SEVEN + */ + public function process() + { + /* + * Make sure all fields we need are accounted for. + */ + $fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-map', 'csv-roles', 'csv-mapped']; + foreach ($fields as $field) { + if (!Session::has($field)) { + Session::flash('warning', 'Could not recover upload (' . $field . ' missing).'); + + return Redirect::route('csv.index'); + } + } + + // loop the original file again: + $content = file_get_contents(Session::get('csv-file')); + $hasHeaders = Session::get('csv-has-headers'); + $reader = Reader::createFromString(Crypt::decrypt($content)); + + // dump stuff + $dateFormat = Session::get('csv-date-format'); + $roles = Session::get('csv-roles'); + $mapped = Session::get('csv-mapped'); + + var_dump($roles); + var_dump(Session::get('csv-mapped')); + + + /* + * Loop over the CSV and collect mappable data: + */ + foreach ($reader as $index => $row) { + if (($hasHeaders && $index > 1) || !$hasHeaders) { + // this is the data we need to store the new transaction: + $amount = 0; + $amountModifier = 1; + $description = ''; + $assetAccount = null; + $opposingAccount = null; + $currency = null; + $date = null; + + foreach ($row as $index => $value) { + if (isset($roles[$index])) { + switch ($roles[$index]) { + default: + throw new FireflyException('Cannot process role "' . $roles[$index] . '"'); + break; + case 'account-iban': + // find ID in "mapped" (if present). + if (isset($mapped[$index])) { + $searchID = $mapped[$index][$value]; + $assetAccount = Account::find($searchID); + } else { + // create account + } + break; + case 'opposing-name': + // don't know yet if its going to be a + // revenue or expense account. + $opposingAccount = $value; + break; + case 'currency-code': + // find ID in "mapped" (if present). + if (isset($mapped[$index])) { + $searchValue = $mapped[$index][$value]; + $currency = TransactionCurrency::whereCode($searchValue); + } else { + // create account + } + break; + case 'date-transaction': + // unmappable: + $date = Carbon::createFromFormat($dateFormat, $value); + + break; + case 'rabo-debet-credet': + if ($value == 'D') { + $amountModifier = -1; + } + break; + case 'amount': + $amount = $value; + break; + case 'description': + $description .= ' ' . $value; + break; + case 'sepa-ct-id': + $description .= ' ' . $value; + break; + + } + } + } + // do something with all this data: + + + // do something. + var_dump($row); + + } + } + + + } + + /** + * Store the mapping the user has made. This is + * + * STEP SIX + */ + public function saveMapping() + { + /* + * Make sure all fields we need are accounted for. + */ + $fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-map', 'csv-roles']; + foreach ($fields as $field) { + if (!Session::has($field)) { + Session::flash('warning', 'Could not recover upload (' . $field . ' missing).'); + + return Redirect::route('csv.index'); + } + } + // save mapping to session. + $mapped = []; + if (!is_array(Input::get('mapping'))) { + Session::flash('warning', 'Invalid mapping.'); + + return Redirect::route('csv.map'); + } + + foreach (Input::get('mapping') as $index => $data) { + $mapped[$index] = []; + foreach ($data as $value => $mapping) { + $mapped[$index][$value] = $mapping; + } + } + Session::put('csv-mapped', $mapped); + + // proceed to process. + return Redirect::route('csv.process'); + + } + + /** + * + * This method processes the file, puts it away somewhere safe + * and sends you onwards. + * + * STEP TWO + * + * @param Request $request + * + * @return \Illuminate\Http\RedirectResponse */ public function upload(Request $request) { - // possible column roles: - $roles = [ - '(ignore this column)', - 'Asset account name', - 'Expense or revenue account name', - 'Amount', - 'Date', - 'Currency', - 'Description', - 'Category', - 'Budget', - - ]; - - if (!$request->hasFile('csv')) { Session::flash('warning', 'No file uploaded.'); return Redirect::route('csv.index'); } + + + $dateFormat = Input::get('date_format'); $hasHeaders = intval(Input::get('has_headers')) === 1; - $reader = Reader::createFromPath($request->file('csv')->getRealPath()); - $data = $reader->query(); - $data->next(); // go to first row: - - $count = count($data->current()); - $headers = []; - for ($i = 1; $i <= $count; $i++) { - $headers[] = trans('firefly.csv_row') . ' #' . $i; - } - if ($hasHeaders) { - $headers = $data->current(); - } - - // example data is always the second row: - $data->next(); - $example = $data->current(); // store file somewhere temporary (encrypted)? $time = str_replace(' ', '-', microtime()); $fileName = 'csv-upload-' . Auth::user()->id . '-' . $time . '.csv.encrypted'; $fullPath = storage_path('upload') . DIRECTORY_SEPARATOR . $fileName; $content = file_get_contents($request->file('csv')->getRealPath()); - $content = Crypt::encrypt($content); + + Log::debug('Stored uploaded content in ' . $fullPath); + Log::debug('Strlen of uploaded content is ' . strlen($content)); + Log::debug('MD5 of uploaded content is ' . md5($content)); + + $content = Crypt::encrypt($content); file_put_contents($fullPath, $content); - Session::put('latestCSVUpload', $fullPath); - $subTitle = trans('firefly.csv_process'); - return view('csv.upload', compact('headers', 'example', 'roles', 'subTitle')); + Session::put('csv-date-format', $dateFormat); + Session::put('csv-has-headers', $hasHeaders); + Session::put('csv-file', $fullPath); + + return Redirect::route('csv.column-roles'); + + + // + // + // + + // + // return view('csv.upload', compact('headers', 'example', 'roles', 'subTitle')); } } \ No newline at end of file diff --git a/app/Http/routes.php b/app/Http/routes.php index e0447eba0c..55b967497e 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -225,6 +225,11 @@ Route::group( */ Route::get('/csv', ['uses' => 'CsvController@index', 'as' => 'csv.index']); Route::post('/csv/upload', ['uses' => 'CsvController@upload', 'as' => 'csv.upload']); + Route::get('/csv/column_roles', ['uses' => 'CsvController@columnRoles', 'as' => 'csv.column-roles']); + Route::post('/csv/initial_parse', ['uses' => 'CsvController@initialParse', 'as' => 'csv.initial_parse']); + Route::get('/csv/map', ['uses' => 'CsvController@map', 'as' => 'csv.map']); + Route::post('/csv/save_mapping', ['uses' => 'CsvController@saveMapping', 'as' => 'csv.save_mapping']); + Route::get('/csv/process', ['uses' => 'CsvController@process', 'as' => 'csv.process']); /** * Currency Controller diff --git a/config/csv.php b/config/csv.php new file mode 100644 index 0000000000..6a198dc8c8 --- /dev/null +++ b/config/csv.php @@ -0,0 +1,113 @@ + [ + '_ignore' => [ + 'name' => '(ignore this column)', + 'mappable' => false, + ], + 'bill-id' => [ + 'name' => 'Bill ID (matching Firefly)', + 'mappable' => true, + ], + 'bill-name' => [ + 'name' => 'Bill name', + 'mappable' => true, + ], + 'currency-id' => [ + 'name' => 'Currency ID (matching Firefly)', + 'mappable' => true, + ], + 'currency-name' => [ + 'name' => 'Currency name (matching Firefly)', + 'mappable' => true, + ], + 'currency-code' => [ + 'name' => 'Currency code (ISO 4217)', + 'mappable' => true, + ], + 'currency-symbol' => [ + 'name' => 'Currency symbol (matching Firefly)', + 'mappable' => true, + ], + 'description' => [ + 'name' => 'Description', + 'mappable' => false, + ], + 'date-transaction' => [ + 'name' => 'Date', + 'mappable' => false, + ], + 'date-rent' => [ + 'name' => 'Rent calculation date', + 'mappable' => false, + ], + 'budget-id' => [ + 'name' => 'Budget ID (matching Firefly)', + 'mappable' => true, + ], + 'budget-name' => [ + 'name' => 'Budget name', + 'mappable' => true, + ], + 'rabo-debet-credet' => [ + 'name' => 'Rabobank specific debet/credet indicator', + 'mappable' => false, + ], + 'category-id' => [ + 'name' => 'Category ID (matching Firefly)', + 'mappable' => true, + ], + 'category-name' => [ + 'name' => 'Category name', + 'mappable' => true, + ], + 'tags-comma' => [ + 'name' => 'Tags (comma separated)', + 'mappable' => true, + ], + 'tags-space' => [ + 'name' => 'Tags (space separated)', + 'mappable' => true, + ], + 'account-id' => [ + 'name' => 'Asset account ID (matching Firefly)', + 'mappable' => true, + ], + 'account-name' => [ + 'name' => 'Asset account name', + 'mappable' => true, + ], + 'account-iban' => [ + 'name' => 'Asset account IBAN', + 'mappable' => true, + ], + 'opposing-id' => [ + 'name' => 'Expense or revenue account ID (matching Firefly)', + 'mappable' => true, + ], + 'opposing-name' => [ + 'name' => 'Expense or revenue account name', + 'mappable' => true, + ], + 'opposing-iban' => [ + 'name' => 'Expense or revenue account IBAN', + 'mappable' => true, + ], + 'amount' => [ + 'name' => 'Amount', + 'mappable' => false, + ], + 'sepa-ct-id' => [ + 'name' => 'SEPA Credit Transfer end-to-end ID', + 'mappable' => false, + ], + 'sepa-ct-op' => [ + 'name' => 'SEPA Credit Transfer opposing account', + 'mappable' => false, + ], + 'sepa-db' => [ + 'name' => 'SEPA Direct Debet', + 'mappable' => false, + ], + ] +]; \ No newline at end of file diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php index 2ef6f90674..d8afef1045 100644 --- a/database/seeds/TestDataSeeder.php +++ b/database/seeds/TestDataSeeder.php @@ -98,7 +98,7 @@ class TestDataSeeder extends Seeder protected function createAssetAccounts() { - $assets = ['MyBank Checking Account', 'Savings', 'Shared', 'Creditcard']; + $assets = ['MyBank Checking Account', 'Savings', 'Shared', 'Creditcard', 'Emergencies', 'STE']; $assetMeta = [ [ 'accountRole' => 'defaultAsset', @@ -114,6 +114,12 @@ class TestDataSeeder extends Seeder 'ccMonthlyPaymentDate' => '2015-05-27', 'ccType' => 'monthlyFull' ], + [ + 'accountRole' => 'savingAsset', + ], + [ + 'accountRole' => 'savingAsset', + ], ]; diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php index d58d2cc632..071f352e50 100644 --- a/resources/lang/en/firefly.php +++ b/resources/lang/en/firefly.php @@ -26,8 +26,11 @@ return [ 'csv_upload_form' => 'Upload form', 'upload_csv_file' => 'Upload CSV file', 'csv_header_help' => 'Check this when bla bla', + 'csv_date_help' => 'Date time format in your CSV. Follow the format like this' . + ' page indicates.', 'csv_row' => 'row', - 'upload_not_writeable' => 'Cannot write to the path mentioned here. Cannot upload', + 'upload_not_writeable' => 'Cannot write to the path mentioned here. Cannot upload', // create new stuff: 'create_new_withdrawal' => 'Create new withdrawal', diff --git a/resources/lang/en/form.php b/resources/lang/en/form.php index 8b9530ec10..ef9596096f 100644 --- a/resources/lang/en/form.php +++ b/resources/lang/en/form.php @@ -47,6 +47,7 @@ return [ 'code' => 'Code', 'csv' => 'CSV file', 'has_headers' => 'Headers', + 'date_format' => 'Date format', 'store_new_withdrawal' => 'Store new withdrawal', 'store_new_deposit' => 'Store new deposit', diff --git a/resources/lang/nl/form.php b/resources/lang/nl/form.php index 837ec1d3a8..82b5667a69 100644 --- a/resources/lang/nl/form.php +++ b/resources/lang/nl/form.php @@ -47,6 +47,7 @@ return [ 'code' => 'Code', 'csv' => 'CSV-bestand', 'has_headers' => 'Eerste rij zijn kolomnamen', + 'date_format' => 'Datumformaat', 'store_new_withdrawal' => 'Nieuwe uitgave opslaan', 'store_new_deposit' => 'Nieuwe inkomsten opslaan', diff --git a/resources/twig/csv/upload.twig b/resources/twig/csv/column-roles.twig similarity index 73% rename from resources/twig/csv/upload.twig rename to resources/twig/csv/column-roles.twig index 4b0b34cd07..6325ada631 100644 --- a/resources/twig/csv/upload.twig +++ b/resources/twig/csv/column-roles.twig @@ -20,7 +20,9 @@
    - {{ 'csv_process_text'|_ }} +

    {{ 'csv_process_text'|_ }}

    +

    {{ 'csv_more_information' }}

    +

    {{ 'csv_more_information_text'|_ }}

    @@ -39,7 +41,8 @@
    - +
    + @@ -52,16 +55,21 @@ {% endfor %}
    {{ 'cvs_column_name'|_ }}{{ header }} {{ example[index] }} - {{ Form.select(('role_'~index), roles) }} + {{ Form.select(('role['~index~']'), roles) }} - {{ Form.checkbox(('map_'~index),false) }} + {{ Form.checkbox(('map['~index~']'),1,false) }}
    - +

    + +

    +
    diff --git a/resources/twig/csv/index.twig b/resources/twig/csv/index.twig index 023d0b2fe0..79e3b53add 100644 --- a/resources/twig/csv/index.twig +++ b/resources/twig/csv/index.twig @@ -21,6 +21,8 @@
    {{ 'csv_index_text'|_ }} +

    {{ 'csv_more_information' }}

    + {{ 'csv_more_information_text'|_ }}
    @@ -44,6 +46,7 @@ {{ ExpandedForm.checkbox('has_headers',false,null,{helpText: 'csv_header_help'|_}) }} + {{ ExpandedForm.text('date_format','Ymd',{helpText: 'csv_date_help'|_}) }} {{ ExpandedForm.file('csv') }} diff --git a/resources/twig/csv/map.twig b/resources/twig/csv/map.twig new file mode 100644 index 0000000000..78ed891fa8 --- /dev/null +++ b/resources/twig/csv/map.twig @@ -0,0 +1,83 @@ +{% extends "./layout/default.twig" %} + +{% block breadcrumbs %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +{% endblock %} + +{% block content %} + + +
    +
    +
    +
    +

    {{ 'csv_map'|_ }}

    + + +
    + +
    + +
    +
    +

    {{ 'csv_map_text'|_ }}

    +

    {{ 'csv_more_information' }}

    + +

    {{ 'csv_more_information_text'|_ }}

    +
    +
    + +
    +
    +
    + + + {% for index,columnName in map %} + +
    +
    +
    +
    +

    {{ columnName }}

    + + +
    + +
    + +
    +
    + + + + + + + {% for value in values[index] %} + + + + + {% endfor %} + + + +
    {{ 'cvs_field_value'|_ }}{{ 'csv_field_mapped_to'|_ }}
    {{ value }} + {{ Form.select('mapping['~index~']['~value~']',options[index]) }} +
    + + +
    +
    +
    +
    + {% endfor %} +

    + +

    +
    + + +{% endblock %} diff --git a/resources/twig/form/help.twig b/resources/twig/form/help.twig index e1e2d011ea..d402fb623b 100644 --- a/resources/twig/form/help.twig +++ b/resources/twig/form/help.twig @@ -1,3 +1,3 @@ {% if options.helpText %} -

    {{ options.helpText }}

    +

    {{ options.helpText|raw }}

    {% endif %} diff --git a/resources/twig/form/text.twig b/resources/twig/form/text.twig index 0b199f9117..c2f890c0fe 100644 --- a/resources/twig/form/text.twig +++ b/resources/twig/form/text.twig @@ -3,6 +3,7 @@
    {{ Form.input('text', name, value, options) }} + {% include 'form/help.twig' %} {% include 'form/feedback.twig' %}
    From 65122f014433dbf1549968929e7e42de30cc399f Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 06:18:02 +0200 Subject: [PATCH 17/60] Greatly expanded the CSV routine. --- app/Helpers/Csv/Converter/AccountIban.php | 46 +++ app/Helpers/Csv/Converter/Amount.php | 32 ++ app/Helpers/Csv/Converter/BasicConverter.php | 101 +++++ .../Csv/Converter/ConverterInterface.php | 51 +++ app/Helpers/Csv/Converter/CurrencyCode.php | 27 ++ app/Helpers/Csv/Converter/Date.php | 33 ++ app/Helpers/Csv/Converter/Ignore.php | 22 ++ .../Csv/Converter/RabobankDebetCredit.php | 27 ++ app/Helpers/Csv/Data.php | 235 ++++++++++++ app/Helpers/Csv/DataGrabber.php | 54 +++ app/Helpers/Csv/Importer.php | 175 +++++++++ app/Helpers/Csv/Wizard.php | 178 +++++++++ app/Helpers/Csv/WizardInterface.php | 58 +++ app/Http/Controllers/CsvController.php | 352 ++++++++---------- app/Http/routes.php | 3 + app/Providers/FireflyServiceProvider.php | 3 + config/csv.php | 34 +- resources/twig/csv/column-roles.twig | 5 +- resources/twig/csv/download-config.twig | 40 ++ resources/twig/csv/index.twig | 5 +- resources/twig/csv/map.twig | 7 +- resources/twig/error.twig | 4 +- 22 files changed, 1282 insertions(+), 210 deletions(-) create mode 100644 app/Helpers/Csv/Converter/AccountIban.php create mode 100644 app/Helpers/Csv/Converter/Amount.php create mode 100644 app/Helpers/Csv/Converter/BasicConverter.php create mode 100644 app/Helpers/Csv/Converter/ConverterInterface.php create mode 100644 app/Helpers/Csv/Converter/CurrencyCode.php create mode 100644 app/Helpers/Csv/Converter/Date.php create mode 100644 app/Helpers/Csv/Converter/Ignore.php create mode 100644 app/Helpers/Csv/Converter/RabobankDebetCredit.php create mode 100644 app/Helpers/Csv/Data.php create mode 100644 app/Helpers/Csv/DataGrabber.php create mode 100644 app/Helpers/Csv/Importer.php create mode 100644 app/Helpers/Csv/Wizard.php create mode 100644 app/Helpers/Csv/WizardInterface.php create mode 100644 resources/twig/csv/download-config.twig diff --git a/app/Helpers/Csv/Converter/AccountIban.php b/app/Helpers/Csv/Converter/AccountIban.php new file mode 100644 index 0000000000..6aa7494c62 --- /dev/null +++ b/app/Helpers/Csv/Converter/AccountIban.php @@ -0,0 +1,46 @@ +mapped[$this->index][$this->value])) { + $account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]); + } else { + // find or create new account: + $accountType = AccountType::where('type', 'Asset account')->first(); + $account = Account::firstOrCreateEncrypted( + [ + 'name' => $this->value, + //'iban' => $this->value, + 'user_id' => Auth::user()->id, + 'account_type_id' => $accountType->id + ] + ); + } + + return $account; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/Amount.php b/app/Helpers/Csv/Converter/Amount.php new file mode 100644 index 0000000000..de2e9d5b08 --- /dev/null +++ b/app/Helpers/Csv/Converter/Amount.php @@ -0,0 +1,32 @@ +value)) { + return $this->value; + } + + return 0; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/BasicConverter.php b/app/Helpers/Csv/Converter/BasicConverter.php new file mode 100644 index 0000000000..ff19555071 --- /dev/null +++ b/app/Helpers/Csv/Converter/BasicConverter.php @@ -0,0 +1,101 @@ +data; + } + + /** + * @param array $data + */ + public function setData($data) + { + $this->data = $data; + } + + /** + * @return mixed + */ + public function getIndex() + { + return $this->index; + } + + /** + * @param mixed $index + */ + public function setIndex($index) + { + $this->index = $index; + } + + /** + * @return array + */ + public function getMapped() + { + return $this->mapped; + } + + /** + * @param array $mapped + */ + public function setMapped($mapped) + { + $this->mapped = $mapped; + } + + /** + * @return mixed + */ + public function getRole() + { + return $this->role; + } + + /** + * @param mixed $role + */ + public function setRole($role) + { + $this->role = $role; + } + + /** + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * @param mixed $value + */ + public function setValue($value) + { + $this->value = $value; + } + + +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/ConverterInterface.php b/app/Helpers/Csv/Converter/ConverterInterface.php new file mode 100644 index 0000000000..3efd70555c --- /dev/null +++ b/app/Helpers/Csv/Converter/ConverterInterface.php @@ -0,0 +1,51 @@ +mapped[$this->index][$this->value])) { + $currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]); + } else { + $currency = TransactionCurrency::whereCode($this->value)->first(); + } + + return $currency; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/Date.php b/app/Helpers/Csv/Converter/Date.php new file mode 100644 index 0000000000..df79825a62 --- /dev/null +++ b/app/Helpers/Csv/Converter/Date.php @@ -0,0 +1,33 @@ +value); + + return $date; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/Ignore.php b/app/Helpers/Csv/Converter/Ignore.php new file mode 100644 index 0000000000..b9c7607d47 --- /dev/null +++ b/app/Helpers/Csv/Converter/Ignore.php @@ -0,0 +1,22 @@ +value == 'D') { + return -1; + } + + return 1; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Data.php b/app/Helpers/Csv/Data.php new file mode 100644 index 0000000000..149cbda6e5 --- /dev/null +++ b/app/Helpers/Csv/Data.php @@ -0,0 +1,235 @@ +sessionHasHeaders(); + $this->sessionDateFormat(); + $this->sessionCsvFileLocation(); + $this->sessionMap(); + $this->sessionRoles(); + $this->sessionMapped(); + } + + protected function sessionHasHeaders() + { + if (Session::has('csv-has-headers')) { + $this->hasHeaders = (bool)Session::get('csv-has-headers'); + } + } + + protected function sessionDateFormat() + { + if (Session::has('csv-date-format')) { + $this->dateFormat = (string)Session::get('csv-date-format'); + } + } + + protected function sessionCsvFileLocation() + { + if (Session::has('csv-file')) { + $this->csvFileLocation = (string)Session::get('csv-file'); + } + } + + protected function sessionMap() + { + if (Session::has('csv-map')) { + $this->map = (array)Session::get('csv-map'); + } + } + + protected function sessionRoles() + { + if (Session::has('csv-roles')) { + $this->roles = (array)Session::get('csv-roles'); + } + } + + protected function sessionMapped() + { + if (Session::has('csv-mapped')) { + $this->mapped = (array)Session::get('csv-mapped'); + } + } + + /** + * @return string + */ + public function getDateFormat() + { + return $this->dateFormat; + } + + /** + * @param mixed $dateFormat + */ + public function setDateFormat($dateFormat) + { + Session::put('csv-date-format', $dateFormat); + $this->dateFormat = $dateFormat; + } + + /** + * @return bool + */ + public function getHasHeaders() + { + return $this->hasHeaders; + } + + /** + * @param bool $hasHeaders + */ + public function setHasHeaders($hasHeaders) + { + Session::put('csv-has-headers', $hasHeaders); + $this->hasHeaders = $hasHeaders; + } + + /** + * @return array + */ + public function getMap() + { + return $this->map; + } + + /** + * @param array $map + */ + public function setMap(array $map) + { + Session::put('csv-map', $map); + $this->map = $map; + } + + /** + * @return array + */ + public function getMapped() + { + return $this->mapped; + } + + /** + * @param array $mapped + */ + public function setMapped(array $mapped) + { + Session::put('csv-mapped', $mapped); + $this->mapped = $mapped; + } + + /** + * @return Reader + */ + public function getReader() + { + + if (strlen($this->csvFileContent) === 0) { + $this->loadCsvFile(); + } + + if (is_null($this->reader)) { + $this->reader = Reader::createFromString($this->getCsvFileContent()); + } + + return $this->reader; + } + + protected function loadCsvFile() + { + $file = $this->getCsvFileLocation(); + $content = file_get_contents($file); + $contentDecrypted = Crypt::decrypt($content); + $this->setCsvFileContent($contentDecrypted); + } + + /** + * @return string + */ + public function getCsvFileLocation() + { + return $this->csvFileLocation; + } + + /** + * @param string $csvFileLocation + */ + public function setCsvFileLocation($csvFileLocation) + { + Session::put('csv-file', $csvFileLocation); + $this->csvFileLocation = $csvFileLocation; + } + + /** + * @return string + */ + public function getCsvFileContent() + { + return $this->csvFileContent; + } + + /** + * @param string $csvFileContent + */ + public function setCsvFileContent($csvFileContent) + { + $this->csvFileContent = $csvFileContent; + } + + /** + * @return array + */ + public function getRoles() + { + return $this->roles; + } + + /** + * @param array $roles + */ + public function setRoles(array $roles) + { + Session::put('csv-roles', $roles); + $this->roles = $roles; + } + + +} \ No newline at end of file diff --git a/app/Helpers/Csv/DataGrabber.php b/app/Helpers/Csv/DataGrabber.php new file mode 100644 index 0000000000..93260b82c4 --- /dev/null +++ b/app/Helpers/Csv/DataGrabber.php @@ -0,0 +1,54 @@ +accounts()->with( + ['accountmeta' => function (HasMany $query) { + $query->where('name', 'accountRole'); + }] + )->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')->get(['accounts.*']); + + $list = []; + /** @var Account $account */ + foreach ($result as $account) { + $list[$account->id] = $account->name; + } + + return $list; + } + + /** + * @return array + */ + public function getCurrencies() + { + $currencies = TransactionCurrency::get(); + $list = []; + foreach ($currencies as $currency) { + $list[$currency->id] = $currency->name . ' (' . $currency->code . ')'; + } + + return $list; + } + +} \ No newline at end of file diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php new file mode 100644 index 0000000000..eeda8892c5 --- /dev/null +++ b/app/Helpers/Csv/Importer.php @@ -0,0 +1,175 @@ +map = $this->data->getMap(); + $this->roles = $this->data->getRoles(); + $this->mapped = $this->data->getMapped(); + foreach ($this->data->getReader() as $row) { + $this->importRow($row); + } + } + + /** + * @param $row + * + * @throws FireflyException + */ + protected function importRow($row) + { + /* + * These fields are necessary to create a new transaction journal. Some are optional: + */ + $data = $this->getFiller(); + foreach ($row as $index => $value) { + $role = isset($this->roles[$index]) ? $this->roles[$index] : '_ignore'; + $class = Config::get('csv.roles.' . $role . '.converter'); + $field = Config::get('csv.roles.' . $role . '.field'); + + if (is_null($class)) { + throw new FireflyException('No converter for field of type "' . $role . '".'); + } + if (is_null($field)) { + throw new FireflyException('No place to store value of type "' . $role . '".'); + } + /** @var ConverterInterface $converter */ + $converter = App::make('FireflyIII\Helpers\Csv\Converter\\' . $class); + $converter->setData($data); // the complete array so far. + $converter->setIndex($index); + $converter->setValue($value); + $converter->setRole($role); + // if (is_array($field)) { + // $convertResult = $converter->convert(); + // foreach ($field as $fieldName) { + // $data[$fieldName] = $convertResult[$fieldName]; + // } + // } else { + $data[$field] = $converter->convert(); + // } + + + // case 'description': + // $data['description'] .= ' ' . $value; + // break; + // case '_ignore': + // ignore! (duh) + // break; + // case 'account-iban': + // $data['asset-account'] = $this->findAssetAccount($index, $value); + // break; + // case 'currency-code': + // $data['currency'] = $this->findCurrency($index, $value, $role); + // break; + // case 'date-transaction': + // $data['date'] = $this->parseDate($value); + // break; + // case 'rabo-debet-credit': + // $data['amount-modifier'] = $this->parseRaboDebetCredit($value); + // break; + // default: + // throw new FireflyException('Cannot process row of type "' . $role . '".'); + // break; + + + } + $data = $this->postProcess($data); + var_dump($data); + + + + exit; + + } + + /** + * @return array + */ + protected function getFiller() + { + return [ + 'description' => '', + 'asset-account' => null, + 'date' => null, + 'currency' => null, + 'amount' => null, + 'amount-modifier' => 1, + 'ignored' => null, + ]; + + } + + /** + * @param array $data + * + * @return array + */ + protected function postProcess(array $data) + { + $data['description'] = trim($data['description']); + + + return $data; + } + + /** + * @param Data $data + */ + public function setData($data) + { + $this->data = $data; + } + + /** + * @param $value + * + * @return Carbon + */ + protected function parseDate($value) + { + return Carbon::createFromFormat($this->data->getDateFormat(), $value); + } + +} \ No newline at end of file diff --git a/app/Helpers/Csv/Wizard.php b/app/Helpers/Csv/Wizard.php new file mode 100644 index 0000000000..b08e10bc55 --- /dev/null +++ b/app/Helpers/Csv/Wizard.php @@ -0,0 +1,178 @@ + $row) { + if (($hasHeaders && $index > 1) || !$hasHeaders) { + // collect all map values + foreach ($map as $column => $irrelevant) { + // check if $irrelevant is mappable! + $values[$column][] = $row[$column]; + } + } + } + /* + * Make each one unique. + */ + foreach ($values as $column => $found) { + $values[$column] = array_unique($found); + } + + return $values; + } + + + /** + * @param array $roles + * @param mixed $map + * + * @return array + */ + public function processSelectedMapping(array $roles, $map) + { + $configRoles = Config::get('csv.roles'); + $maps = []; + + + if (is_array($map)) { + foreach ($map as $index => $field) { + if (isset($roles[$index])) { + $name = $roles[$index]; + if ($configRoles[$name]['mappable']) { + $maps[$index] = $name; + } + } + } + } + + return $maps; + + } + + /** + * @param mixed $input + * + * @return array + */ + public function processSelectedRoles($input) + { + $roles = []; + + + /* + * Store all rows for each column: + */ + if (is_array($input)) { + foreach ($input as $index => $role) { + if ($role != '_ignore') { + $roles[$index] = $role; + } + } + } + + return $roles; + } + + /** + * @param array $fields + * + * @return bool + */ + public function sessionHasValues(array $fields) + { + foreach ($fields as $field) { + if (!Session::has($field)) { + return false; + } + } + + return true; + } + + + /** + * @param array $map + * + * @return array + * @throws FireflyException + */ + public function showOptions(array $map) + { + $dataGrabber = new DataGrabber; + $options = []; + foreach ($map as $index => $columnRole) { + + /* + * Depending on the column role, get the relevant data from the database. + * This needs some work to be optimal. + */ + switch ($columnRole) { + default: + throw new FireflyException('Cannot map field of type "' . $columnRole . '".'); + break; + case 'account-iban': + $set = $dataGrabber->getAssetAccounts(); + break; + case 'currency-code': + $set = $dataGrabber->getCurrencies(); + break; + } + + /* + * Make select list kind of thing: + */ + + $options[$index] = $set; + } + + + return $options; + } + + /** + * @param $path + * + * @return string + */ + public function storeCsvFile($path) + { + $time = str_replace(' ', '-', microtime()); + $fileName = 'csv-upload-' . Auth::user()->id . '-' . $time . '.csv.encrypted'; + $fullPath = storage_path('upload') . DIRECTORY_SEPARATOR . $fileName; + $content = file_get_contents($path); + $contentEncrypted = Crypt::encrypt($content); + file_put_contents($fullPath, $contentEncrypted); + + return $fullPath; + + + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/WizardInterface.php b/app/Helpers/Csv/WizardInterface.php new file mode 100644 index 0000000000..bd938ad248 --- /dev/null +++ b/app/Helpers/Csv/WizardInterface.php @@ -0,0 +1,58 @@ +wizard = App::make('FireflyIII\Helpers\Csv\WizardInterface'); + $this->data = App::make('FireflyIII\Helpers\Csv\Data'); + } /** @@ -52,48 +62,81 @@ class CsvController extends Controller */ public function columnRoles() { - $fields = ['csv-file', 'csv-date-format', 'csv-has-headers']; - foreach ($fields as $field) { - if (!Session::has($field)) { - Session::flash('warning', 'Could not recover upload (' . $field . ' missing).'); - return Redirect::route('csv.index'); - } + $fields = ['csv-file', 'csv-date-format', 'csv-has-headers']; + if (!$this->wizard->sessionHasValues($fields)) { + Session::flash('warning', 'Could not recover upload.'); + + return Redirect::route('csv.index'); } - $subTitle = trans('firefly.csv_process'); - $fullPath = Session::get('csv-file'); - $hasHeaders = Session::get('csv-has-headers'); - $content = file_get_contents($fullPath); - $contentDecrypted = Crypt::decrypt($content); - $reader = Reader::createFromString($contentDecrypted); + $subTitle = trans('firefly.csv_process'); + $firstRow = $this->data->getReader()->fetchOne(); + $count = count($firstRow); + $headers = []; + $example = $this->data->getReader()->fetchOne(); + $availableRoles = []; + $roles = $this->data->getRoles(); + $map = $this->data->getMap(); - - Log::debug('Get uploaded content from ' . $fullPath); - Log::debug('Strlen of original content is ' . strlen($contentDecrypted)); - Log::debug('MD5 of original content is ' . md5($contentDecrypted)); - - $firstRow = $reader->fetchOne(); - - $count = count($firstRow); - $headers = []; for ($i = 1; $i <= $count; $i++) { $headers[] = trans('firefly.csv_row') . ' #' . $i; } - if ($hasHeaders) { + if ($this->data->getHasHeaders()) { $headers = $firstRow; } - // example data is always the second row: - $example = $reader->fetchOne(); - $roles = []; foreach (Config::get('csv.roles') as $name => $role) { - $roles[$name] = $role['name']; + $availableRoles[$name] = $role['name']; } - ksort($roles); + ksort($availableRoles); + return view('csv.column-roles', compact('availableRoles', 'map', 'roles', 'headers', 'example', 'subTitle')); + } - return view('csv.column-roles', compact('roles', 'headers', 'example', 'subTitle')); + /** + * Optional download of mapping. + * + * STEP FOUR THREE-A + */ + public function downloadConfig() + { + $fields = ['csv-date-format', 'csv-has-headers']; + if (!$this->wizard->sessionHasValues($fields)) { + Session::flash('warning', 'Could not recover upload.'); + + return Redirect::route('csv.index'); + } + $data = [ + 'date-format' => Session::get('date-format'), + 'has-headers' => Session::get('csv-has-headers') + ]; + // $fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-map', 'csv-roles', 'csv-mapped']; + if (Session::has('csv-map')) { + $data['map'] = Session::get('csv-map'); + } + if (Session::has('csv-roles')) { + $data['roles'] = Session::get('csv-roles'); + } + if (Session::has('csv-mapped')) { + $data['mapped'] = Session::get('csv-mapped'); + } + + $result = json_encode($data, JSON_PRETTY_PRINT); + $name = 'csv-configuration-' . date('Y-m-d') . '.json'; + + header('Content-disposition: attachment; filename=' . $name); + header('Content-type: application/json'); + echo $result; + exit; + } + + /** + * @return View + */ + public function downloadConfigPage() + { + return view('csv.download-config'); } /** @@ -110,6 +153,9 @@ class CsvController extends Controller Session::forget('csv-date-format'); Session::forget('csv-has-headers'); Session::forget('csv-file'); + Session::forget('csv-map'); + Session::forget('csv-roles'); + Session::forget('csv-mapped'); // can actually upload? @@ -129,28 +175,20 @@ class CsvController extends Controller public function initialParse() { $fields = ['csv-file', 'csv-date-format', 'csv-has-headers']; - foreach ($fields as $field) { - if (!Session::has($field)) { - Session::flash('warning', 'Could not recover upload (' . $field . ' missing).'); + if (!$this->wizard->sessionHasValues($fields)) { + Session::flash('warning', 'Could not recover upload.'); - return Redirect::route('csv.index'); - } + return Redirect::route('csv.index'); } - $configRoles = Config::get('csv.roles'); - $roles = []; - /* - * Store all rows for each column: - */ - if (is_array(Input::get('role'))) { - $roles = []; - foreach (Input::get('role') as $index => $role) { - if ($role != '_ignore') { - $roles[$index] = $role; - } - } - } + // process given roles and mapping: + $roles = $this->wizard->processSelectedRoles(Input::get('role')); + $maps = $this->wizard->processSelectedMapping($roles, Input::get('map')); + + Session::put('csv-map', $maps); + Session::put('csv-roles', $roles); + /* * Go back when no roles defined: */ @@ -159,28 +197,19 @@ class CsvController extends Controller return Redirect::route('csv.column-roles'); } - Session::put('csv-roles', $roles); /* - * Show user map thing: + * Continue with map specification when necessary. */ - if (is_array(Input::get('map'))) { - $maps = []; - foreach (Input::get('map') as $index => $map) { - $name = $roles[$index]; - if ($configRoles[$name]['mappable']) { - $maps[$index] = $name; - } - } - // redirect to map routine. - Session::put('csv-map', $maps); - + if (count($maps) > 0) { return Redirect::route('csv.map'); } - var_dump($roles); - var_dump($_POST); - exit; + /* + * Or simply start processing. + */ + + return Redirect::route('csv.process'); } @@ -200,106 +229,42 @@ class CsvController extends Controller * Make sure all fields we need are accounted for. */ $fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-map', 'csv-roles']; - foreach ($fields as $field) { - if (!Session::has($field)) { - Session::flash('warning', 'Could not recover upload (' . $field . ' missing).'); + if (!$this->wizard->sessionHasValues($fields)) { + Session::flash('warning', 'Could not recover upload.'); - return Redirect::route('csv.index'); - } + return Redirect::route('csv.index'); } - /* - * The $map array contains all columns - * the user wishes to map on to data already in the system. - */ - $map = Session::get('csv-map'); - /* * The "options" array contains all options the user has * per column, where the key represents the column. * * For each key there is an array which in turn represents * all the options available: grouped by ID. + * + * Aka: + * + * options[column index] = [ + * field id => field identifier. + * ] */ - $options = []; - - /* - * Loop each field the user whishes to map. - */ - foreach ($map as $index => $columnRole) { - - /* - * Depending on the column role, get the relevant data from the database. - * This needs some work to be optimal. - */ - switch ($columnRole) { - default: - throw new FireflyException('Cannot map field of type "' . $columnRole . '".'); - break; - case 'account-iban': - // get content for this column. - $content = Auth::user()->accounts()->where('account_type_id', 3)->get(['accounts.*']); - $list = []; - // make user friendly list: - - foreach ($content as $account) { - $list[$account->id] = $account->name; - //if(!is_null($account->iban)) { - //$list[$account->id] .= ' ('.$account->iban.')'; - //} - } - $options[$index] = $list; - break; - case 'currency-code': - $currencies = TransactionCurrency::get(); - $list = []; - foreach ($currencies as $currency) { - $list[$currency->id] = $currency->name . ' (' . $currency->code . ')'; - } - $options[$index] = $list; - break; - case 'opposing-name': - // get content for this column. - $content = Auth::user()->accounts()->whereIn('account_type_id', [4, 5])->get(['accounts.*']); - $list = []; - // make user friendly list: - - foreach ($content as $account) { - $list[$account->id] = $account->name . ' (' . $account->accountType->type . ')'; - } - $options[$index] = $list; - break; - - } - + try { + $options = $this->wizard->showOptions($this->data->getMap()); + } catch (FireflyException $e) { + return view('error', ['message' => $e->getMessage()]); } - /* * After these values are prepped, read the actual CSV file */ - $content = file_get_contents(Session::get('csv-file')); - $hasHeaders = Session::get('csv-has-headers'); - $reader = Reader::createFromString(Crypt::decrypt($content)); - $values = []; + $reader = $this->data->getReader(); + $map = $this->data->getMap(); + $hasHeaders = $this->data->getHasHeaders(); + $values = $this->wizard->getMappableValues($reader, $map, $hasHeaders); + $map = $this->data->getMap(); + $mapped = $this->data->getMapped(); - /* - * Loop over the CSV and collect mappable data: - */ - foreach ($reader as $index => $row) { - if (($hasHeaders && $index > 1) || !$hasHeaders) { - // collect all map values - foreach ($map as $column => $irrelevant) { - // check if $irrelevant is mappable! - $values[$column][] = $row[$column]; - } - } - } - foreach ($values as $column => $found) { - $values[$column] = array_unique($found); - } - - return view('csv.map', compact('map', 'options', 'values')); + return view('csv.map', compact('map', 'options', 'values', 'mapped')); } /** @@ -313,14 +278,24 @@ class CsvController extends Controller * Make sure all fields we need are accounted for. */ $fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-map', 'csv-roles', 'csv-mapped']; - foreach ($fields as $field) { - if (!Session::has($field)) { - Session::flash('warning', 'Could not recover upload (' . $field . ' missing).'); + if (!$this->wizard->sessionHasValues($fields)) { + Session::flash('warning', 'Could not recover upload.'); - return Redirect::route('csv.index'); - } + return Redirect::route('csv.index'); } + // + $importer = new Importer; + $importer->setData($this->data); + try { + $importer->run(); + } catch (FireflyException $e) { + return view('error', ['message' => $e->getMessage()]); + } + + + exit; + // loop the original file again: $content = file_get_contents(Session::get('csv-file')); $hasHeaders = Session::get('csv-has-headers'); @@ -331,10 +306,6 @@ class CsvController extends Controller $roles = Session::get('csv-roles'); $mapped = Session::get('csv-mapped'); - var_dump($roles); - var_dump(Session::get('csv-mapped')); - - /* * Loop over the CSV and collect mappable data: */ @@ -424,13 +395,12 @@ class CsvController extends Controller * Make sure all fields we need are accounted for. */ $fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-map', 'csv-roles']; - foreach ($fields as $field) { - if (!Session::has($field)) { - Session::flash('warning', 'Could not recover upload (' . $field . ' missing).'); + if (!$this->wizard->sessionHasValues($fields)) { + Session::flash('warning', 'Could not recover upload.'); - return Redirect::route('csv.index'); - } + return Redirect::route('csv.index'); } + // save mapping to session. $mapped = []; if (!is_array(Input::get('mapping'))) { @@ -448,7 +418,7 @@ class CsvController extends Controller Session::put('csv-mapped', $mapped); // proceed to process. - return Redirect::route('csv.process'); + return Redirect::route('csv.download-config-page'); } @@ -468,40 +438,46 @@ class CsvController extends Controller if (!$request->hasFile('csv')) { Session::flash('warning', 'No file uploaded.'); - return Redirect::route('csv.index'); } - + /* + * Store CSV and put in session. + */ + $fullPath = $this->wizard->storeCsvFile($request->file('csv')->getRealPath()); $dateFormat = Input::get('date_format'); $hasHeaders = intval(Input::get('has_headers')) === 1; - // store file somewhere temporary (encrypted)? - $time = str_replace(' ', '-', microtime()); - $fileName = 'csv-upload-' . Auth::user()->id . '-' . $time . '.csv.encrypted'; - $fullPath = storage_path('upload') . DIRECTORY_SEPARATOR . $fileName; - $content = file_get_contents($request->file('csv')->getRealPath()); - - Log::debug('Stored uploaded content in ' . $fullPath); - Log::debug('Strlen of uploaded content is ' . strlen($content)); - Log::debug('MD5 of uploaded content is ' . md5($content)); - - $content = Crypt::encrypt($content); - file_put_contents($fullPath, $content); + $map = []; + $roles = []; + $mapped = []; - Session::put('csv-date-format', $dateFormat); - Session::put('csv-has-headers', $hasHeaders); - Session::put('csv-file', $fullPath); + /* + * Process config file if present. + */ + if ($request->hasFile('csv_config')) { + + $data = file_get_contents($request->file('csv_config')->getRealPath()); + $json = json_decode($data, true); + + if (!is_null($json)) { + $dateFormat = isset($json['date-format']) ? $json['date-format'] : $dateFormat; + $hasHeaders = isset($json['has-headers']) ? $json['has-headers'] : $hasHeaders; + $map = isset($json['map']) && is_array($json['map']) ? $json['map'] : []; + $mapped = isset($json['mapped']) && is_array($json['mapped']) ? $json['mapped'] : []; + $roles = isset($json['roles']) && is_array($json['roles']) ? $json['roles'] : []; + } + } + + $this->data->setCsvFileLocation($fullPath); + $this->data->setDateFormat($dateFormat); + $this->data->setHasHeaders($hasHeaders); + $this->data->setMap($map); + $this->data->setMapped($mapped); + $this->data->setRoles($roles); + return Redirect::route('csv.column-roles'); - - // - // - // - - // - // return view('csv.upload', compact('headers', 'example', 'roles', 'subTitle')); - } } \ No newline at end of file diff --git a/app/Http/routes.php b/app/Http/routes.php index 55b967497e..a391ead7e5 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -228,7 +228,10 @@ Route::group( Route::get('/csv/column_roles', ['uses' => 'CsvController@columnRoles', 'as' => 'csv.column-roles']); Route::post('/csv/initial_parse', ['uses' => 'CsvController@initialParse', 'as' => 'csv.initial_parse']); Route::get('/csv/map', ['uses' => 'CsvController@map', 'as' => 'csv.map']); + Route::get('/csv/download-config', ['uses' => 'CsvController@downloadConfig', 'as' => 'csv.download-config']); + Route::get('/csv/download', ['uses' => 'CsvController@downloadConfigPage', 'as' => 'csv.download-config-page']); Route::post('/csv/save_mapping', ['uses' => 'CsvController@saveMapping', 'as' => 'csv.save_mapping']); + Route::get('/csv/process', ['uses' => 'CsvController@process', 'as' => 'csv.process']); /** diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index 685e9685e9..c528ab0bb6 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -91,6 +91,9 @@ class FireflyServiceProvider extends ServiceProvider $this->app->bind('FireflyIII\Repositories\Tag\TagRepositoryInterface', 'FireflyIII\Repositories\Tag\TagRepository'); $this->app->bind('FireflyIII\Support\Search\SearchInterface', 'FireflyIII\Support\Search\Search'); + // CSV import + $this->app->bind('FireflyIII\Helpers\Csv\WizardInterface', 'FireflyIII\Helpers\Csv\Wizard'); + // make charts: // alternative is Google instead of ChartJs $this->app->bind('FireflyIII\Generator\Chart\Account\AccountChartGenerator', 'FireflyIII\Generator\Chart\Account\ChartJsAccountChartGenerator'); diff --git a/config/csv.php b/config/csv.php index 6a198dc8c8..7c65084ffd 100644 --- a/config/csv.php +++ b/config/csv.php @@ -4,6 +4,8 @@ return [ '_ignore' => [ 'name' => '(ignore this column)', 'mappable' => false, + 'converter' => 'Ignore', + 'field' => 'ignored', ], 'bill-id' => [ 'name' => 'Bill ID (matching Firefly)', @@ -22,8 +24,10 @@ return [ 'mappable' => true, ], 'currency-code' => [ - 'name' => 'Currency code (ISO 4217)', - 'mappable' => true, + 'name' => 'Currency code (ISO 4217)', + 'mappable' => true, + 'converter' => 'CurrencyCode', + 'field' => 'currency' ], 'currency-symbol' => [ 'name' => 'Currency symbol (matching Firefly)', @@ -34,8 +38,10 @@ return [ 'mappable' => false, ], 'date-transaction' => [ - 'name' => 'Date', - 'mappable' => false, + 'name' => 'Date', + 'mappable' => false, + 'converter' => 'Date', + 'field' => 'date', ], 'date-rent' => [ 'name' => 'Rent calculation date', @@ -49,9 +55,11 @@ return [ 'name' => 'Budget name', 'mappable' => true, ], - 'rabo-debet-credet' => [ - 'name' => 'Rabobank specific debet/credet indicator', - 'mappable' => false, + 'rabo-debet-credit' => [ + 'name' => 'Rabobank specific debet/credit indicator', + 'mappable' => false, + 'converter' => 'RabobankDebetCredit', + 'field' => 'amount-modifier', ], 'category-id' => [ 'name' => 'Category ID (matching Firefly)', @@ -78,8 +86,10 @@ return [ 'mappable' => true, ], 'account-iban' => [ - 'name' => 'Asset account IBAN', - 'mappable' => true, + 'name' => 'Asset account IBAN', + 'mappable' => true, + 'converter' => 'AccountIban', + 'field' => 'asset-account' ], 'opposing-id' => [ 'name' => 'Expense or revenue account ID (matching Firefly)', @@ -94,8 +104,10 @@ return [ 'mappable' => true, ], 'amount' => [ - 'name' => 'Amount', - 'mappable' => false, + 'name' => 'Amount', + 'mappable' => false, + 'converter' => 'Amount', + 'field' => 'amount', ], 'sepa-ct-id' => [ 'name' => 'SEPA Credit Transfer end-to-end ID', diff --git a/resources/twig/csv/column-roles.twig b/resources/twig/csv/column-roles.twig index 6325ada631..e3e0248288 100644 --- a/resources/twig/csv/column-roles.twig +++ b/resources/twig/csv/column-roles.twig @@ -55,16 +55,17 @@ {{ header }} {{ example[index] }} - {{ Form.select(('role['~index~']'), roles) }} + {{ Form.select(('role['~index~']'), availableRoles,roles[index]) }} - {{ Form.checkbox(('map['~index~']'),1,false) }} + {{ Form.checkbox(('map['~index~']'),1,map[index]) }} {% endfor %}

    + {{ 'go_back'|_ }} diff --git a/resources/twig/csv/download-config.twig b/resources/twig/csv/download-config.twig new file mode 100644 index 0000000000..e566d293ec --- /dev/null +++ b/resources/twig/csv/download-config.twig @@ -0,0 +1,40 @@ +{% extends "./layout/default.twig" %} + +{% block breadcrumbs %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +{% endblock %} + +{% block content %} + + +

    +
    +
    +
    +

    {{ 'csv_download_config'|_ }}

    + + +
    + +
    + +
    +
    +

    + {{ 'csv_some_text'|_ }} +

    +

    + {{ 'csv_do_download_config'|_ }} +

    +

    + {{ 'csv_more_information_text'|_ }} +

    +

    + {{ 'csv_do_process'|_ }} +

    +
    +
    + +
    +
    +{% endblock %} diff --git a/resources/twig/csv/index.twig b/resources/twig/csv/index.twig index 79e3b53add..58b4c3f2b3 100644 --- a/resources/twig/csv/index.twig +++ b/resources/twig/csv/index.twig @@ -29,7 +29,7 @@
    -
    +

    {{ 'csv_upload_form'|_ }}

    @@ -50,6 +50,8 @@ {{ ExpandedForm.file('csv') }} + {{ ExpandedForm.file('csv_config') }} + {% if uploadPossible %}
    @@ -57,6 +59,7 @@
    + diff --git a/resources/twig/csv/map.twig b/resources/twig/csv/map.twig index 78ed891fa8..255abac3b0 100644 --- a/resources/twig/csv/map.twig +++ b/resources/twig/csv/map.twig @@ -20,10 +20,7 @@
    -

    {{ 'csv_map_text'|_ }}

    -

    {{ 'csv_more_information' }}

    - -

    {{ 'csv_more_information_text'|_ }}

    + Download config for use again
    @@ -57,7 +54,7 @@ {{ value }} - {{ Form.select('mapping['~index~']['~value~']',options[index]) }} + {{ Form.select('mapping['~index~']['~value~']',options[index], mapped[index][value]) }} {% endfor %} diff --git a/resources/twig/error.twig b/resources/twig/error.twig index e0621f17d8..4390f9c05c 100644 --- a/resources/twig/error.twig +++ b/resources/twig/error.twig @@ -4,9 +4,7 @@
    -

    Firefly
    - Error -

    +

    Sorry, an error occurred.

    From 1069db3c134be5bdbab731588752a56ac120f6b6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 06:26:34 +0200 Subject: [PATCH 18/60] Some new converters. --- app/Helpers/Csv/Converter/BasicConverter.php | 35 +++++++++++++++---- .../Csv/Converter/ConverterInterface.php | 16 +++++---- app/Helpers/Csv/Converter/OpposingName.php | 24 +++++++++++++ app/Helpers/Csv/Importer.php | 1 + config/csv.php | 12 ++++--- 5 files changed, 71 insertions(+), 17 deletions(-) create mode 100644 app/Helpers/Csv/Converter/OpposingName.php diff --git a/app/Helpers/Csv/Converter/BasicConverter.php b/app/Helpers/Csv/Converter/BasicConverter.php index ff19555071..ba2bffc864 100644 --- a/app/Helpers/Csv/Converter/BasicConverter.php +++ b/app/Helpers/Csv/Converter/BasicConverter.php @@ -11,10 +11,15 @@ class BasicConverter { /** @var array */ protected $data; + /** @var string */ + protected $field; + /** @var int */ protected $index; /** @var array */ protected $mapped; + /** @var string */ protected $role; + /** @var string */ protected $value; /** @@ -28,13 +33,29 @@ class BasicConverter /** * @param array $data */ - public function setData($data) + public function setData(array $data) { $this->data = $data; } /** - * @return mixed + * @return string + */ + public function getField() + { + return $this->field; + } + + /** + * @param string $field + */ + public function setField($field) + { + $this->field = $field; + } + + /** + * @return int */ public function getIndex() { @@ -42,7 +63,7 @@ class BasicConverter } /** - * @param mixed $index + * @param int $index */ public function setIndex($index) { @@ -66,7 +87,7 @@ class BasicConverter } /** - * @return mixed + * @return string */ public function getRole() { @@ -74,7 +95,7 @@ class BasicConverter } /** - * @param mixed $role + * @param string $role */ public function setRole($role) { @@ -82,7 +103,7 @@ class BasicConverter } /** - * @return mixed + * @return string */ public function getValue() { @@ -90,7 +111,7 @@ class BasicConverter } /** - * @param mixed $value + * @param string $value */ public function setValue($value) { diff --git a/app/Helpers/Csv/Converter/ConverterInterface.php b/app/Helpers/Csv/Converter/ConverterInterface.php index 3efd70555c..1e9eb275e3 100644 --- a/app/Helpers/Csv/Converter/ConverterInterface.php +++ b/app/Helpers/Csv/Converter/ConverterInterface.php @@ -22,30 +22,34 @@ interface ConverterInterface public function convert(); /** - * @param $index + * @param int $index */ public function setIndex($index); /** - * @param $mapped + * @param array $mapped */ public function setMapped($mapped); /** - * @param $role + * @param string $role */ public function setRole($role); /** - * @param $value + * @param string $value */ public function setValue($value); /** * @param array $data - * - * @return mixed */ public function setData(array $data); + /** + * @param string $field + * + */ + public function setField($field); + } \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/OpposingName.php b/app/Helpers/Csv/Converter/OpposingName.php new file mode 100644 index 0000000000..25ab7b00be --- /dev/null +++ b/app/Helpers/Csv/Converter/OpposingName.php @@ -0,0 +1,24 @@ +value; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index eeda8892c5..644daaebea 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -78,6 +78,7 @@ class Importer /** @var ConverterInterface $converter */ $converter = App::make('FireflyIII\Helpers\Csv\Converter\\' . $class); $converter->setData($data); // the complete array so far. + $converter->setField($field); $converter->setIndex($index); $converter->setValue($value); $converter->setRole($role); diff --git a/config/csv.php b/config/csv.php index 7c65084ffd..dea1edb42f 100644 --- a/config/csv.php +++ b/config/csv.php @@ -2,8 +2,8 @@ return [ 'roles' => [ '_ignore' => [ - 'name' => '(ignore this column)', - 'mappable' => false, + 'name' => '(ignore this column)', + 'mappable' => false, 'converter' => 'Ignore', 'field' => 'ignored', ], @@ -46,6 +46,8 @@ return [ 'date-rent' => [ 'name' => 'Rent calculation date', 'mappable' => false, + 'converter' => 'Date', + 'field' => 'date-rent', ], 'budget-id' => [ 'name' => 'Budget ID (matching Firefly)', @@ -96,8 +98,10 @@ return [ 'mappable' => true, ], 'opposing-name' => [ - 'name' => 'Expense or revenue account name', - 'mappable' => true, + 'name' => 'Expense or revenue account name', + 'mappable' => true, + 'converter' => 'OpposingName', + 'field' => 'opposing-account' ], 'opposing-iban' => [ 'name' => 'Expense or revenue account IBAN', From 1dc6d8de40ce4664f27037863b4ef2598930221a Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 06:59:05 +0200 Subject: [PATCH 19/60] First working version, very beta. --- app/Helpers/Csv/Converter/AccountIban.php | 7 +- app/Helpers/Csv/Converter/Description.php | 21 +++ app/Helpers/Csv/Importer.php | 180 +++++++++++++++++----- config/csv.php | 28 ++-- 4 files changed, 183 insertions(+), 53 deletions(-) create mode 100644 app/Helpers/Csv/Converter/Description.php diff --git a/app/Helpers/Csv/Converter/AccountIban.php b/app/Helpers/Csv/Converter/AccountIban.php index 6aa7494c62..bbca8ac0ee 100644 --- a/app/Helpers/Csv/Converter/AccountIban.php +++ b/app/Helpers/Csv/Converter/AccountIban.php @@ -11,6 +11,7 @@ namespace FireflyIII\Helpers\Csv\Converter; use Auth; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; +use Log; /** * Class AccountIban @@ -36,9 +37,13 @@ class AccountIban extends BasicConverter implements ConverterInterface 'name' => $this->value, //'iban' => $this->value, 'user_id' => Auth::user()->id, - 'account_type_id' => $accountType->id + 'account_type_id' => $accountType->id, + 'active' => true, ] ); + if ($account->getErrors()->count() > 0) { + Log::error('Create or find asset account: ' . json_encode($account->getErrors()->all())); + } } return $account; diff --git a/app/Helpers/Csv/Converter/Description.php b/app/Helpers/Csv/Converter/Description.php new file mode 100644 index 0000000000..19bede19a0 --- /dev/null +++ b/app/Helpers/Csv/Converter/Description.php @@ -0,0 +1,21 @@ +data['description'] . ' ' . $this->value); + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 644daaebea..4d8ac5c1b4 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -3,10 +3,18 @@ namespace FireflyIII\Helpers\Csv; use App; +use Auth; use Carbon\Carbon; use Config; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Csv\Converter\ConverterInterface; +use FireflyIII\Models\Account; +use FireflyIII\Models\AccountType; +use FireflyIII\Models\Transaction; +use FireflyIII\Models\TransactionJournal; +use FireflyIII\Models\TransactionType; +use Illuminate\Support\MessageBag; +use Log; /** * Class Importer @@ -18,13 +26,12 @@ class Importer /** @var Data */ protected $data; - + /** @var array */ + protected $errors; /** @var array */ protected $map; - /** @var array */ protected $mapped; - /** @var array */ protected $roles; @@ -48,22 +55,29 @@ class Importer $this->map = $this->data->getMap(); $this->roles = $this->data->getRoles(); $this->mapped = $this->data->getMapped(); - foreach ($this->data->getReader() as $row) { - $this->importRow($row); + foreach ($this->data->getReader() as $index => $row) { + $result = $this->importRow($row); + if (!($result === true)) { + $this->errors[$index] = $result; + Log::error('ImportRow: ' . $result); + } } + + return count($this->errors); } /** * @param $row * * @throws FireflyException + * @return string|bool */ protected function importRow($row) { /* * These fields are necessary to create a new transaction journal. Some are optional: */ - $data = $this->getFiller(); + $data = $this->getFiller(); foreach ($row as $index => $value) { $role = isset($this->roles[$index]) ? $this->roles[$index] : '_ignore'; $class = Config::get('csv.roles.' . $role . '.converter'); @@ -91,37 +105,19 @@ class Importer $data[$field] = $converter->convert(); // } - - // case 'description': - // $data['description'] .= ' ' . $value; - // break; - // case '_ignore': - // ignore! (duh) - // break; - // case 'account-iban': - // $data['asset-account'] = $this->findAssetAccount($index, $value); - // break; - // case 'currency-code': - // $data['currency'] = $this->findCurrency($index, $value, $role); - // break; - // case 'date-transaction': - // $data['date'] = $this->parseDate($value); - // break; - // case 'rabo-debet-credit': - // $data['amount-modifier'] = $this->parseRaboDebetCredit($value); - // break; - // default: - // throw new FireflyException('Cannot process row of type "' . $role . '".'); - // break; - - } - $data = $this->postProcess($data); - var_dump($data); + $data = $this->postProcess($data); + $result = $this->validateData($data); + if ($result === true) { + $result = $this->createTransactionJournal($data); + } else { + Log::error('Validator: ' . $result); + } + if ($result instanceof TransactionJournal) { + return true; + } - - - exit; + return 'Not a journal.'; } @@ -131,13 +127,16 @@ class Importer protected function getFiller() { return [ - 'description' => '', - 'asset-account' => null, - 'date' => null, - 'currency' => null, - 'amount' => null, - 'amount-modifier' => 1, - 'ignored' => null, + 'description' => '', + 'asset-account' => null, + 'opposing-account' => '', + 'opposing-account-object' => null, + 'date' => null, + 'currency' => null, + 'amount' => null, + 'amount-modifier' => 1, + 'ignored' => null, + 'date-rent' => null, ]; } @@ -149,12 +148,109 @@ class Importer */ protected function postProcess(array $data) { + bcscale(2); $data['description'] = trim($data['description']); + $data['amount'] = bcmul($data['amount'], $data['amount-modifier']); + if ($data['amount'] < 0) { + // create expense account: + $accountType = AccountType::where('type', 'Expense account')->first(); + } else { + // create revenue account: + $accountType = AccountType::where('type', 'Revenue account')->first(); + } + $data['opposing-account-object'] = Account::firstOrCreateEncrypted( + [ + 'user_id' => Auth::user()->id, + 'name' => ucwords($data['opposing-account']), + 'account_type_id' => $accountType->id, + 'active' => 1, + ] + ); return $data; } + /** + * @param $data + * + * @return bool|string + */ + protected function validateData($data) + { + if (is_null($data['date']) && is_null($data['date-rent'])) { + return 'No date value for this row.'; + } + if (strlen($data['description']) == 0) { + return 'No valid description'; + } + if (is_null($data['opposing-account-object'])) { + return 'Opposing account is null'; + } + + return true; + } + + /** + * @param array $data + * + * @return static + */ + protected function createTransactionJournal(array $data) + { + bcscale(2); + $date = $data['date']; + if (is_null($data['date'])) { + $date = $data['date-rent']; + } + if ($data['amount'] < 0) { + $transactionType = TransactionType::where('type', 'Withdrawal')->first(); + } else { + $transactionType = TransactionType::where('type', 'Deposit')->first(); + } + $errors = new MessageBag; + $journal = TransactionJournal::create( + [ + 'user_id' => Auth::user()->id, + 'transaction_type_id' => $transactionType->id, + 'bill_id' => null, + 'transaction_currency_id' => $data['currency']->id, + 'description' => $data['description'], + 'completed' => 0, + 'date' => $date, + ] + ); + $errors = $journal->getErrors()->merge($errors); + if ($journal->getErrors()->count() == 0) { + // create both transactions: + $transaction = Transaction::create( + [ + 'transaction_journal_id' => $journal->id, + 'account_id' => $data['asset-account']->id, + 'amount' => $data['amount'] + ] + ); + $errors = $transaction->getErrors()->merge($errors); + + $transaction = Transaction::create( + [ + 'transaction_journal_id' => $journal->id, + 'account_id' => $data['opposing-account-object']->id, + 'amount' => bcmul($data['amount'], -1) + ] + ); + $errors = $transaction->getErrors()->merge($errors); + } + if($errors->count() == 0) { + $journal->completed = 1; + $journal->save(); + } + + return $journal; + + + } + /** * @param Data $data */ diff --git a/config/csv.php b/config/csv.php index dea1edb42f..78b4121dcb 100644 --- a/config/csv.php +++ b/config/csv.php @@ -34,8 +34,10 @@ return [ 'mappable' => true, ], 'description' => [ - 'name' => 'Description', - 'mappable' => false, + 'name' => 'Description', + 'mappable' => false, + 'converter' => 'Description', + 'field' => 'description', ], 'date-transaction' => [ 'name' => 'Date', @@ -44,8 +46,8 @@ return [ 'field' => 'date', ], 'date-rent' => [ - 'name' => 'Rent calculation date', - 'mappable' => false, + 'name' => 'Rent calculation date', + 'mappable' => false, 'converter' => 'Date', 'field' => 'date-rent', ], @@ -114,16 +116,22 @@ return [ 'field' => 'amount', ], 'sepa-ct-id' => [ - 'name' => 'SEPA Credit Transfer end-to-end ID', - 'mappable' => false, + 'name' => 'SEPA Credit Transfer end-to-end ID', + 'mappable' => false, + 'converter' => 'Description', + 'field' => 'description', ], 'sepa-ct-op' => [ - 'name' => 'SEPA Credit Transfer opposing account', - 'mappable' => false, + 'name' => 'SEPA Credit Transfer opposing account', + 'mappable' => false, + 'converter' => 'Description', + 'field' => 'description', ], 'sepa-db' => [ - 'name' => 'SEPA Direct Debet', - 'mappable' => false, + 'name' => 'SEPA Direct Debet', + 'mappable' => false, + 'converter' => 'Description', + 'field' => 'description', ], ] ]; \ No newline at end of file From f8936210cfa111fd8138f74f2742a6f311eab25a Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 07:18:48 +0200 Subject: [PATCH 20/60] Small fixes. --- app/Helpers/Csv/Importer.php | 29 ++++++++++---- app/Helpers/Csv/Specifix.php | 73 ++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 app/Helpers/Csv/Specifix.php diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 4d8ac5c1b4..94e6b75e5a 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -16,6 +16,8 @@ use FireflyIII\Models\TransactionType; use Illuminate\Support\MessageBag; use Log; +set_time_limit(0); + /** * Class Importer * @@ -106,7 +108,7 @@ class Importer // } } - $data = $this->postProcess($data); + $data = $this->postProcess($data, $row); $result = $this->validateData($data); if ($result === true) { $result = $this->createTransactionJournal($data); @@ -142,11 +144,14 @@ class Importer } /** + * Row denotes the original data. + * * @param array $data + * @param array $row * * @return array */ - protected function postProcess(array $data) + protected function postProcess(array $data, array $row) { bcscale(2); $data['description'] = trim($data['description']); @@ -159,6 +164,16 @@ class Importer $accountType = AccountType::where('type', 'Revenue account')->first(); } + // do bank specific fixes: + + $specifix = new Specifix(); + $specifix->setData($data); + $specifix->setRow($row); + $specifix->fix($data, $row); + + // get data back: + $data = $specifix->getData(); + $data['opposing-account-object'] = Account::firstOrCreateEncrypted( [ 'user_id' => Auth::user()->id, @@ -208,7 +223,7 @@ class Importer } else { $transactionType = TransactionType::where('type', 'Deposit')->first(); } - $errors = new MessageBag; + $errors = new MessageBag; $journal = TransactionJournal::create( [ 'user_id' => Auth::user()->id, @@ -220,7 +235,7 @@ class Importer 'date' => $date, ] ); - $errors = $journal->getErrors()->merge($errors); + $errors = $journal->getErrors()->merge($errors); if ($journal->getErrors()->count() == 0) { // create both transactions: $transaction = Transaction::create( @@ -230,7 +245,7 @@ class Importer 'amount' => $data['amount'] ] ); - $errors = $transaction->getErrors()->merge($errors); + $errors = $transaction->getErrors()->merge($errors); $transaction = Transaction::create( [ @@ -239,9 +254,9 @@ class Importer 'amount' => bcmul($data['amount'], -1) ] ); - $errors = $transaction->getErrors()->merge($errors); + $errors = $transaction->getErrors()->merge($errors); } - if($errors->count() == 0) { + if ($errors->count() == 0) { $journal->completed = 1; $journal->save(); } diff --git a/app/Helpers/Csv/Specifix.php b/app/Helpers/Csv/Specifix.php new file mode 100644 index 0000000000..0e530d4a5d --- /dev/null +++ b/app/Helpers/Csv/Specifix.php @@ -0,0 +1,73 @@ +rabobankFixEmptyOpposing(); + + } + + /** + * Fixes Rabobank specific thing. + */ + protected function rabobankFixEmptyOpposing() + { + if (strlen($this->data['opposing-account']) == 0) { + $this->data['opposing-account'] = $this->row[10]; + } + $this->data['description'] = trim(str_replace($this->row[10], '', $this->data['description'])); + } + + + /** + * @return array + */ + public function getData() + { + return $this->data; + } + + /** + * @param array $data + */ + public function setData($data) + { + $this->data = $data; + } + + /** + * @return array + */ + public function getRow() + { + return $this->row; + } + + /** + * @param array $row + */ + public function setRow($row) + { + $this->row = $row; + } + + +} \ No newline at end of file From 540dde135e0e313557983fdecfb8ad39b3bc9a4b Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 08:45:05 +0200 Subject: [PATCH 21/60] CSV importer now indicates the problems it has. --- app/Helpers/Csv/Importer.php | 27 ++-- .../AssetAccount.php} | 34 ++--- app/Helpers/Csv/Mapper/MapperInterface.php | 16 +++ .../Csv/Mapper/TransactionCurrency.php | 28 +++++ app/Helpers/Csv/Wizard.php | 35 +++--- app/Http/Controllers/CsvController.php | 118 ++++-------------- config/csv.php | 6 +- resources/lang/en/firefly.php | 52 ++++++-- resources/lang/en/form.php | 1 + resources/twig/csv/column-roles.twig | 105 ++++++++-------- resources/twig/csv/download-config.twig | 58 +++++---- resources/twig/csv/index.twig | 101 ++++++++------- resources/twig/csv/map.twig | 28 +++-- 13 files changed, 312 insertions(+), 297 deletions(-) rename app/Helpers/Csv/{DataGrabber.php => Mapper/AssetAccount.php} (51%) create mode 100644 app/Helpers/Csv/Mapper/MapperInterface.php create mode 100644 app/Helpers/Csv/Mapper/TransactionCurrency.php diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 94e6b75e5a..3f7be24554 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -37,18 +37,6 @@ class Importer /** @var array */ protected $roles; - /** - * @param $value - */ - public function parseRaboDebetCredit($value) - { - if ($value == 'D') { - return -1; - } - - return 1; - } - /** * */ @@ -58,10 +46,11 @@ class Importer $this->roles = $this->data->getRoles(); $this->mapped = $this->data->getMapped(); foreach ($this->data->getReader() as $index => $row) { + Log::debug('Now at row ' . $index); $result = $this->importRow($row); if (!($result === true)) { + Log::error('Caught error at row #' . $index . ': ' . $result); $this->errors[$index] = $result; - Log::error('ImportRow: ' . $result); } } @@ -96,16 +85,10 @@ class Importer $converter->setData($data); // the complete array so far. $converter->setField($field); $converter->setIndex($index); + $converter->setMapped($this->mapped); $converter->setValue($value); $converter->setRole($role); - // if (is_array($field)) { - // $convertResult = $converter->convert(); - // foreach ($field as $fieldName) { - // $data[$fieldName] = $convertResult[$fieldName]; - // } - // } else { $data[$field] = $converter->convert(); - // } } $data = $this->postProcess($data, $row); @@ -164,6 +147,10 @@ class Importer $accountType = AccountType::where('type', 'Revenue account')->first(); } + if(strlen($data['description']) == 0) { + $data['description'] = trans('firefly.csv_empty_description'); + } + // do bank specific fixes: $specifix = new Specifix(); diff --git a/app/Helpers/Csv/DataGrabber.php b/app/Helpers/Csv/Mapper/AssetAccount.php similarity index 51% rename from app/Helpers/Csv/DataGrabber.php rename to app/Helpers/Csv/Mapper/AssetAccount.php index 93260b82c4..d8fe71cc2d 100644 --- a/app/Helpers/Csv/DataGrabber.php +++ b/app/Helpers/Csv/Mapper/AssetAccount.php @@ -1,26 +1,29 @@ accounts()->with( ['accountmeta' => function (HasMany $query) { @@ -36,19 +39,4 @@ class DataGrabber return $list; } - - /** - * @return array - */ - public function getCurrencies() - { - $currencies = TransactionCurrency::get(); - $list = []; - foreach ($currencies as $currency) { - $list[$currency->id] = $currency->name . ' (' . $currency->code . ')'; - } - - return $list; - } - } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/MapperInterface.php b/app/Helpers/Csv/Mapper/MapperInterface.php new file mode 100644 index 0000000000..a01785f9a4 --- /dev/null +++ b/app/Helpers/Csv/Mapper/MapperInterface.php @@ -0,0 +1,16 @@ +id] = $currency->name . ' (' . $currency->code . ')'; + } + + return $list; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Wizard.php b/app/Helpers/Csv/Wizard.php index b08e10bc55..92291e7f45 100644 --- a/app/Helpers/Csv/Wizard.php +++ b/app/Helpers/Csv/Wizard.php @@ -1,11 +1,14 @@ $columnRole) { - /* - * Depending on the column role, get the relevant data from the database. - * This needs some work to be optimal. - */ - switch ($columnRole) { - default: - throw new FireflyException('Cannot map field of type "' . $columnRole . '".'); - break; - case 'account-iban': - $set = $dataGrabber->getAssetAccounts(); - break; - case 'currency-code': - $set = $dataGrabber->getCurrencies(); - break; + $mapper = Config::get('csv.roles.' . $columnRole . '.mapper'); + if (is_null($mapper)) { + throw new FireflyException('Cannot map field of type "' . $columnRole . '".'); } - - /* - * Make select list kind of thing: - */ - + $class = 'FireflyIII\Helpers\Csv\Mapper\\' . $mapper; + try { + /** @var MapperInterface $mapObject */ + $mapObject = App::make($class); + } catch (ReflectionException $e) { + throw new FireflyException('Column "' . $columnRole . '" cannot be mapped because class ' . $mapper . ' does not exist.'); + } + $set = $mapObject->getMap(); $options[$index] = $set; } - return $options; } diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index a8636dde63..03cfd5e63f 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -9,18 +9,14 @@ namespace FireflyIII\Http\Controllers; use App; -use Carbon\Carbon; use Config; -use Crypt; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Csv\Data; use FireflyIII\Helpers\Csv\Importer; use FireflyIII\Helpers\Csv\WizardInterface; -use FireflyIII\Models\Account; -use FireflyIII\Models\TransactionCurrency; use Illuminate\Http\Request; use Input; -use League\Csv\Reader; +use Log; use Redirect; use Session; use View; @@ -80,7 +76,7 @@ class CsvController extends Controller $map = $this->data->getMap(); for ($i = 1; $i <= $count; $i++) { - $headers[] = trans('firefly.csv_row') . ' #' . $i; + $headers[] = trans('firefly.csv_column') . ' #' . $i; } if ($this->data->getHasHeaders()) { $headers = $firstRow; @@ -157,12 +153,24 @@ class CsvController extends Controller Session::forget('csv-roles'); Session::forget('csv-mapped'); + // get values which are yet unsaveable or unmappable: + $unsupported = []; + foreach (Config::get('csv.roles') as $role) { + if (!isset($role['converter'])) { + $unsupported[] = trans('firefly.csv_unsupported_value', ['columnRole' => $role['name']]); + } + if ($role['mappable'] === true && !isset($role['mapper'])) { + $unsupported[] = trans('firefly.csv_unsupported_map', ['columnRole' => $role['name']]); + } + } + sort($unsupported); + // can actually upload? $uploadPossible = is_writable(storage_path('upload')); $path = storage_path('upload'); - return view('csv.index', compact('subTitle', 'uploadPossible', 'path')); + return view('csv.index', compact('subTitle', 'uploadPossible', 'path','unsupported')); } /** @@ -209,7 +217,8 @@ class CsvController extends Controller * Or simply start processing. */ - return Redirect::route('csv.process'); + // proceed to download config + return Redirect::route('csv.download-config-page'); } @@ -284,104 +293,21 @@ class CsvController extends Controller return Redirect::route('csv.index'); } - // + Log::debug('Created importer'); $importer = new Importer; $importer->setData($this->data); try { $importer->run(); } catch (FireflyException $e) { + Log::error('Catch error: ' . $e->getMessage()); + return view('error', ['message' => $e->getMessage()]); } + Log::debug('Done importing!'); - + echo 'display result'; exit; - // loop the original file again: - $content = file_get_contents(Session::get('csv-file')); - $hasHeaders = Session::get('csv-has-headers'); - $reader = Reader::createFromString(Crypt::decrypt($content)); - - // dump stuff - $dateFormat = Session::get('csv-date-format'); - $roles = Session::get('csv-roles'); - $mapped = Session::get('csv-mapped'); - - /* - * Loop over the CSV and collect mappable data: - */ - foreach ($reader as $index => $row) { - if (($hasHeaders && $index > 1) || !$hasHeaders) { - // this is the data we need to store the new transaction: - $amount = 0; - $amountModifier = 1; - $description = ''; - $assetAccount = null; - $opposingAccount = null; - $currency = null; - $date = null; - - foreach ($row as $index => $value) { - if (isset($roles[$index])) { - switch ($roles[$index]) { - default: - throw new FireflyException('Cannot process role "' . $roles[$index] . '"'); - break; - case 'account-iban': - // find ID in "mapped" (if present). - if (isset($mapped[$index])) { - $searchID = $mapped[$index][$value]; - $assetAccount = Account::find($searchID); - } else { - // create account - } - break; - case 'opposing-name': - // don't know yet if its going to be a - // revenue or expense account. - $opposingAccount = $value; - break; - case 'currency-code': - // find ID in "mapped" (if present). - if (isset($mapped[$index])) { - $searchValue = $mapped[$index][$value]; - $currency = TransactionCurrency::whereCode($searchValue); - } else { - // create account - } - break; - case 'date-transaction': - // unmappable: - $date = Carbon::createFromFormat($dateFormat, $value); - - break; - case 'rabo-debet-credet': - if ($value == 'D') { - $amountModifier = -1; - } - break; - case 'amount': - $amount = $value; - break; - case 'description': - $description .= ' ' . $value; - break; - case 'sepa-ct-id': - $description .= ' ' . $value; - break; - - } - } - } - // do something with all this data: - - - // do something. - var_dump($row); - - } - } - - } /** diff --git a/config/csv.php b/config/csv.php index 78b4121dcb..e141c2f438 100644 --- a/config/csv.php +++ b/config/csv.php @@ -27,7 +27,8 @@ return [ 'name' => 'Currency code (ISO 4217)', 'mappable' => true, 'converter' => 'CurrencyCode', - 'field' => 'currency' + 'field' => 'currency', + 'mapper' => 'TransactionCurrency' ], 'currency-symbol' => [ 'name' => 'Currency symbol (matching Firefly)', @@ -93,7 +94,8 @@ return [ 'name' => 'Asset account IBAN', 'mappable' => true, 'converter' => 'AccountIban', - 'field' => 'asset-account' + 'field' => 'asset-account', + 'mapper' => 'AssetAccount' ], 'opposing-id' => [ 'name' => 'Expense or revenue account ID (matching Firefly)', diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php index 071f352e50..1374379ef4 100644 --- a/resources/lang/en/firefly.php +++ b/resources/lang/en/firefly.php @@ -22,15 +22,53 @@ return [ // csv import: 'csv_import' => 'Import CSV file', 'csv' => 'CSV', - 'csv_index_text' => 'Here be explanation.', - 'csv_upload_form' => 'Upload form', - 'upload_csv_file' => 'Upload CSV file', - 'csv_header_help' => 'Check this when bla bla', + 'csv_index_title' => 'Upload and import a CSV file', + 'csv_index_text' => + 'This form allows you to import a CSV file with transactions into Firefly. It is based on the excellent CSV importer made by' . + ' the folks at Atlassian. Simply upload your CSV file and follow the instructions.', + 'csv_index_beta_warning' => 'This tool is very much in beta. Please proceed with caution', + 'csv_header_help' => 'Check this box when your CSV file\'s first row consists of column names, not actual data', 'csv_date_help' => 'Date time format in your CSV. Follow the format like this' . - ' page indicates.', - 'csv_row' => 'row', - 'upload_not_writeable' => 'Cannot write to the path mentioned here. Cannot upload', + ' page indicates. The default value will parse dates that look like this: ' . date('Ymd'), + 'csv_csv_file_help' => 'Select the CSV file here. You can only upload one file at a time', + 'csv_csv_config_file_help' => 'Select your CSV import configuration here. If you do not know what this is, ignore it. It will be explained later.', + 'csv_upload_button' => 'Start importing CSV', + 'csv_column_roles_title' => 'Define column roles', + 'csv_column_roles_text' => 'Firefly does not know what each column means. You need to indicate what every column is. Please check out the example ' + . 'data if you\'re not sure yourself. Click on the question mark (top right of the page) to learn what' + . ' each column means. If you want to map imported data onto existing data in Firefly, use the checkbox. ' + . 'The next step will show you what this button does.', + 'csv_column_roles_table' => 'Column roles', + 'csv_column' => 'CSV column', + 'cvs_column_name' => 'CSV column name', + 'cvs_column_example' => 'Column example data', + 'cvs_column_role' => 'Column contains?', + 'csv_do_map_value' => 'Map value?', + 'csv_continue' => 'Continue to the next step', + 'csv_go_back' => 'Go back to the previous step', + 'csv_map_title' => 'Map found values to existing values', + 'csv_map_text' => + 'This page allows you to map the values from the CSV file to existing entries in your database. This ensures that accounts and other' + . ' things won\'t be created twice.', + 'cvs_field_value' => 'Field value from CSV', + 'csv_field_mapped_to' => 'Must be mapped to...', + 'csv_download_config_title' => 'Download CSV configuration', + 'csv_download_config_text' => 'Everything you\'ve just set up can be downloaded as a configuration file. Click the button to do so.', + 'csv_more_information_text' => 'If the import fails, you can use this configuration file so you don\'t have to start all over again.', + 'csv_do_download_config' => 'Download configuration file.', + 'csv_empty_description' => '(empty description)', + 'csv_upload_form' => 'CSV upload form', + 'csv_index_unsupported_warning' => 'The CSV importer is yet incapable of doing the following:', + 'csv_unsupported_map' => 'The importer cannot map the column ":columnRole" to existing values in the database.', + 'csv_unsupported_value' => 'The importer does not know how to handle values in columns marked as ":columnRole".', + // 'csv_index_text' => 'Here be explanation.', + // 'csv_upload_form' => 'Upload form', + // 'upload_csv_file' => 'Upload CSV file', + // 'csv_header_help' => 'Check this when bla bla', + // 'csv_date_help' => + // 'csv_row' => 'row', + 'csv_upload_not_writeable' => 'Cannot write to the path mentioned here. Cannot upload', // create new stuff: 'create_new_withdrawal' => 'Create new withdrawal', diff --git a/resources/lang/en/form.php b/resources/lang/en/form.php index ef9596096f..67e7337be6 100644 --- a/resources/lang/en/form.php +++ b/resources/lang/en/form.php @@ -48,6 +48,7 @@ return [ 'csv' => 'CSV file', 'has_headers' => 'Headers', 'date_format' => 'Date format', + 'csv_config' => 'CSV import configuration', 'store_new_withdrawal' => 'Store new withdrawal', 'store_new_deposit' => 'Store new deposit', diff --git a/resources/twig/csv/column-roles.twig b/resources/twig/csv/column-roles.twig index e3e0248288..3480bdbd0f 100644 --- a/resources/twig/csv/column-roles.twig +++ b/resources/twig/csv/column-roles.twig @@ -7,32 +7,11 @@ {% block content %} -
    -
    -
    -
    -

    {{ 'csv_process'|_ }}

    - - -
    - -
    - -
    -
    -

    {{ 'csv_process_text'|_ }}

    -

    {{ 'csv_more_information' }}

    -

    {{ 'csv_more_information_text'|_ }}

    -
    -
    - -
    -
    -

    {{ 'csv_process_form'|_ }}

    +

    {{ 'csv_column_roles_title'|_ }}

    @@ -41,40 +20,68 @@
    -
    - - - +

    {{ 'csv_column_roles_text'|_ }}

    + + + + + + + + +
    +
    +
    +
    +

    {{ 'csv_column_roles_table'|_ }}

    + + +
    + +
    + +
    +
    + +
    + - - - {% for index,header in headers %} - - - - - + + + {% for index,header in headers %} + + + + + - - {% endfor %} -
    {{ 'cvs_column_name'|_ }} {{ 'cvs_column_example'|_ }} {{ 'cvs_column_role'|_ }}{{ 'do_map_value'|_ }}
    {{ header }}{{ example[index] }} - {{ Form.select(('role['~index~']'), availableRoles,roles[index]) }} - - {{ Form.checkbox(('map['~index~']'),1,map[index]) }} - {{ 'csv_do_map_value'|_ }}
    {{ header }}{{ example[index] }} + {{ Form.select(('role['~index~']'), availableRoles,roles[index]) }} + + {{ Form.checkbox(('map['~index~']'),1,map[index]) }} +
    -

    - {{ 'go_back'|_ }} - -

    -
    + + {% endfor %} + + +
    -
    +
    +
    +
    +
    + {{ 'csv_go_back'|_ }} + +
    +
    +
    +
    + {% endblock %} diff --git a/resources/twig/csv/download-config.twig b/resources/twig/csv/download-config.twig index e566d293ec..302670614d 100644 --- a/resources/twig/csv/download-config.twig +++ b/resources/twig/csv/download-config.twig @@ -7,34 +7,44 @@ {% block content %} -
    -
    -
    -
    -

    {{ 'csv_download_config'|_ }}

    +
    +
    +
    +
    +

    {{ 'csv_download_config_title'|_ }}

    + + +
    + +
    - -
    -
    +
    +

    + {{ 'csv_download_config_text'|_ }} +

    -
    -
    -

    - {{ 'csv_some_text'|_ }} -

    -

    - {{ 'csv_do_download_config'|_ }} -

    -

    - {{ 'csv_more_information_text'|_ }} -

    -

    - {{ 'csv_do_process'|_ }} -

    +

    + {{ 'csv_do_download_config'|_ }} +

    + +

    + {{ 'csv_more_information_text'|_ }} +

    +
    -
    -
    + + + {% endblock %} diff --git a/resources/twig/csv/index.twig b/resources/twig/csv/index.twig index 58b4c3f2b3..10f00c9cf2 100644 --- a/resources/twig/csv/index.twig +++ b/resources/twig/csv/index.twig @@ -7,32 +7,11 @@ {% block content %} -
    -
    -
    -
    -

    {{ 'csv'|_ }}

    - - -
    - -
    - -
    -
    - {{ 'csv_index_text'|_ }} -

    {{ 'csv_more_information' }}

    - {{ 'csv_more_information_text'|_ }} -
    -
    - -
    -
    -

    {{ 'csv_upload_form'|_ }}

    +

    {{ 'csv_index_title'|_ }}

    @@ -41,31 +20,48 @@
    + {{ 'csv_index_text'|_ }} +

    {{ 'csv_index_beta_warning'|_ }}

    + {% if unsupported|length > 0 %} +

    {{ 'csv_index_unsupported_warning'|_ }}

    +
      + {% for message in unsupported %} +
    • {{ message }}
    • + {% endfor %} +
    + {% endif %} +
    +
    + +
    +
    + +
    + + +
    +
    +
    +
    +

    {{ 'csv_upload_form'|_ }}

    + + +
    + +
    + +
    +
    - - {{ ExpandedForm.checkbox('has_headers',false,null,{helpText: 'csv_header_help'|_}) }} {{ ExpandedForm.text('date_format','Ymd',{helpText: 'csv_date_help'|_}) }} - {{ ExpandedForm.file('csv') }} + {{ ExpandedForm.file('csv',{helpText: 'csv_csv_file_help'|_}) }} - {{ ExpandedForm.file('csv_config') }} + {{ ExpandedForm.file('csv_config',{helpText: 'csv_csv_config_file_help'|_}) }} - {% if uploadPossible %} -
    -
    -   -
    - -
    - - -
    -
    - {% else %} + {% if not uploadPossible %}
      @@ -74,20 +70,31 @@
    {{ path }}

    - {{ 'upload_not_writeable'|_ }} + {{ 'csv_upload_not_writeable'|_ }}

    {% endif %} - - - - - +
    -
    + +
    +
    +
    +
    + +
    +
    +
    +
    + + + + {% endblock %} diff --git a/resources/twig/csv/map.twig b/resources/twig/csv/map.twig index 255abac3b0..97ce18b582 100644 --- a/resources/twig/csv/map.twig +++ b/resources/twig/csv/map.twig @@ -11,7 +11,7 @@
    -

    {{ 'csv_map'|_ }}

    +

    {{ 'csv_map_title'|_ }}

    @@ -20,7 +20,9 @@
    - Download config for use again +

    + {{ 'csv_map_text'|_ }} +

    @@ -35,7 +37,7 @@
    -

    {{ columnName }}

    +

    {{ Config.get('csv.roles.'~columnName~'.name') }}

    @@ -69,11 +71,21 @@
    {% endfor %} -

    - -

    + + +
    +
    +
    +
    + {{ 'csv_go_back'|_ }} + +
    +
    +
    +
    + From 910510430357f45c780ae996d87a15f9fa3a4ab4 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 08:47:16 +0200 Subject: [PATCH 22/60] Make CSV import a feature that can be turned on / off. --- app/Http/Controllers/CsvController.php | 6 +++++- config/firefly.php | 1 + resources/twig/partials/menu-sidebar.twig | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 03cfd5e63f..c56c7f1046 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -43,6 +43,10 @@ class CsvController extends Controller View::share('title', trans('firefly.csv')); View::share('mainTitleIcon', 'fa-file-text-o'); + if (Config::get('firefly.csv_import_enabled') === false) { + throw new FireflyException('CSV Import is not enabled.'); + } + $this->wizard = App::make('FireflyIII\Helpers\Csv\WizardInterface'); $this->data = App::make('FireflyIII\Helpers\Csv\Data'); @@ -170,7 +174,7 @@ class CsvController extends Controller $uploadPossible = is_writable(storage_path('upload')); $path = storage_path('upload'); - return view('csv.index', compact('subTitle', 'uploadPossible', 'path','unsupported')); + return view('csv.index', compact('subTitle', 'uploadPossible', 'path', 'unsupported')); } /** diff --git a/config/firefly.php b/config/firefly.php index e56f64e13e..81f741bd77 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -5,6 +5,7 @@ return [ 'version' => '3.4.6', 'index_periods' => ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'], 'budget_periods' => ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'], + 'csv_import_enabled' => false, 'piggy_bank_periods' => [ 'week' => 'Week', 'month' => 'Month', diff --git a/resources/twig/partials/menu-sidebar.twig b/resources/twig/partials/menu-sidebar.twig index 76bc4f4cfb..c3bfafa52c 100644 --- a/resources/twig/partials/menu-sidebar.twig +++ b/resources/twig/partials/menu-sidebar.twig @@ -123,9 +123,11 @@
  • {{ 'currencies'|_ }}
  • + {% if Config.get('firefly.csv_import_enabled') %}
  • {{ 'csv_import'|_ }}
  • + {% endif %} From 60bb639351469c2e4a5bc25fa1d3ced8f9f2d055 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 08:52:35 +0200 Subject: [PATCH 23/60] Add IBAN to account list. --- resources/lang/en/list.php | 1 + resources/lang/nl/list.php | 4 ++-- resources/twig/list/accounts.twig | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/lang/en/list.php b/resources/lang/en/list.php index 4ad2805ede..d2c541c490 100644 --- a/resources/lang/en/list.php +++ b/resources/lang/en/list.php @@ -29,4 +29,5 @@ return [ 'transfer' => 'Transfer', 'type' => 'Type', 'completed' => 'Completed', + 'iban' => 'IBAN', ]; diff --git a/resources/lang/nl/list.php b/resources/lang/nl/list.php index a9a8a30b02..8eb2ac36e7 100644 --- a/resources/lang/nl/list.php +++ b/resources/lang/nl/list.php @@ -28,6 +28,6 @@ return [ 'deposit' => 'Inkomsten', 'transfer' => 'Overschrijving', 'type' => 'Type', - 'completed' => 'Opgeslagen' - + 'completed' => 'Opgeslagen', + 'iban' => 'IBAN', ]; diff --git a/resources/twig/list/accounts.twig b/resources/twig/list/accounts.twig index 4d782b7f57..cf06a1a359 100644 --- a/resources/twig/list/accounts.twig +++ b/resources/twig/list/accounts.twig @@ -6,6 +6,7 @@ {% if what == 'asset' %} {{ trans('list.role') }} {% endif %} + {{ trans('list.iban') }} {{ trans('list.currentBalance') }} {{ trans('list.active') }} {{ trans('list.lastActivity') }} @@ -31,6 +32,7 @@ {% endfor %} {% endif %} + {{ account.iban }} {{ account|balance|formatAmount }} {% if account.active %} From 3751106317295d79d6c7e9795346e8ef263000f0 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 09:05:51 +0200 Subject: [PATCH 24/60] Fix name in option list. --- resources/twig/form/options.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/twig/form/options.twig b/resources/twig/form/options.twig index 718110186d..8a25895f34 100644 --- a/resources/twig/form/options.twig +++ b/resources/twig/form/options.twig @@ -24,7 +24,7 @@
    From c2645894e00e54516202fa24e48b97dff6141d93 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 09:07:05 +0200 Subject: [PATCH 25/60] Allow update iban [skip ci] --- app/Models/Account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Account.php b/app/Models/Account.php index 9c061021d3..9cf4c7e37f 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -55,7 +55,7 @@ class Account extends Model { use SoftDeletes, ValidatingTrait; - protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance']; + protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance','iban']; protected $hidden = ['virtual_balance_encrypted', 'encrypted']; protected $rules = [ From 2d59d845bcc6982d5bfc52f29d85ad739fb165af Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 09:19:51 +0200 Subject: [PATCH 26/60] Account iban thing fix [skip ci] --- app/Http/Controllers/AccountController.php | 1 + app/Models/Account.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index f9dc21694b..6e8778949a 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -248,6 +248,7 @@ class AccountController extends Controller 'ccMonthlyPaymentDate' => $request->input('ccMonthlyPaymentDate'), ]; + $repository->update($account, $accountData); Session::flash('success', 'Account "' . $account->name . '" updated.'); diff --git a/app/Models/Account.php b/app/Models/Account.php index 9cf4c7e37f..9b77363657 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -55,13 +55,13 @@ class Account extends Model { use SoftDeletes, ValidatingTrait; - protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance','iban']; + protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban']; protected $hidden = ['virtual_balance_encrypted', 'encrypted']; protected $rules = [ 'user_id' => 'required|exists:users,id', 'account_type_id' => 'required|exists:account_types,id', - 'name' => 'required|between:1,1024|uniqueAccountForUser', + 'name' => 'required', 'active' => 'required|boolean' ]; From 9e7b730002cfcae22e9c776e7f8a7eec634bb11d Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 09:34:57 +0200 Subject: [PATCH 27/60] Somehow CSV reader got lost in translation. --- composer.json | 3 ++- composer.lock | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 2bdb37e207..d3fb277a16 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "league/commonmark": "0.7.*", "rcrowe/twigbridge": "0.7.x@dev", "zizaco/entrust": "dev-laravel-5", - "codeception/codeception": "*" + "codeception/codeception": "*", + "league/csv": "^7.1" }, "require-dev": { "barryvdh/laravel-debugbar": "@stable", diff --git a/composer.lock b/composer.lock index 5d8d22b521..7d5375499b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "ac0a3c8a66984034e157599940956412", + "hash": "16409d4004d305517bea330fcc6591a6", "packages": [ { "name": "classpreloader/classpreloader", @@ -1429,6 +1429,63 @@ ], "time": "2015-03-08 17:48:53" }, + { + "name": "league/csv", + "version": "7.1.2", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/csv.git", + "reference": "2ee1760c262c41986f6371775907fc9e8603fd26" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/csv/zipball/2ee1760c262c41986f6371775907fc9e8603fd26", + "reference": "2ee1760c262c41986f6371775907fc9e8603fd26", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "scrutinizer/ocular": "~1.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.1-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Csv\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignace Nyamagana Butera", + "email": "nyamsprod@gmail.com", + "homepage": "https://github.com/nyamsprod/", + "role": "Developer" + } + ], + "description": "Csv data manipulation made easy in PHP", + "homepage": "http://csv.thephpleague.com", + "keywords": [ + "csv", + "export", + "filter", + "import", + "read", + "write" + ], + "time": "2015-06-10 11:12:37" + }, { "name": "league/flysystem", "version": "1.0.4", From d7329a5915e5d3361434b355433f3cdcc28fd66b Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 14:37:36 +0200 Subject: [PATCH 28/60] Expanded CSV configuration. --- .../Chart/Bill/ChartJsBillChartGenerator.php | 6 -- app/Helpers/Csv/Converter/AccountIban.php | 51 ----------- app/Helpers/Csv/Converter/AccountId.php | 29 +++++++ app/Helpers/Csv/Converter/Amount.php | 6 -- .../Csv/Converter/AssetAccountIban.php | 51 +++++++++++ .../Csv/Converter/AssetAccountName.php | 50 +++++++++++ app/Helpers/Csv/Converter/BillId.php | 30 +++++++ app/Helpers/Csv/Converter/BillName.php | 38 ++++++++ .../Csv/Converter/ConverterInterface.php | 6 -- app/Helpers/Csv/Converter/Date.php | 6 -- .../Csv/Converter/RabobankDebetCredit.php | 6 -- app/Helpers/Csv/Importer.php | 86 +++++++++++++------ app/Helpers/Csv/Mapper/AssetAccount.php | 6 -- app/Http/Controllers/CsvController.php | 21 +++-- app/Http/Controllers/HomeController.php | 4 + app/Models/Account.php | 7 +- config/csv.php | 34 +++++--- resources/lang/en/firefly.php | 8 ++ resources/twig/csv/download-config.twig | 2 +- resources/twig/csv/index.twig | 2 +- resources/twig/csv/process.twig | 49 +++++++++++ 21 files changed, 363 insertions(+), 135 deletions(-) delete mode 100644 app/Helpers/Csv/Converter/AccountIban.php create mode 100644 app/Helpers/Csv/Converter/AccountId.php create mode 100644 app/Helpers/Csv/Converter/AssetAccountIban.php create mode 100644 app/Helpers/Csv/Converter/AssetAccountName.php create mode 100644 app/Helpers/Csv/Converter/BillId.php create mode 100644 app/Helpers/Csv/Converter/BillName.php create mode 100644 resources/twig/csv/process.twig diff --git a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php index 4afa0c6ea7..c7ba8172d5 100644 --- a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php +++ b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php @@ -1,10 +1,4 @@ mapped[$this->index][$this->value])) { - $account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]); - } else { - // find or create new account: - $accountType = AccountType::where('type', 'Asset account')->first(); - $account = Account::firstOrCreateEncrypted( - [ - 'name' => $this->value, - //'iban' => $this->value, - 'user_id' => Auth::user()->id, - 'account_type_id' => $accountType->id, - 'active' => true, - ] - ); - if ($account->getErrors()->count() > 0) { - Log::error('Create or find asset account: ' . json_encode($account->getErrors()->all())); - } - } - - return $account; - } -} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/AccountId.php b/app/Helpers/Csv/Converter/AccountId.php new file mode 100644 index 0000000000..ef555174a6 --- /dev/null +++ b/app/Helpers/Csv/Converter/AccountId.php @@ -0,0 +1,29 @@ +mapped[$this->index][$this->value])) { + $account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]); + } else { + $account = Auth::user()->accounts()->find($this->value); + } + + return $account; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/Amount.php b/app/Helpers/Csv/Converter/Amount.php index de2e9d5b08..38acf974b5 100644 --- a/app/Helpers/Csv/Converter/Amount.php +++ b/app/Helpers/Csv/Converter/Amount.php @@ -1,10 +1,4 @@ mapped[$this->index][$this->value])) { + $account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]); + + return $account; + } + // find or create new account: + $accountType = AccountType::where('type', 'Asset account')->first(); + $set = Auth::user()->accounts()->where('account_type_id', $accountType->id)->get(); + /** @var Account $entry */ + foreach ($set as $entry) { + if ($entry->iban == $this->value) { + return $entry; + } + } + + // create it if doesnt exist. + $account = Account::firstOrCreateEncrypted( + [ + 'name' => $this->value, + 'iban' => $this->value, + 'user_id' => Auth::user()->id, + 'account_type_id' => $accountType->id, + 'active' => 1, + ] + ); + + return $account; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/AssetAccountName.php b/app/Helpers/Csv/Converter/AssetAccountName.php new file mode 100644 index 0000000000..cf1ff1a666 --- /dev/null +++ b/app/Helpers/Csv/Converter/AssetAccountName.php @@ -0,0 +1,50 @@ +mapped[$this->index][$this->value])) { + $account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]); + + return $account; + } + // find or create new account: + $accountType = AccountType::where('type', 'Asset account')->first(); + $set = Auth::user()->accounts()->where('account_type_id', $accountType->id)->get(); + /** @var Account $entry */ + foreach ($set as $entry) { + if ($entry->name == $this->value) { + return $entry; + } + } + + // create it if doesnt exist. + $account = Account::firstOrCreateEncrypted( + [ + 'name' => $this->value, + 'iban' => '', + 'user_id' => Auth::user()->id, + 'account_type_id' => $accountType->id, + 'active' => 1, + ] + ); + + return $account; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/BillId.php b/app/Helpers/Csv/Converter/BillId.php new file mode 100644 index 0000000000..975ce66771 --- /dev/null +++ b/app/Helpers/Csv/Converter/BillId.php @@ -0,0 +1,30 @@ +mapped[$this->index][$this->value])) { + $bill = Auth::user()->bills()->find($this->mapped[$this->index][$this->value]); + } else { + $bill = Auth::user()->bills()->find($this->value); + } + + return $bill; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/BillName.php b/app/Helpers/Csv/Converter/BillName.php new file mode 100644 index 0000000000..4e15b1bdbd --- /dev/null +++ b/app/Helpers/Csv/Converter/BillName.php @@ -0,0 +1,38 @@ +mapped[$this->index][$this->value])) { + $bill = Auth::user()->bills()->find($this->mapped[$this->index][$this->value]); + } else { + + $bills = Auth::user()->bills()->get(); + /** @var Bill $bill */ + foreach ($bills as $bill) { + if ($bill->name == $this->value) { + return $bill; + } + } + } + + return $bill; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/ConverterInterface.php b/app/Helpers/Csv/Converter/ConverterInterface.php index 1e9eb275e3..aad4e3999a 100644 --- a/app/Helpers/Csv/Converter/ConverterInterface.php +++ b/app/Helpers/Csv/Converter/ConverterInterface.php @@ -1,10 +1,4 @@ errors; + } + + /** + * @return int + */ + public function getImported() + { + return $this->imported; + } + + /** + * @return int + */ + public function getRows() + { + return $this->rows; + } + + /** + * @throws FireflyException */ public function run() { @@ -46,15 +76,18 @@ class Importer $this->roles = $this->data->getRoles(); $this->mapped = $this->data->getMapped(); foreach ($this->data->getReader() as $index => $row) { - Log::debug('Now at row ' . $index); - $result = $this->importRow($row); - if (!($result === true)) { - Log::error('Caught error at row #' . $index . ': ' . $result); - $this->errors[$index] = $result; + if (($this->data->getHasHeaders() && $index > 1) || !$this->data->getHasHeaders()) { + $this->rows++; + Log::debug('Now at row ' . $index); + $result = $this->importRow($row); + if (!($result === true)) { + Log::error('Caught error at row #' . $index . ': ' . $result); + $this->errors[$index] = $result; + } else { + $this->imported++; + } } } - - return count($this->errors); } /** @@ -80,8 +113,12 @@ class Importer if (is_null($field)) { throw new FireflyException('No place to store value of type "' . $role . '".'); } - /** @var ConverterInterface $converter */ - $converter = App::make('FireflyIII\Helpers\Csv\Converter\\' . $class); + try { + /** @var ConverterInterface $converter */ + $converter = App::make('FireflyIII\Helpers\Csv\Converter\\' . $class); + } catch (ReflectionException $e) { + throw new FireflyException('Cannot continue with column of type "' . $role . '" because class "' . $class . '" cannot be found.'); + } $converter->setData($data); // the complete array so far. $converter->setField($field); $converter->setIndex($index); @@ -122,6 +159,8 @@ class Importer 'amount-modifier' => 1, 'ignored' => null, 'date-rent' => null, + 'bill' => null, + 'bill-id' => null, ]; } @@ -147,19 +186,27 @@ class Importer $accountType = AccountType::where('type', 'Revenue account')->first(); } - if(strlen($data['description']) == 0) { + if (strlen($data['description']) == 0) { $data['description'] = trans('firefly.csv_empty_description'); } + // fix currency + if (is_null($data['currency'])) { + $currencyPreference = Preferences::get('currencyPreference', 'EUR'); + $data['currency'] = TransactionCurrency::whereCode($currencyPreference->data)->first(); + } + if (!is_null($data['bill'])) { + $data['bill-id'] = $data['bill']->id; + } // do bank specific fixes: $specifix = new Specifix(); $specifix->setData($data); $specifix->setRow($row); - $specifix->fix($data, $row); + //$specifix->fix($data, $row); // TODO // get data back: - $data = $specifix->getData(); + //$data = $specifix->getData(); // TODO $data['opposing-account-object'] = Account::firstOrCreateEncrypted( [ @@ -215,11 +262,11 @@ class Importer [ 'user_id' => Auth::user()->id, 'transaction_type_id' => $transactionType->id, - 'bill_id' => null, 'transaction_currency_id' => $data['currency']->id, 'description' => $data['description'], 'completed' => 0, 'date' => $date, + 'bill_id' => $data['bill-id'], ] ); $errors = $journal->getErrors()->merge($errors); @@ -261,14 +308,5 @@ class Importer $this->data = $data; } - /** - * @param $value - * - * @return Carbon - */ - protected function parseDate($value) - { - return Carbon::createFromFormat($this->data->getDateFormat(), $value); - } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/AssetAccount.php b/app/Helpers/Csv/Mapper/AssetAccount.php index d8fe71cc2d..44982539b5 100644 --- a/app/Helpers/Csv/Mapper/AssetAccount.php +++ b/app/Helpers/Csv/Mapper/AssetAccount.php @@ -1,10 +1,4 @@ data->getReader()->fetchOne(); $count = count($firstRow); $headers = []; - $example = $this->data->getReader()->fetchOne(); + $example = $this->data->getReader()->fetchOne(1); $availableRoles = []; $roles = $this->data->getRoles(); $map = $this->data->getMap(); @@ -166,6 +161,9 @@ class CsvController extends Controller if ($role['mappable'] === true && !isset($role['mapper'])) { $unsupported[] = trans('firefly.csv_unsupported_map', ['columnRole' => $role['name']]); } + if (!isset($role['field'])) { + $unsupported[] = trans('firefly.csv_cannot_store_value', ['columnRole' => $role['name']]); + } } sort($unsupported); @@ -309,8 +307,13 @@ class CsvController extends Controller } Log::debug('Done importing!'); - echo 'display result'; - exit; + $rows = $importer->getRows(); + $errors = $importer->getErrors(); + $imported = $importer->getImported(); + + Preferences::mark(); + + return view('csv.process', compact('rows', 'errors', 'imported')); } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 987967585c..d57649bd24 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -40,6 +40,9 @@ class HomeController extends Controller */ public function flush() { + + Preferences::mark(); + // get all tags. // update all counts: $tags = Tag::get(); @@ -54,6 +57,7 @@ class HomeController extends Controller } + Session::clear(); return Redirect::route('index'); diff --git a/app/Models/Account.php b/app/Models/Account.php index 9b77363657..42bf226a20 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -76,7 +76,7 @@ class Account extends Model // everything but the name: $query = Account::orderBy('id'); foreach ($fields as $name => $value) { - if ($name != 'name') { + if ($name != 'name' && $name != 'iban') { $query->where($name, $value); } } @@ -87,6 +87,11 @@ class Account extends Model return $account; } } + // account must have a name. If not set, use IBAN. + if (!isset($fields['name'])) { + $fields['name'] = $fields['iban']; + } + // create it! $account = Account::create($fields); diff --git a/config/csv.php b/config/csv.php index e141c2f438..f5ebdad7fa 100644 --- a/config/csv.php +++ b/config/csv.php @@ -8,12 +8,16 @@ return [ 'field' => 'ignored', ], 'bill-id' => [ - 'name' => 'Bill ID (matching Firefly)', - 'mappable' => true, + 'name' => 'Bill ID (matching Firefly)', + 'mappable' => false, + 'field' => 'bill', + 'converter' => 'BillId' ], 'bill-name' => [ - 'name' => 'Bill name', - 'mappable' => true, + 'name' => 'Bill name', + 'mappable' => true, + 'converter' => 'BillName', + 'field' => 'bill', ], 'currency-id' => [ 'name' => 'Currency ID (matching Firefly)', @@ -83,32 +87,38 @@ return [ 'mappable' => true, ], 'account-id' => [ - 'name' => 'Asset account ID (matching Firefly)', - 'mappable' => true, + 'name' => 'Asset account ID (matching Firefly)', + 'mappable' => true, + 'mapper' => 'AssetAccount', + 'field' => 'asset-account', + 'converter' => 'AccountId' ], 'account-name' => [ - 'name' => 'Asset account name', - 'mappable' => true, + 'name' => 'Asset account name', + 'mappable' => true, + 'mapper' => 'AssetAccount', + 'field' => 'asset-account', + 'converter' => 'AssetAccountName' ], 'account-iban' => [ 'name' => 'Asset account IBAN', 'mappable' => true, - 'converter' => 'AccountIban', + 'converter' => 'AssetAccountIban', 'field' => 'asset-account', 'mapper' => 'AssetAccount' ], 'opposing-id' => [ - 'name' => 'Expense or revenue account ID (matching Firefly)', + 'name' => 'Opposing account account ID (matching Firefly)', 'mappable' => true, ], 'opposing-name' => [ - 'name' => 'Expense or revenue account name', + 'name' => 'Opposing account name', 'mappable' => true, 'converter' => 'OpposingName', 'field' => 'opposing-account' ], 'opposing-iban' => [ - 'name' => 'Expense or revenue account IBAN', + 'name' => 'Opposing account IBAN', 'mappable' => true, ], 'amount' => [ diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php index 1374379ef4..85a663d095 100644 --- a/resources/lang/en/firefly.php +++ b/resources/lang/en/firefly.php @@ -62,6 +62,14 @@ return [ 'csv_index_unsupported_warning' => 'The CSV importer is yet incapable of doing the following:', 'csv_unsupported_map' => 'The importer cannot map the column ":columnRole" to existing values in the database.', 'csv_unsupported_value' => 'The importer does not know how to handle values in columns marked as ":columnRole".', + 'csv_cannot_store_value' => 'The importer has not reserved space for columns marked ":columnRole" and will be incapable of processing them.', + 'csv_process_title' => 'CVS import finished', + 'csv_process_text' => 'The CVS importer has finished and has imported :rows rows', + 'csv_row' => 'Row', + 'csv_import_with_errors' => 'There was one error.|There were :errors errors.', + 'csv_error_see_logs' => 'Check the log files to see details.', + 'csv_start_over' => 'Import again', + 'csv_to_index' => 'Back home', // 'csv_index_text' => 'Here be explanation.', // 'csv_upload_form' => 'Upload form', // 'upload_csv_file' => 'Upload CSV file', diff --git a/resources/twig/csv/download-config.twig b/resources/twig/csv/download-config.twig index 302670614d..c1f8a7eb88 100644 --- a/resources/twig/csv/download-config.twig +++ b/resources/twig/csv/download-config.twig @@ -40,7 +40,7 @@
    diff --git a/resources/twig/csv/index.twig b/resources/twig/csv/index.twig index 10f00c9cf2..7e8e79c97f 100644 --- a/resources/twig/csv/index.twig +++ b/resources/twig/csv/index.twig @@ -54,7 +54,7 @@
    - {{ ExpandedForm.checkbox('has_headers',false,null,{helpText: 'csv_header_help'|_}) }} + {{ ExpandedForm.checkbox('has_headers',1,null,{helpText: 'csv_header_help'|_}) }} {{ ExpandedForm.text('date_format','Ymd',{helpText: 'csv_date_help'|_}) }} {{ ExpandedForm.file('csv',{helpText: 'csv_csv_file_help'|_}) }} diff --git a/resources/twig/csv/process.twig b/resources/twig/csv/process.twig new file mode 100644 index 0000000000..c45a882d20 --- /dev/null +++ b/resources/twig/csv/process.twig @@ -0,0 +1,49 @@ +{% extends "./layout/default.twig" %} + +{% block breadcrumbs %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +{% endblock %} + +{% block content %} + + +
    +
    +
    +
    +

    {{ 'csv_process_title'|_ }}

    + + +
    + +
    + +
    +
    +

    + + {{ trans('firefly.csv_process_text',{rows: rows}) }} +

    + + {% if errors|length > 0 %} +

    {{ Lang.choice('firefly.csv_import_with_errors',errors|length,{errors: errors|length}) }}

    +
      + {% for index,err in errors %} +
    • {{ 'csv_row'|_ }} #{{ index }}: {{ err }}
    • + {% endfor %} +
    +

    + {{ trans('firefly.csv_error_see_logs') }} +

    + {% endif %} +

    + {{ 'csv_start_over'|_ }} + {{ 'csv_to_index'|_ }} + +

    +
    +
    + +
    +
    +{% endblock %} From 601f9f86bb993178cd3c4c76a55c9f954febe9f8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 15:16:44 +0200 Subject: [PATCH 29/60] Some more importers. --- app/Helpers/Csv/Converter/BudgetId.php | 29 +++++++++++ app/Helpers/Csv/Converter/BudgetName.php | 35 +++++++++++++ app/Helpers/Csv/Converter/CategoryId.php | 29 +++++++++++ app/Helpers/Csv/Converter/CategoryName.php | 34 ++++++++++++ app/Helpers/Csv/Converter/CurrencyId.php | 28 ++++++++++ app/Helpers/Csv/Converter/CurrencyName.php | 27 ++++++++++ app/Helpers/Csv/Converter/CurrencySymbol.php | 28 ++++++++++ app/Helpers/Csv/Converter/OpposingName.php | 2 +- app/Helpers/Csv/Importer.php | 55 +++++++++++++++----- config/csv.php | 51 +++++++++++------- 10 files changed, 285 insertions(+), 33 deletions(-) create mode 100644 app/Helpers/Csv/Converter/BudgetId.php create mode 100644 app/Helpers/Csv/Converter/BudgetName.php create mode 100644 app/Helpers/Csv/Converter/CategoryId.php create mode 100644 app/Helpers/Csv/Converter/CategoryName.php create mode 100644 app/Helpers/Csv/Converter/CurrencyId.php create mode 100644 app/Helpers/Csv/Converter/CurrencyName.php create mode 100644 app/Helpers/Csv/Converter/CurrencySymbol.php diff --git a/app/Helpers/Csv/Converter/BudgetId.php b/app/Helpers/Csv/Converter/BudgetId.php new file mode 100644 index 0000000000..daaec82688 --- /dev/null +++ b/app/Helpers/Csv/Converter/BudgetId.php @@ -0,0 +1,29 @@ +mapped[$this->index][$this->value])) { + $budget = Auth::user()->budgets()->find($this->mapped[$this->index][$this->value]); + } else { + $budget = Auth::user()->budgets()->find($this->value); + } + + return $budget; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/BudgetName.php b/app/Helpers/Csv/Converter/BudgetName.php new file mode 100644 index 0000000000..26ff92a1ec --- /dev/null +++ b/app/Helpers/Csv/Converter/BudgetName.php @@ -0,0 +1,35 @@ +mapped[$this->index][$this->value])) { + $budget = Auth::user()->budgets()->find($this->mapped[$this->index][$this->value]); + } else { + $budget = Budget::firstOrCreateEncrypted( + [ + 'name' => $this->value, + 'user_id' => Auth::user()->id, + 'active' => true, + ] + ); + } + + return $budget; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/CategoryId.php b/app/Helpers/Csv/Converter/CategoryId.php new file mode 100644 index 0000000000..9b6b089d37 --- /dev/null +++ b/app/Helpers/Csv/Converter/CategoryId.php @@ -0,0 +1,29 @@ +mapped[$this->index][$this->value])) { + $category = Auth::user()->categories()->find($this->mapped[$this->index][$this->value]); + } else { + $category = Auth::user()->categories()->find($this->value); + } + + return $category; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/CategoryName.php b/app/Helpers/Csv/Converter/CategoryName.php new file mode 100644 index 0000000000..5a35ecbcb9 --- /dev/null +++ b/app/Helpers/Csv/Converter/CategoryName.php @@ -0,0 +1,34 @@ +mapped[$this->index][$this->value])) { + $category = Auth::user()->categories()->find($this->mapped[$this->index][$this->value]); + } else { + $category = Category::firstOrCreateEncrypted( + [ + 'name' => $this->value, + 'user_id' => Auth::user()->id + ] + ); + } + + return $category; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/CurrencyId.php b/app/Helpers/Csv/Converter/CurrencyId.php new file mode 100644 index 0000000000..1544acae83 --- /dev/null +++ b/app/Helpers/Csv/Converter/CurrencyId.php @@ -0,0 +1,28 @@ +mapped[$this->index][$this->value])) { + $currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]); + } else { + $currency = TransactionCurrency::find($this->value); + } + + return $currency; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/CurrencyName.php b/app/Helpers/Csv/Converter/CurrencyName.php new file mode 100644 index 0000000000..8788de2397 --- /dev/null +++ b/app/Helpers/Csv/Converter/CurrencyName.php @@ -0,0 +1,27 @@ +mapped[$this->index][$this->value])) { + $currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]); + } else { + $currency = TransactionCurrency::whereName($this->value)->first(); + } + + return $currency; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/CurrencySymbol.php b/app/Helpers/Csv/Converter/CurrencySymbol.php new file mode 100644 index 0000000000..957674751f --- /dev/null +++ b/app/Helpers/Csv/Converter/CurrencySymbol.php @@ -0,0 +1,28 @@ +mapped[$this->index][$this->value])) { + $currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]); + } else { + $currency = TransactionCurrency::whereSymbol($this->value)->first(); + } + + return $currency; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/OpposingName.php b/app/Helpers/Csv/Converter/OpposingName.php index 25ab7b00be..6a0662db29 100644 --- a/app/Helpers/Csv/Converter/OpposingName.php +++ b/app/Helpers/Csv/Converter/OpposingName.php @@ -11,7 +11,7 @@ class OpposingName extends BasicConverter implements ConverterInterface { /** - * This method cannot search yet for the correct account (Expense account or Revenue account) because simply put, + * This method cannot search yet for the correct account (Expense account, Revenue account or Asset account) because simply put, * Firefly doesn't know yet if this account needs to be an Expense account or a Revenue account. This depends * on the amount which is in the current row and that's a big unknown. * diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 65cdceb4e9..b179a9acd0 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -148,20 +148,16 @@ class Importer */ protected function getFiller() { - return [ - 'description' => '', - 'asset-account' => null, - 'opposing-account' => '', - 'opposing-account-object' => null, - 'date' => null, - 'currency' => null, - 'amount' => null, - 'amount-modifier' => 1, - 'ignored' => null, - 'date-rent' => null, - 'bill' => null, - 'bill-id' => null, - ]; + $filler = []; + foreach (Config::get('csv.roles') as $role) { + $fieldName = $role['field']; + $filler[$fieldName] = null; + } + // some extra's: + $filler['bill-id'] = null; + $filler['opposing-account-object'] = null; + + return $filler; } @@ -178,6 +174,11 @@ class Importer bcscale(2); $data['description'] = trim($data['description']); $data['amount'] = bcmul($data['amount'], $data['amount-modifier']); + + // get opposing account, which is quite complex: + $data['opposing-account-object'] = $this->processOpposingAccount($data); + + // opposing account type: if ($data['amount'] < 0) { // create expense account: $accountType = AccountType::where('type', 'Expense account')->first(); @@ -220,6 +221,22 @@ class Importer return $data; } + /** + * @param array $data + */ + public function processOpposingAccount(array $data) + { + // first priority. try to find the account based on ID, + // if any. + + // second: try to find the account based on IBAN, if any. + + // third: try to find account based on name, if any. + + // if nothing, create expense/revenue, never asset. + + } + /** * @param $data * @@ -295,6 +312,16 @@ class Importer $journal->save(); } + // add budget: + if (!is_null($data['budget'])) { + $journal->budgets()->save($data['budget']); + } + + // add category: + if (!is_null($data['category'])) { + $journal->categories()->save($data['category']); + } + return $journal; diff --git a/config/csv.php b/config/csv.php index f5ebdad7fa..6164cf280c 100644 --- a/config/csv.php +++ b/config/csv.php @@ -20,12 +20,16 @@ return [ 'field' => 'bill', ], 'currency-id' => [ - 'name' => 'Currency ID (matching Firefly)', - 'mappable' => true, + 'name' => 'Currency ID (matching Firefly)', + 'mappable' => true, + 'converter' => 'CurrencyId', + 'field' => 'currency', ], 'currency-name' => [ - 'name' => 'Currency name (matching Firefly)', - 'mappable' => true, + 'name' => 'Currency name (matching Firefly)', + 'mappable' => true, + 'converter' => 'CurrencyName', + 'field' => 'currency', ], 'currency-code' => [ 'name' => 'Currency code (ISO 4217)', @@ -35,8 +39,10 @@ return [ 'mapper' => 'TransactionCurrency' ], 'currency-symbol' => [ - 'name' => 'Currency symbol (matching Firefly)', - 'mappable' => true, + 'name' => 'Currency symbol (matching Firefly)', + 'mappable' => true, + 'converter' => 'CurrencySymbol', + 'field' => 'currency', ], 'description' => [ 'name' => 'Description', @@ -57,12 +63,16 @@ return [ 'field' => 'date-rent', ], 'budget-id' => [ - 'name' => 'Budget ID (matching Firefly)', - 'mappable' => true, + 'name' => 'Budget ID (matching Firefly)', + 'mappable' => true, + 'converter' => 'BudgetId', + 'field' => 'budget' ], 'budget-name' => [ - 'name' => 'Budget name', - 'mappable' => true, + 'name' => 'Budget name', + 'mappable' => true, + 'converter' => 'BudgetName', + 'field' => 'budget' ], 'rabo-debet-credit' => [ 'name' => 'Rabobank specific debet/credit indicator', @@ -71,12 +81,16 @@ return [ 'field' => 'amount-modifier', ], 'category-id' => [ - 'name' => 'Category ID (matching Firefly)', - 'mappable' => true, + 'name' => 'Category ID (matching Firefly)', + 'mappable' => true, + 'converter' => 'CategoryId', + 'field' => 'category' ], 'category-name' => [ - 'name' => 'Category name', - 'mappable' => true, + 'name' => 'Category name', + 'mappable' => true, + 'converter' => 'CategoryName', + 'field' => 'category' ], 'tags-comma' => [ 'name' => 'Tags (comma separated)', @@ -110,16 +124,17 @@ return [ 'opposing-id' => [ 'name' => 'Opposing account account ID (matching Firefly)', 'mappable' => true, + 'field' => 'opposing-account-id', ], 'opposing-name' => [ - 'name' => 'Opposing account name', - 'mappable' => true, - 'converter' => 'OpposingName', - 'field' => 'opposing-account' + 'name' => 'Opposing account name', + 'mappable' => true, + 'field' => 'opposing-account-name', ], 'opposing-iban' => [ 'name' => 'Opposing account IBAN', 'mappable' => true, + 'field' => 'opposing-account-iban', ], 'amount' => [ 'name' => 'Amount', From 12ee5da872500dbbcf07e9c0da570a971634b9e7 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 16:39:25 +0200 Subject: [PATCH 30/60] Massively complex but working never the less. --- .../Csv/Converter/OpposingAccountIban.php | 39 +++++++ .../Csv/Converter/OpposingAccountId.php | 32 +++++ .../Csv/Converter/OpposingAccountName.php | 31 +++++ app/Helpers/Csv/Converter/OpposingName.php | 24 ---- app/Helpers/Csv/Importer.php | 109 +++++++++++++----- config/csv.php | 9 +- 6 files changed, 191 insertions(+), 53 deletions(-) create mode 100644 app/Helpers/Csv/Converter/OpposingAccountIban.php create mode 100644 app/Helpers/Csv/Converter/OpposingAccountId.php create mode 100644 app/Helpers/Csv/Converter/OpposingAccountName.php delete mode 100644 app/Helpers/Csv/Converter/OpposingName.php diff --git a/app/Helpers/Csv/Converter/OpposingAccountIban.php b/app/Helpers/Csv/Converter/OpposingAccountIban.php new file mode 100644 index 0000000000..cbd4b70a73 --- /dev/null +++ b/app/Helpers/Csv/Converter/OpposingAccountIban.php @@ -0,0 +1,39 @@ +mapped[$this->index][$this->value])) { + $account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]); + + return $account; + } else { + $set = Auth::user()->accounts()->get(); + /** @var Account $account */ + foreach ($set as $account) { + if ($account->iban == $this->value) { + return $account; + } + } + + return $this->value; + } + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/OpposingAccountId.php b/app/Helpers/Csv/Converter/OpposingAccountId.php new file mode 100644 index 0000000000..8d14ab5e75 --- /dev/null +++ b/app/Helpers/Csv/Converter/OpposingAccountId.php @@ -0,0 +1,32 @@ +mapped[$this->index][$this->value])) { + $account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]); + + } else { + $account = Auth::user()->accounts()->find($this->value); + } + + return $account; + + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/OpposingAccountName.php b/app/Helpers/Csv/Converter/OpposingAccountName.php new file mode 100644 index 0000000000..835ae0ad7c --- /dev/null +++ b/app/Helpers/Csv/Converter/OpposingAccountName.php @@ -0,0 +1,31 @@ +mapped[$this->index][$this->value])) { + $account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]); + + return $account; + } else { + return $this->value; + } + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/OpposingName.php b/app/Helpers/Csv/Converter/OpposingName.php deleted file mode 100644 index 6a0662db29..0000000000 --- a/app/Helpers/Csv/Converter/OpposingName.php +++ /dev/null @@ -1,24 +0,0 @@ -value; - } -} \ No newline at end of file diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index b179a9acd0..df16ab374d 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -150,12 +150,15 @@ class Importer { $filler = []; foreach (Config::get('csv.roles') as $role) { - $fieldName = $role['field']; - $filler[$fieldName] = null; + if (isset($role['field'])) { + $fieldName = $role['field']; + $filler[$fieldName] = null; + } } // some extra's: $filler['bill-id'] = null; $filler['opposing-account-object'] = null; + $filler['amount-modifier'] = '1'; return $filler; @@ -175,18 +178,10 @@ class Importer $data['description'] = trim($data['description']); $data['amount'] = bcmul($data['amount'], $data['amount-modifier']); + // get opposing account, which is quite complex: $data['opposing-account-object'] = $this->processOpposingAccount($data); - // opposing account type: - if ($data['amount'] < 0) { - // create expense account: - $accountType = AccountType::where('type', 'Expense account')->first(); - } else { - // create revenue account: - $accountType = AccountType::where('type', 'Revenue account')->first(); - } - if (strlen($data['description']) == 0) { $data['description'] = trans('firefly.csv_empty_description'); } @@ -205,36 +200,101 @@ class Importer $specifix->setData($data); $specifix->setRow($row); //$specifix->fix($data, $row); // TODO - // get data back: //$data = $specifix->getData(); // TODO - $data['opposing-account-object'] = Account::firstOrCreateEncrypted( - [ - 'user_id' => Auth::user()->id, - 'name' => ucwords($data['opposing-account']), - 'account_type_id' => $accountType->id, - 'active' => 1, - ] - ); - return $data; } /** * @param array $data */ - public function processOpposingAccount(array $data) + protected function processOpposingAccount(array $data) { // first priority. try to find the account based on ID, // if any. + if ($data['opposing-account-id'] instanceof Account) { + return $data['opposing-account-id']; + } // second: try to find the account based on IBAN, if any. + if ($data['opposing-account-iban'] instanceof Account) { + return $data['opposing-account-iban']; + } + + $accountType = $this->getAccountType($data['amount']); + + if (is_string($data['opposing-account-iban'])) { + $accounts = Auth::user()->accounts()->where('account_type_id', $accountType->id)->get(); + foreach ($accounts as $entry) { + if ($entry->iban == $data['opposing-account-iban']) { + + //return $entry; + } + } + // create if not exists: + $account = Account::firstOrCreateEncrypted( + [ + 'user_id' => Auth::user()->id, + 'account_type_id' => $accountType->id, + 'name' => $data['opposing-account-iban'], + 'iban' => $data['opposing-account-iban'], + 'active' => true, + ] + ); + + return $account; + + } // third: try to find account based on name, if any. + if ($data['opposing-account-name'] instanceof Account) { + return $data['opposing-account-name']; + } - // if nothing, create expense/revenue, never asset. + if (is_string($data['opposing-account-name'])) { + $accounts = Auth::user()->accounts()->where('account_type_id', $accountType->id)->get(); + foreach ($accounts as $entry) { + if ($entry->name == $data['opposing-account-name']) { + return $entry; + } + } + // create if not exists: + $account = Account::firstOrCreateEncrypted( + [ + 'user_id' => Auth::user()->id, + 'account_type_id' => $accountType->id, + 'name' => $data['opposing-account-name'], + 'iban' => '', + 'active' => true, + ] + ); + return $account; + } + return null; + + // if nothing, create expense/revenue, never asset. TODO + + } + + /** + * @param $amount + * + * @return AccountType + */ + protected function getAccountType($amount) + { + // opposing account type: + if ($amount < 0) { + // create expense account: + + return AccountType::where('type', 'Expense account')->first(); + } else { + // create revenue account: + + return AccountType::where('type', 'Revenue account')->first(); + } } /** @@ -247,9 +307,6 @@ class Importer if (is_null($data['date']) && is_null($data['date-rent'])) { return 'No date value for this row.'; } - if (strlen($data['description']) == 0) { - return 'No valid description'; - } if (is_null($data['opposing-account-object'])) { return 'Opposing account is null'; } diff --git a/config/csv.php b/config/csv.php index 6164cf280c..1fcd459bc6 100644 --- a/config/csv.php +++ b/config/csv.php @@ -122,19 +122,22 @@ return [ 'mapper' => 'AssetAccount' ], 'opposing-id' => [ - 'name' => 'Opposing account account ID (matching Firefly)', - 'mappable' => true, - 'field' => 'opposing-account-id', + 'name' => 'Opposing account account ID (matching Firefly)', + 'mappable' => true, + 'field' => 'opposing-account-id', + 'converter' => 'OpposingAccountId' ], 'opposing-name' => [ 'name' => 'Opposing account name', 'mappable' => true, 'field' => 'opposing-account-name', + 'converter' => 'OpposingAccountName' ], 'opposing-iban' => [ 'name' => 'Opposing account IBAN', 'mappable' => true, 'field' => 'opposing-account-iban', + 'converter' => 'OpposingAccountIban' ], 'amount' => [ 'name' => 'Amount', From 18b038d8ff1400532f9fb831cf0c2d97cd402f9e Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 18:18:44 +0200 Subject: [PATCH 31/60] Fixed most importers. --- app/Helpers/Csv/Converter/TagsComma.php | 40 ++++++ app/Helpers/Csv/Converter/TagsSpace.php | 40 ++++++ app/Helpers/Csv/Importer.php | 165 ++++++------------------ app/Helpers/Csv/Mapper/AnyAccount.php | 32 +++++ app/Helpers/Csv/Mapper/AssetAccount.php | 2 + app/Helpers/Csv/Mapper/Bill.php | 32 +++++ app/Helpers/Csv/Mapper/Budget.php | 32 +++++ app/Helpers/Csv/Mapper/Category.php | 32 +++++ app/Helpers/Csv/Mapper/Tag.php | 32 +++++ app/Helpers/Csv/OpposingAccount.php | 137 ++++++++++++++++++++ app/Http/Controllers/CsvController.php | 1 + config/csv.php | 54 +++++--- 12 files changed, 459 insertions(+), 140 deletions(-) create mode 100644 app/Helpers/Csv/Converter/TagsComma.php create mode 100644 app/Helpers/Csv/Converter/TagsSpace.php create mode 100644 app/Helpers/Csv/Mapper/AnyAccount.php create mode 100644 app/Helpers/Csv/Mapper/Bill.php create mode 100644 app/Helpers/Csv/Mapper/Budget.php create mode 100644 app/Helpers/Csv/Mapper/Category.php create mode 100644 app/Helpers/Csv/Mapper/Tag.php create mode 100644 app/Helpers/Csv/OpposingAccount.php diff --git a/app/Helpers/Csv/Converter/TagsComma.php b/app/Helpers/Csv/Converter/TagsComma.php new file mode 100644 index 0000000000..73ad4aa71f --- /dev/null +++ b/app/Helpers/Csv/Converter/TagsComma.php @@ -0,0 +1,40 @@ +value); + foreach ($strings as $string) { + $tag = Tag::firstOrCreateEncrypted( + [ + 'tag' => $string, + 'tagMode' => 'nothing', + 'user_id' => Auth::user()->id, + ] + ); + $tags->push($tag); + } + $tags = $tags->merge($this->data['tags']); + + return $tags; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/TagsSpace.php b/app/Helpers/Csv/Converter/TagsSpace.php new file mode 100644 index 0000000000..6e0353832d --- /dev/null +++ b/app/Helpers/Csv/Converter/TagsSpace.php @@ -0,0 +1,40 @@ +value); + foreach ($strings as $string) { + $tag = Tag::firstOrCreateEncrypted( + [ + 'tag' => $string, + 'tagMode' => 'nothing', + 'user_id' => Auth::user()->id, + ] + ); + $tags->push($tag); + } + $tags = $tags->merge($this->data['tags']); + + return $tags; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index df16ab374d..83c9f1553b 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -7,8 +7,6 @@ use Auth; use Config; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Csv\Converter\ConverterInterface; -use FireflyIII\Models\Account; -use FireflyIII\Models\AccountType; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionJournal; @@ -16,7 +14,6 @@ use FireflyIII\Models\TransactionType; use Illuminate\Support\MessageBag; use Log; use Preferences; -use ReflectionException; set_time_limit(0); @@ -75,10 +72,10 @@ class Importer $this->map = $this->data->getMap(); $this->roles = $this->data->getRoles(); $this->mapped = $this->data->getMapped(); + foreach ($this->data->getReader() as $index => $row) { - if (($this->data->getHasHeaders() && $index > 1) || !$this->data->getHasHeaders()) { + if ($this->parseRow($index)) { $this->rows++; - Log::debug('Now at row ' . $index); $result = $this->importRow($row); if (!($result === true)) { Log::error('Caught error at row #' . $index . ': ' . $result); @@ -90,6 +87,16 @@ class Importer } } + /** + * @param int $index + * + * @return bool + */ + protected function parseRow($index) + { + return (($this->data->getHasHeaders() && $index > 1) || !$this->data->getHasHeaders()); + } + /** * @param $row * @@ -107,18 +114,8 @@ class Importer $class = Config::get('csv.roles.' . $role . '.converter'); $field = Config::get('csv.roles.' . $role . '.field'); - if (is_null($class)) { - throw new FireflyException('No converter for field of type "' . $role . '".'); - } - if (is_null($field)) { - throw new FireflyException('No place to store value of type "' . $role . '".'); - } - try { - /** @var ConverterInterface $converter */ - $converter = App::make('FireflyIII\Helpers\Csv\Converter\\' . $class); - } catch (ReflectionException $e) { - throw new FireflyException('Cannot continue with column of type "' . $role . '" because class "' . $class . '" cannot be found.'); - } + /** @var ConverterInterface $converter */ + $converter = App::make('FireflyIII\Helpers\Csv\Converter\\' . $class); $converter->setData($data); // the complete array so far. $converter->setField($field); $converter->setIndex($index); @@ -128,7 +125,8 @@ class Importer $data[$field] = $converter->convert(); } - $data = $this->postProcess($data, $row); + // post processing and validating. + $data = $this->postProcess($data); $result = $this->validateData($data); if ($result === true) { $result = $this->createTransactionJournal($data); @@ -168,37 +166,42 @@ class Importer * Row denotes the original data. * * @param array $data - * @param array $row * * @return array */ - protected function postProcess(array $data, array $row) + protected function postProcess(array $data) { + // fix two simple fields: bcscale(2); $data['description'] = trim($data['description']); $data['amount'] = bcmul($data['amount'], $data['amount-modifier']); - - // get opposing account, which is quite complex: - $data['opposing-account-object'] = $this->processOpposingAccount($data); - if (strlen($data['description']) == 0) { $data['description'] = trans('firefly.csv_empty_description'); } + // fix currency if (is_null($data['currency'])) { $currencyPreference = Preferences::get('currencyPreference', 'EUR'); $data['currency'] = TransactionCurrency::whereCode($currencyPreference->data)->first(); } + + // get bill id. if (!is_null($data['bill'])) { $data['bill-id'] = $data['bill']->id; } + // opposing account can be difficult. + + // get opposing account, which is quite complex: + $opposingAccount = new OpposingAccount($data); + $data['opposing-account-object'] = $opposingAccount->parse(); + // do bank specific fixes: - $specifix = new Specifix(); - $specifix->setData($data); - $specifix->setRow($row); + // $specifix = new Specifix(); + // $specifix->setData($data); + // $specifix->setRow($row); //$specifix->fix($data, $row); // TODO // get data back: //$data = $specifix->getData(); // TODO @@ -206,97 +209,6 @@ class Importer return $data; } - /** - * @param array $data - */ - protected function processOpposingAccount(array $data) - { - // first priority. try to find the account based on ID, - // if any. - if ($data['opposing-account-id'] instanceof Account) { - return $data['opposing-account-id']; - } - - // second: try to find the account based on IBAN, if any. - if ($data['opposing-account-iban'] instanceof Account) { - return $data['opposing-account-iban']; - } - - $accountType = $this->getAccountType($data['amount']); - - if (is_string($data['opposing-account-iban'])) { - $accounts = Auth::user()->accounts()->where('account_type_id', $accountType->id)->get(); - foreach ($accounts as $entry) { - if ($entry->iban == $data['opposing-account-iban']) { - - //return $entry; - } - } - // create if not exists: - $account = Account::firstOrCreateEncrypted( - [ - 'user_id' => Auth::user()->id, - 'account_type_id' => $accountType->id, - 'name' => $data['opposing-account-iban'], - 'iban' => $data['opposing-account-iban'], - 'active' => true, - ] - ); - - return $account; - - } - - // third: try to find account based on name, if any. - if ($data['opposing-account-name'] instanceof Account) { - return $data['opposing-account-name']; - } - - if (is_string($data['opposing-account-name'])) { - $accounts = Auth::user()->accounts()->where('account_type_id', $accountType->id)->get(); - foreach ($accounts as $entry) { - if ($entry->name == $data['opposing-account-name']) { - return $entry; - } - } - // create if not exists: - $account = Account::firstOrCreateEncrypted( - [ - 'user_id' => Auth::user()->id, - 'account_type_id' => $accountType->id, - 'name' => $data['opposing-account-name'], - 'iban' => '', - 'active' => true, - ] - ); - - return $account; - } - return null; - - // if nothing, create expense/revenue, never asset. TODO - - } - - /** - * @param $amount - * - * @return AccountType - */ - protected function getAccountType($amount) - { - // opposing account type: - if ($amount < 0) { - // create expense account: - - return AccountType::where('type', 'Expense account')->first(); - } else { - // create revenue account: - - return AccountType::where('type', 'Revenue account')->first(); - } - } - /** * @param $data * @@ -326,11 +238,17 @@ class Importer if (is_null($data['date'])) { $date = $data['date-rent']; } + + // defaults to deposit + $transactionType = TransactionType::where('type', 'Deposit')->first(); if ($data['amount'] < 0) { $transactionType = TransactionType::where('type', 'Withdrawal')->first(); - } else { - $transactionType = TransactionType::where('type', 'Deposit')->first(); } + + if ($data['opposing-account-object']->accountType->type == 'Asset account') { + $transactionType = TransactionType::where('type', 'Transfer')->first(); + } + $errors = new MessageBag; $journal = TransactionJournal::create( [ @@ -378,6 +296,11 @@ class Importer if (!is_null($data['category'])) { $journal->categories()->save($data['category']); } + if (!is_null($data['tags'])) { + foreach ($data['tags'] as $tag) { + $journal->tags()->save($tag); + } + } return $journal; @@ -391,6 +314,4 @@ class Importer { $this->data = $data; } - - } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/AnyAccount.php b/app/Helpers/Csv/Mapper/AnyAccount.php new file mode 100644 index 0000000000..37488c1523 --- /dev/null +++ b/app/Helpers/Csv/Mapper/AnyAccount.php @@ -0,0 +1,32 @@ +accounts()->with('accountType')->orderBy('accounts.name', 'ASC')->get(['accounts.*']); + + $list = []; + /** @var Account $account */ + foreach ($result as $account) { + $list[$account->id] = $account->name . ' (' . $account->accountType->type . ')'; + } + asort($list); + + return $list; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/AssetAccount.php b/app/Helpers/Csv/Mapper/AssetAccount.php index 44982539b5..cb49177976 100644 --- a/app/Helpers/Csv/Mapper/AssetAccount.php +++ b/app/Helpers/Csv/Mapper/AssetAccount.php @@ -31,6 +31,8 @@ class AssetAccount implements MapperInterface $list[$account->id] = $account->name; } + asort($list); + return $list; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/Bill.php b/app/Helpers/Csv/Mapper/Bill.php new file mode 100644 index 0000000000..17a9f5b22e --- /dev/null +++ b/app/Helpers/Csv/Mapper/Bill.php @@ -0,0 +1,32 @@ +bills()->get(['bills.*']); + $list = []; + + /** @var BillModel $bill */ + foreach ($result as $bill) { + $list[$bill->id] = $bill->name . ' [' . $bill->match . ']'; + } + asort($list); + + return $list; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/Budget.php b/app/Helpers/Csv/Mapper/Budget.php new file mode 100644 index 0000000000..c4bf2064eb --- /dev/null +++ b/app/Helpers/Csv/Mapper/Budget.php @@ -0,0 +1,32 @@ +budgets()->get(['budgets.*']); + $list = []; + + /** @var BudgetModel $budget */ + foreach ($result as $budget) { + $list[$budget->id] = $budget->name; + } + asort($list); + + return $list; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/Category.php b/app/Helpers/Csv/Mapper/Category.php new file mode 100644 index 0000000000..81634764f0 --- /dev/null +++ b/app/Helpers/Csv/Mapper/Category.php @@ -0,0 +1,32 @@ +categories()->get(['categories.*']); + $list = []; + + /** @var CategoryModel $category */ + foreach ($result as $category) { + $list[$category->id] = $category->name; + } + asort($list); + + return $list; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/Tag.php b/app/Helpers/Csv/Mapper/Tag.php new file mode 100644 index 0000000000..9ef0d6a2db --- /dev/null +++ b/app/Helpers/Csv/Mapper/Tag.php @@ -0,0 +1,32 @@ +budgets()->get(['tags.*']); + $list = []; + + /** @var TagModel $tag */ + foreach ($result as $tag) { + $list[$tag->id] = $tag->tag; + } + asort($list); + + return $list; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/OpposingAccount.php b/app/Helpers/Csv/OpposingAccount.php new file mode 100644 index 0000000000..021423aeca --- /dev/null +++ b/app/Helpers/Csv/OpposingAccount.php @@ -0,0 +1,137 @@ +data = $data; + } + + /** + * @return \FireflyIII\Models\Account|null + */ + public function parse() + { + // first priority. try to find the account based on ID, + // if any. + if ($this->data['opposing-account-id'] instanceof Account) { + + return $this->data['opposing-account-id']; + } + + // second: try to find the account based on IBAN, if any. + if ($this->data['opposing-account-iban'] instanceof Account) { + return $this->data['opposing-account-iban']; + } + + + if (is_string($this->data['opposing-account-iban'])) { + + return $this->parseIbanString(); + } + + // third: try to find account based on name, if any. + if ($this->data['opposing-account-name'] instanceof Account) { + + return $this->data['opposing-account-name']; + } + + if (is_string($this->data['opposing-account-name'])) { + return $this->parseNameString(); + } + + return null; + + // if nothing, create expense/revenue, never asset. TODO + } + + /** + * @return Account|null + */ + protected function parseIbanString() + { + + // create by name and/or iban. + $accountType = $this->getAccountType(); + $accounts = Auth::user()->accounts()->where('account_type_id', $accountType->id)->get(); + foreach ($accounts as $entry) { + if ($entry->iban == $this->data['opposing-account-iban']) { + + return $entry; + } + } + // create if not exists: + $account = Account::firstOrCreateEncrypted( + [ + 'user_id' => Auth::user()->id, + 'account_type_id' => $accountType->id, + 'name' => $this->data['opposing-account-iban'], + 'iban' => $this->data['opposing-account-iban'], + 'active' => true, + ] + ); + + return $account; + } + + /** + * + * @return AccountType + */ + protected function getAccountType() + { + // opposing account type: + if ($this->data['amount'] < 0) { + // create expense account: + + return AccountType::where('type', 'Expense account')->first(); + } else { + // create revenue account: + + return AccountType::where('type', 'Revenue account')->first(); + } + } + + /** + * @return Account|null + */ + protected function parseNameString() + { + $accountType = $this->getAccountType(); + $accounts = Auth::user()->accounts()->where('account_type_id', $accountType->id)->get(); + foreach ($accounts as $entry) { + if ($entry->name == $this->data['opposing-account-name']) { + return $entry; + } + } + // create if not exists: + $account = Account::firstOrCreateEncrypted( + [ + 'user_id' => Auth::user()->id, + 'account_type_id' => $accountType->id, + 'name' => $this->data['opposing-account-name'], + 'iban' => '', + 'active' => true, + ] + ); + + return $account; + } +} \ No newline at end of file diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 1376a64141..68d79c0529 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -151,6 +151,7 @@ class CsvController extends Controller Session::forget('csv-map'); Session::forget('csv-roles'); Session::forget('csv-mapped'); + Session::forget('csv-specifix'); // get values which are yet unsaveable or unmappable: $unsupported = []; diff --git a/config/csv.php b/config/csv.php index 1fcd459bc6..937b2bbfa8 100644 --- a/config/csv.php +++ b/config/csv.php @@ -11,25 +11,29 @@ return [ 'name' => 'Bill ID (matching Firefly)', 'mappable' => false, 'field' => 'bill', - 'converter' => 'BillId' + 'converter' => 'BillId', + 'mapper' => 'Bill', ], 'bill-name' => [ 'name' => 'Bill name', 'mappable' => true, 'converter' => 'BillName', 'field' => 'bill', + 'mapper' => 'Bill', ], 'currency-id' => [ 'name' => 'Currency ID (matching Firefly)', 'mappable' => true, 'converter' => 'CurrencyId', 'field' => 'currency', + 'mapper' => 'TransactionCurrency' ], 'currency-name' => [ 'name' => 'Currency name (matching Firefly)', 'mappable' => true, 'converter' => 'CurrencyName', 'field' => 'currency', + 'mapper' => 'TransactionCurrency' ], 'currency-code' => [ 'name' => 'Currency code (ISO 4217)', @@ -43,6 +47,7 @@ return [ 'mappable' => true, 'converter' => 'CurrencySymbol', 'field' => 'currency', + 'mapper' => 'TransactionCurrency' ], 'description' => [ 'name' => 'Description', @@ -66,13 +71,15 @@ return [ 'name' => 'Budget ID (matching Firefly)', 'mappable' => true, 'converter' => 'BudgetId', - 'field' => 'budget' + 'field' => 'budget', + 'mapper' => 'Budget', ], 'budget-name' => [ 'name' => 'Budget name', 'mappable' => true, 'converter' => 'BudgetName', - 'field' => 'budget' + 'field' => 'budget', + 'mapper' => 'Budget', ], 'rabo-debet-credit' => [ 'name' => 'Rabobank specific debet/credit indicator', @@ -84,21 +91,29 @@ return [ 'name' => 'Category ID (matching Firefly)', 'mappable' => true, 'converter' => 'CategoryId', - 'field' => 'category' + 'field' => 'category', + 'mapper' => 'Category', ], 'category-name' => [ 'name' => 'Category name', 'mappable' => true, 'converter' => 'CategoryName', - 'field' => 'category' + 'field' => 'category', + 'mapper' => 'Category', ], 'tags-comma' => [ - 'name' => 'Tags (comma separated)', - 'mappable' => true, + 'name' => 'Tags (comma separated)', + 'mappable' => true, + 'field' => 'tags', + 'converter' => 'TagsComma', + 'mapper' => 'Tag', ], 'tags-space' => [ - 'name' => 'Tags (space separated)', - 'mappable' => true, + 'name' => 'Tags (space separated)', + 'mappable' => true, + 'field' => 'tags', + 'converter' => 'TagsSpace', + 'mapper' => 'Tag', ], 'account-id' => [ 'name' => 'Asset account ID (matching Firefly)', @@ -125,19 +140,22 @@ return [ 'name' => 'Opposing account account ID (matching Firefly)', 'mappable' => true, 'field' => 'opposing-account-id', - 'converter' => 'OpposingAccountId' + 'converter' => 'OpposingAccountId', + 'mapper' => 'AnyAccount', ], 'opposing-name' => [ - 'name' => 'Opposing account name', - 'mappable' => true, - 'field' => 'opposing-account-name', - 'converter' => 'OpposingAccountName' + 'name' => 'Opposing account name', + 'mappable' => true, + 'field' => 'opposing-account-name', + 'converter' => 'OpposingAccountName', + 'mapper' => 'AnyAccount', ], 'opposing-iban' => [ - 'name' => 'Opposing account IBAN', - 'mappable' => true, - 'field' => 'opposing-account-iban', - 'converter' => 'OpposingAccountIban' + 'name' => 'Opposing account IBAN', + 'mappable' => true, + 'field' => 'opposing-account-iban', + 'converter' => 'OpposingAccountIban', + 'mapper' => 'AnyAccount', ], 'amount' => [ 'name' => 'Amount', From c4ef379d0ea8749e66ccde361b3d287e81c9894e Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 19:31:58 +0200 Subject: [PATCH 32/60] Cleanup post processing. --- app/Helpers/Csv/Importer.php | 33 +++--------- app/Helpers/Csv/PostProcessing/Amount.php | 35 +++++++++++++ app/Helpers/Csv/PostProcessing/Bill.php | 37 ++++++++++++++ app/Helpers/Csv/PostProcessing/Currency.php | 40 +++++++++++++++ .../Csv/PostProcessing/Description.php | 38 ++++++++++++++ .../{ => PostProcessing}/OpposingAccount.php | 51 +++++++++++-------- .../PostProcessing/PostProcessorInterface.php | 28 ++++++++++ app/Http/Controllers/CsvController.php | 2 + config/csv.php | 13 ++++- 9 files changed, 230 insertions(+), 47 deletions(-) create mode 100644 app/Helpers/Csv/PostProcessing/Amount.php create mode 100644 app/Helpers/Csv/PostProcessing/Bill.php create mode 100644 app/Helpers/Csv/PostProcessing/Currency.php create mode 100644 app/Helpers/Csv/PostProcessing/Description.php rename app/Helpers/Csv/{ => PostProcessing}/OpposingAccount.php (78%) create mode 100644 app/Helpers/Csv/PostProcessing/PostProcessorInterface.php diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 83c9f1553b..ca2e2e2d1f 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -7,6 +7,7 @@ use Auth; use Config; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Csv\Converter\ConverterInterface; +use FireflyIII\Helpers\Csv\PostProcessing\PostProcessorInterface; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionJournal; @@ -171,33 +172,15 @@ class Importer */ protected function postProcess(array $data) { - // fix two simple fields: - bcscale(2); - $data['description'] = trim($data['description']); - $data['amount'] = bcmul($data['amount'], $data['amount-modifier']); - - if (strlen($data['description']) == 0) { - $data['description'] = trans('firefly.csv_empty_description'); + $set = Config::get('csv.post_processors'); + foreach ($set as $className) { + /** @var PostProcessorInterface $postProcessor */ + $postProcessor = App::make('FireflyIII\Helpers\Csv\PostProcessing\\' . $className); + $postProcessor->setData($data); + $data = $postProcessor->process(); } - // fix currency - if (is_null($data['currency'])) { - $currencyPreference = Preferences::get('currencyPreference', 'EUR'); - $data['currency'] = TransactionCurrency::whereCode($currencyPreference->data)->first(); - } - - // get bill id. - if (!is_null($data['bill'])) { - $data['bill-id'] = $data['bill']->id; - } - - // opposing account can be difficult. - - // get opposing account, which is quite complex: - $opposingAccount = new OpposingAccount($data); - $data['opposing-account-object'] = $opposingAccount->parse(); - - // do bank specific fixes: + // do bank specific fixes: TODO // $specifix = new Specifix(); // $specifix->setData($data); diff --git a/app/Helpers/Csv/PostProcessing/Amount.php b/app/Helpers/Csv/PostProcessing/Amount.php new file mode 100644 index 0000000000..c4e6f6e890 --- /dev/null +++ b/app/Helpers/Csv/PostProcessing/Amount.php @@ -0,0 +1,35 @@ +data['amount'] = bcmul($this->data['amount'], $this->data['amount-modifier']); + + return $this->data; + } + + /** + * @param array $data + */ + public function setData(array $data) + { + $this->data = $data; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/PostProcessing/Bill.php b/app/Helpers/Csv/PostProcessing/Bill.php new file mode 100644 index 0000000000..e21d8f6720 --- /dev/null +++ b/app/Helpers/Csv/PostProcessing/Bill.php @@ -0,0 +1,37 @@ +data['bill'])) { + $this->data['bill-id'] = $this->data['bill']->id; + } + + return $this->data; + } + + /** + * @param array $data + */ + public function setData(array $data) + { + $this->data = $data; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/PostProcessing/Currency.php b/app/Helpers/Csv/PostProcessing/Currency.php new file mode 100644 index 0000000000..66c77ef189 --- /dev/null +++ b/app/Helpers/Csv/PostProcessing/Currency.php @@ -0,0 +1,40 @@ +data['currency'])) { + $currencyPreference = Preferences::get('currencyPreference', 'EUR'); + $this->data['currency'] = TransactionCurrency::whereCode($currencyPreference->data)->first(); + } + + return $this->data; + } + + /** + * @param array $data + */ + public function setData(array $data) + { + $this->data = $data; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/PostProcessing/Description.php b/app/Helpers/Csv/PostProcessing/Description.php new file mode 100644 index 0000000000..2f2b019918 --- /dev/null +++ b/app/Helpers/Csv/PostProcessing/Description.php @@ -0,0 +1,38 @@ +data['description'] = trim($this->data['description']); + if (strlen($this->data['description']) == 0) { + $this->data['description'] = trans('firefly.csv_empty_description'); + } + + + return $this->data; + } + + /** + * @param array $data + */ + public function setData(array $data) + { + + $this->data = $data; + } +} \ No newline at end of file diff --git a/app/Helpers/Csv/OpposingAccount.php b/app/Helpers/Csv/PostProcessing/OpposingAccount.php similarity index 78% rename from app/Helpers/Csv/OpposingAccount.php rename to app/Helpers/Csv/PostProcessing/OpposingAccount.php index 021423aeca..1ffaafc721 100644 --- a/app/Helpers/Csv/OpposingAccount.php +++ b/app/Helpers/Csv/PostProcessing/OpposingAccount.php @@ -1,65 +1,74 @@ data = $data; - } - - /** - * @return \FireflyIII\Models\Account|null - */ - public function parse() + public function process() { // first priority. try to find the account based on ID, // if any. if ($this->data['opposing-account-id'] instanceof Account) { + $this->data['opposing-account-object'] = $this->data['opposing-account-id']; - return $this->data['opposing-account-id']; + return $this->data; } // second: try to find the account based on IBAN, if any. if ($this->data['opposing-account-iban'] instanceof Account) { - return $this->data['opposing-account-iban']; + $this->data['opposing-account-object'] = $this->data['opposing-account-iban']; + + return $this->data; } if (is_string($this->data['opposing-account-iban'])) { - return $this->parseIbanString(); + $this->data['opposing-account-object'] = $this->parseIbanString(); + + return $this->data; } // third: try to find account based on name, if any. if ($this->data['opposing-account-name'] instanceof Account) { - return $this->data['opposing-account-name']; + $this->data['opposing-account-object'] = $this->data['opposing-account-name']; + + return $this->data; } if (is_string($this->data['opposing-account-name'])) { - return $this->parseNameString(); + $this->data['opposing-account-object'] = $this->parseNameString(); + + return $this->data; } return null; - // if nothing, create expense/revenue, never asset. TODO + + } + + /** + * @param array $data + */ + public function setData(array $data) + { + $this->data = $data; } /** diff --git a/app/Helpers/Csv/PostProcessing/PostProcessorInterface.php b/app/Helpers/Csv/PostProcessing/PostProcessorInterface.php new file mode 100644 index 0000000000..dc2b04e64c --- /dev/null +++ b/app/Helpers/Csv/PostProcessing/PostProcessorInterface.php @@ -0,0 +1,28 @@ + [ + 'specifix' => [ + 'rabo_description' + ], + 'post_processors' => [ + 'OpposingAccount', + 'Description', + 'Amount', + 'Currency', + 'Bill' + + ], + 'roles' => [ '_ignore' => [ 'name' => '(ignore this column)', 'mappable' => false, From 170aebfe543625465714f631c54d7354a3edb3ba Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 19:57:44 +0200 Subject: [PATCH 33/60] Some code improvements. --- app/Helpers/Csv/Importer.php | 21 +++++++++--- .../Csv/PostProcessing/OpposingAccount.php | 7 +++- .../RabobankDescription.php} | 33 +++++-------------- .../Csv/Specifix/SpecifixInterface.php | 25 ++++++++++++++ config/csv.php | 2 +- 5 files changed, 57 insertions(+), 31 deletions(-) rename app/Helpers/Csv/{Specifix.php => Specifix/RabobankDescription.php} (62%) create mode 100644 app/Helpers/Csv/Specifix/SpecifixInterface.php diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index ca2e2e2d1f..07372518e6 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -8,13 +8,12 @@ use Config; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Csv\Converter\ConverterInterface; use FireflyIII\Helpers\Csv\PostProcessing\PostProcessorInterface; +use FireflyIII\Helpers\Csv\Specifix\SpecifixInterface; use FireflyIII\Models\Transaction; -use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; use Illuminate\Support\MessageBag; use Log; -use Preferences; set_time_limit(0); @@ -127,7 +126,7 @@ class Importer } // post processing and validating. - $data = $this->postProcess($data); + $data = $this->postProcess($data, $row); $result = $this->validateData($data); if ($result === true) { $result = $this->createTransactionJournal($data); @@ -167,11 +166,24 @@ class Importer * Row denotes the original data. * * @param array $data + * @param array $row * * @return array */ - protected function postProcess(array $data) + protected function postProcess(array $data, array $row) { + // do bank specific fixes (must be enabled but now all of them. + + $set = Config::get('csv.specifix'); + foreach ($set as $className) { + /** @var SpecifixInterface $specifix */ + $specifix = App::make('FireflyIII\Helpers\Csv\Specifix\\' . $className); + $specifix->setData($data); + $specifix->setRow($row); + $data = $specifix->fix(); + } + + $set = Config::get('csv.post_processors'); foreach ($set as $className) { /** @var PostProcessorInterface $postProcessor */ @@ -180,7 +192,6 @@ class Importer $data = $postProcessor->process(); } - // do bank specific fixes: TODO // $specifix = new Specifix(); // $specifix->setData($data); diff --git a/app/Helpers/Csv/PostProcessing/OpposingAccount.php b/app/Helpers/Csv/PostProcessing/OpposingAccount.php index 1ffaafc721..91214edd05 100644 --- a/app/Helpers/Csv/PostProcessing/OpposingAccount.php +++ b/app/Helpers/Csv/PostProcessing/OpposingAccount.php @@ -4,6 +4,8 @@ namespace FireflyIII\Helpers\Csv\PostProcessing; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; use Auth; +use FireflyIII\Validation\FireflyValidator; +use Validator; /** * Class OpposingAccount @@ -36,8 +38,11 @@ class OpposingAccount implements PostProcessorInterface return $this->data; } + $rules = ['iban' => 'iban']; + $check = ['iban' => $this->data['opposing-account-iban']]; + $validator = Validator::make($check, $rules); - if (is_string($this->data['opposing-account-iban'])) { + if (is_string($this->data['opposing-account-iban']) && $validator->valid()) { $this->data['opposing-account-object'] = $this->parseIbanString(); diff --git a/app/Helpers/Csv/Specifix.php b/app/Helpers/Csv/Specifix/RabobankDescription.php similarity index 62% rename from app/Helpers/Csv/Specifix.php rename to app/Helpers/Csv/Specifix/RabobankDescription.php index 0e530d4a5d..2a2f7211e9 100644 --- a/app/Helpers/Csv/Specifix.php +++ b/app/Helpers/Csv/Specifix/RabobankDescription.php @@ -1,13 +1,13 @@ rabobankFixEmptyOpposing(); + return $this->data; + } /** @@ -30,21 +32,12 @@ class Specifix */ protected function rabobankFixEmptyOpposing() { - if (strlen($this->data['opposing-account']) == 0) { - $this->data['opposing-account'] = $this->row[10]; + if (strlen($this->data['opposing-account-name']) == 0) { + $this->data['opposing-account-name'] = $this->row[10]; } $this->data['description'] = trim(str_replace($this->row[10], '', $this->data['description'])); } - - /** - * @return array - */ - public function getData() - { - return $this->data; - } - /** * @param array $data */ @@ -53,14 +46,6 @@ class Specifix $this->data = $data; } - /** - * @return array - */ - public function getRow() - { - return $this->row; - } - /** * @param array $row */ diff --git a/app/Helpers/Csv/Specifix/SpecifixInterface.php b/app/Helpers/Csv/Specifix/SpecifixInterface.php new file mode 100644 index 0000000000..a71e3cb45a --- /dev/null +++ b/app/Helpers/Csv/Specifix/SpecifixInterface.php @@ -0,0 +1,25 @@ + [ - 'rabo_description' + 'RabobankDescription' ], 'post_processors' => [ 'OpposingAccount', From 1658c666ab8cf4cd47785493d3aa3a4d4cb4b6d9 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Jul 2015 21:47:59 +0200 Subject: [PATCH 34/60] Some changes. --- .../Csv/Converter/AssetAccountIban.php | 45 ++++++++------- .../Csv/Converter/AssetAccountName.php | 5 +- .../Csv/Converter/OpposingAccountIban.php | 15 +++-- app/Helpers/Csv/Importer.php | 2 +- .../Csv/PostProcessing/OpposingAccount.php | 55 ++++++++++++++++--- config/csv.php | 4 +- 6 files changed, 88 insertions(+), 38 deletions(-) diff --git a/app/Helpers/Csv/Converter/AssetAccountIban.php b/app/Helpers/Csv/Converter/AssetAccountIban.php index aea16d7964..a2229bdc94 100644 --- a/app/Helpers/Csv/Converter/AssetAccountIban.php +++ b/app/Helpers/Csv/Converter/AssetAccountIban.php @@ -5,6 +5,7 @@ namespace FireflyIII\Helpers\Csv\Converter; use Auth; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; +use Log; /** * Class AssetAccountIban @@ -25,27 +26,33 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface return $account; } - // find or create new account: - $accountType = AccountType::where('type', 'Asset account')->first(); - $set = Auth::user()->accounts()->where('account_type_id', $accountType->id)->get(); - /** @var Account $entry */ - foreach ($set as $entry) { - if ($entry->iban == $this->value) { - return $entry; + if (strlen($this->value) > 0) { + // find or create new account: + $accountType = AccountType::where('type', 'Asset account')->first(); + $set = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->get(['accounts.*']); + /** @var Account $entry */ + foreach ($set as $entry) { + if ($entry->iban == $this->value) { + Log::debug('AssetAccountIban::convert found an Account (#' . $entry->id . ': ' . $entry->name . ') with IBAN ' . $this->value); + + return $entry; + } } + + // create it if doesn't exist. + $account = Account::firstOrCreateEncrypted( + [ + 'name' => $this->value, + 'iban' => $this->value, + 'user_id' => Auth::user()->id, + 'account_type_id' => $accountType->id, + 'active' => 1, + ] + ); + + return $account; } - // create it if doesnt exist. - $account = Account::firstOrCreateEncrypted( - [ - 'name' => $this->value, - 'iban' => $this->value, - 'user_id' => Auth::user()->id, - 'account_type_id' => $accountType->id, - 'active' => 1, - ] - ); - - return $account; + return null; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/AssetAccountName.php b/app/Helpers/Csv/Converter/AssetAccountName.php index cf1ff1a666..3fc708c20b 100644 --- a/app/Helpers/Csv/Converter/AssetAccountName.php +++ b/app/Helpers/Csv/Converter/AssetAccountName.php @@ -1,6 +1,7 @@ first(); - $set = Auth::user()->accounts()->where('account_type_id', $accountType->id)->get(); + $set = Auth::user()->accounts()->accountTypeIn(['Asset account', 'Default account'])->get(); /** @var Account $entry */ foreach ($set as $entry) { if ($entry->name == $this->value) { diff --git a/app/Helpers/Csv/Converter/OpposingAccountIban.php b/app/Helpers/Csv/Converter/OpposingAccountIban.php index cbd4b70a73..92bad04d5e 100644 --- a/app/Helpers/Csv/Converter/OpposingAccountIban.php +++ b/app/Helpers/Csv/Converter/OpposingAccountIban.php @@ -4,6 +4,7 @@ namespace FireflyIII\Helpers\Csv\Converter; use Auth; use FireflyIII\Models\Account; +use Log; /** * Class OpposingAccountIban @@ -25,11 +26,15 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface return $account; } else { - $set = Auth::user()->accounts()->get(); - /** @var Account $account */ - foreach ($set as $account) { - if ($account->iban == $this->value) { - return $account; + if (strlen($this->value) > 0) { + $set = Auth::user()->accounts()->get(); + /** @var Account $account */ + foreach ($set as $account) { + if ($account->iban == $this->value) { + Log::debug('OpposingAccountIban::convert found an Account (#' . $account->id . ': ' . $account->name . ') with IBAN ' . $this->value); + + return $account; + } } } diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 07372518e6..edadb10d8e 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -239,7 +239,7 @@ class Importer $transactionType = TransactionType::where('type', 'Withdrawal')->first(); } - if ($data['opposing-account-object']->accountType->type == 'Asset account') { + if (in_array($data['opposing-account-object']->accountType->type, ['Asset account', 'Default account'])) { $transactionType = TransactionType::where('type', 'Transfer')->first(); } diff --git a/app/Helpers/Csv/PostProcessing/OpposingAccount.php b/app/Helpers/Csv/PostProcessing/OpposingAccount.php index 91214edd05..e8fe7a4220 100644 --- a/app/Helpers/Csv/PostProcessing/OpposingAccount.php +++ b/app/Helpers/Csv/PostProcessing/OpposingAccount.php @@ -1,10 +1,11 @@ data['opposing-account-id'] instanceof Account) { + Log::debug('opposing-account-id is an account (#' . $this->data['opposing-account-id']->id . ': ' . $this->data['opposing-account-id']->name . ')'); $this->data['opposing-account-object'] = $this->data['opposing-account-id']; + Log::debug('Done post processing opposing account.'); return $this->data; } // second: try to find the account based on IBAN, if any. if ($this->data['opposing-account-iban'] instanceof Account) { + Log::debug( + 'opposing-account-iban is an account (#' . + $this->data['opposing-account-iban']->id . ': ' . $this->data['opposing-account-iban']->name . ')' + ); $this->data['opposing-account-object'] = $this->data['opposing-account-iban']; + Log::debug('Done post processing opposing account.'); return $this->data; } @@ -41,27 +50,44 @@ class OpposingAccount implements PostProcessorInterface $rules = ['iban' => 'iban']; $check = ['iban' => $this->data['opposing-account-iban']]; $validator = Validator::make($check, $rules); + $result = !$validator->fails(); - if (is_string($this->data['opposing-account-iban']) && $validator->valid()) { - $this->data['opposing-account-object'] = $this->parseIbanString(); + if (is_string($this->data['opposing-account-iban']) && strlen($this->data['opposing-account-iban']) > 0) { + Log::debug('opposing-account-iban is an IBAN string (' . $this->data['opposing-account-iban'] . ')'); + if ($result) { + Log::debug('opposing-account-iban is a valid IBAN string!'); + Log::debug('Go to parseIbanString()'); + $this->data['opposing-account-object'] = $this->parseIbanString(); + Log::debug('Done post processing opposing account.'); - return $this->data; + return $this->data; + } else { + Log::debug('opposing-account-iban is NOT a valid IBAN string!'); + } } // third: try to find account based on name, if any. if ($this->data['opposing-account-name'] instanceof Account) { - + Log::debug( + 'opposing-account-name is an Account (#' . + $this->data['opposing-account-name']->id . ': ' . $this->data['opposing-account-name']->name . ') ' + ); $this->data['opposing-account-object'] = $this->data['opposing-account-name']; + Log::debug('Done post processing opposing account.'); return $this->data; } if (is_string($this->data['opposing-account-name'])) { + Log::debug('Opposing account name is a string: ' . $this->data['opposing-account-name']); + Log::debug('Go to parseNameString'); $this->data['opposing-account-object'] = $this->parseNameString(); + Log::debug('Done post processing opposing account.'); return $this->data; } + Log::debug('Done post processing opposing account.'); return null; @@ -81,26 +107,30 @@ class OpposingAccount implements PostProcessorInterface */ protected function parseIbanString() { - + Log::debug('Parse IBAN string!'); // create by name and/or iban. $accountType = $this->getAccountType(); - $accounts = Auth::user()->accounts()->where('account_type_id', $accountType->id)->get(); + $accounts = Auth::user()->accounts()->get(); foreach ($accounts as $entry) { if ($entry->iban == $this->data['opposing-account-iban']) { + Log::debug('Found existing account with this IBAN: (#' . $entry->id . ': ' . $entry->name . ')'); return $entry; } } // create if not exists: + $name = is_string($this->data['opposing-account-name']) && strlen($this->data['opposing-account-name']) > 0 ? $this->data['opposing-account-name'] + : $this->data['opposing-account-iban']; $account = Account::firstOrCreateEncrypted( [ 'user_id' => Auth::user()->id, 'account_type_id' => $accountType->id, - 'name' => $this->data['opposing-account-iban'], + 'name' => $name, 'iban' => $this->data['opposing-account-iban'], 'active' => true, ] ); + Log::debug('Created new (' . $accountType->type . ')B account with this IBAN: (#' . $account->id . ': ' . $account->name . ')'); return $account; } @@ -120,6 +150,8 @@ class OpposingAccount implements PostProcessorInterface // create revenue account: return AccountType::where('type', 'Revenue account')->first(); + + } } @@ -132,6 +164,8 @@ class OpposingAccount implements PostProcessorInterface $accounts = Auth::user()->accounts()->where('account_type_id', $accountType->id)->get(); foreach ($accounts as $entry) { if ($entry->name == $this->data['opposing-account-name']) { + Log::debug('Found an account with this name (#' . $entry->id . ': ' . $entry->name . ')'); + return $entry; } } @@ -146,6 +180,9 @@ class OpposingAccount implements PostProcessorInterface ] ); + Log::debug('Created a new (' . $accountType->type . ')A account with this name (#' . $account->id . ': ' . $account->name . ')'); + + return $account; } } \ No newline at end of file diff --git a/config/csv.php b/config/csv.php index 6b8048194d..9b5914f796 100644 --- a/config/csv.php +++ b/config/csv.php @@ -4,11 +4,11 @@ return [ 'RabobankDescription' ], 'post_processors' => [ - 'OpposingAccount', 'Description', 'Amount', 'Currency', - 'Bill' + 'Bill', + 'OpposingAccount', // must be after Amount! ], 'roles' => [ From 13bda0a264f3a50e234b85ab029c813387056e12 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 08:14:19 +0200 Subject: [PATCH 35/60] Mainly layout improvements. --- app/Helpers/Csv/Importer.php | 11 +++++------ app/Helpers/Csv/Mapper/AnyAccount.php | 4 +++- app/Helpers/Csv/Mapper/AssetAccount.php | 9 ++++++++- app/Helpers/Csv/Mapper/Bill.php | 2 ++ app/Helpers/Csv/Mapper/Budget.php | 2 ++ app/Helpers/Csv/Mapper/Category.php | 2 ++ app/Helpers/Csv/Mapper/Tag.php | 2 ++ app/Helpers/Csv/Mapper/TransactionCurrency.php | 4 ++++ resources/lang/en/firefly.php | 4 +++- resources/lang/en/help.php | 1 + resources/twig/csv/column-roles.twig | 12 ++++++------ resources/twig/csv/index.twig | 2 ++ resources/twig/csv/map.twig | 12 ++++++------ 13 files changed, 46 insertions(+), 21 deletions(-) diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index edadb10d8e..14a3e8705e 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -126,14 +126,13 @@ class Importer } // post processing and validating. - $data = $this->postProcess($data, $row); - $result = $this->validateData($data); + $data = $this->postProcess($data, $row); + $result = $this->validateData($data); + $journal = null; if ($result === true) { - $result = $this->createTransactionJournal($data); - } else { - Log::error('Validator: ' . $result); + $journal = $this->createTransactionJournal($data); } - if ($result instanceof TransactionJournal) { + if ($journal instanceof TransactionJournal) { return true; } diff --git a/app/Helpers/Csv/Mapper/AnyAccount.php b/app/Helpers/Csv/Mapper/AnyAccount.php index 37488c1523..f42e64d071 100644 --- a/app/Helpers/Csv/Mapper/AnyAccount.php +++ b/app/Helpers/Csv/Mapper/AnyAccount.php @@ -20,13 +20,15 @@ class AnyAccount implements MapperInterface { $result = Auth::user()->accounts()->with('accountType')->orderBy('accounts.name', 'ASC')->get(['accounts.*']); - $list = []; + $list = []; /** @var Account $account */ foreach ($result as $account) { $list[$account->id] = $account->name . ' (' . $account->accountType->type . ')'; } asort($list); + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/AssetAccount.php b/app/Helpers/Csv/Mapper/AssetAccount.php index cb49177976..6915533ea7 100644 --- a/app/Helpers/Csv/Mapper/AssetAccount.php +++ b/app/Helpers/Csv/Mapper/AssetAccount.php @@ -26,13 +26,20 @@ class AssetAccount implements MapperInterface )->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')->get(['accounts.*']); $list = []; + /** @var Account $account */ foreach ($result as $account) { - $list[$account->id] = $account->name; + $name = $account->name; + if (strlen($account->iban) > 0) { + $name .= ' (' . $account->iban . ')'; + } + $list[$account->id] = $name; } asort($list); + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/Bill.php b/app/Helpers/Csv/Mapper/Bill.php index 17a9f5b22e..45f2de5897 100644 --- a/app/Helpers/Csv/Mapper/Bill.php +++ b/app/Helpers/Csv/Mapper/Bill.php @@ -27,6 +27,8 @@ class Bill implements MapperInterface } asort($list); + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/Budget.php b/app/Helpers/Csv/Mapper/Budget.php index c4bf2064eb..dbe8ebb03c 100644 --- a/app/Helpers/Csv/Mapper/Budget.php +++ b/app/Helpers/Csv/Mapper/Budget.php @@ -27,6 +27,8 @@ class Budget implements MapperInterface } asort($list); + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/Category.php b/app/Helpers/Csv/Mapper/Category.php index 81634764f0..7244a65a1a 100644 --- a/app/Helpers/Csv/Mapper/Category.php +++ b/app/Helpers/Csv/Mapper/Category.php @@ -27,6 +27,8 @@ class Category implements MapperInterface } asort($list); + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/Tag.php b/app/Helpers/Csv/Mapper/Tag.php index 9ef0d6a2db..559c73089c 100644 --- a/app/Helpers/Csv/Mapper/Tag.php +++ b/app/Helpers/Csv/Mapper/Tag.php @@ -27,6 +27,8 @@ class Tag implements MapperInterface } asort($list); + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/app/Helpers/Csv/Mapper/TransactionCurrency.php b/app/Helpers/Csv/Mapper/TransactionCurrency.php index 0945bea416..4d6281acdc 100644 --- a/app/Helpers/Csv/Mapper/TransactionCurrency.php +++ b/app/Helpers/Csv/Mapper/TransactionCurrency.php @@ -23,6 +23,10 @@ class TransactionCurrency implements MapperInterface $list[$currency->id] = $currency->name . ' (' . $currency->code . ')'; } + asort($list); + + array_unshift($list, trans('firefly.csv_do_not_map')); + return $list; } } \ No newline at end of file diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php index 85a663d095..c45f5d6ae4 100644 --- a/resources/lang/en/firefly.php +++ b/resources/lang/en/firefly.php @@ -25,7 +25,8 @@ return [ 'csv_index_title' => 'Upload and import a CSV file', 'csv_index_text' => 'This form allows you to import a CSV file with transactions into Firefly. It is based on the excellent CSV importer made by' . - ' the folks at Atlassian. Simply upload your CSV file and follow the instructions.', + ' the folks at Atlassian. Simply upload your CSV file and follow the instructions.' . + ' If you would like to learn more, please click on the button at the top of this page.', 'csv_index_beta_warning' => 'This tool is very much in beta. Please proceed with caution', 'csv_header_help' => 'Check this box when your CSV file\'s first row consists of column names, not actual data', 'csv_date_help' => 'Date time format in your CSV. Follow the format like - {{ 'cvs_column_name'|_ }} - {{ 'cvs_column_example'|_ }} - {{ 'cvs_column_role'|_ }} - {{ 'csv_do_map_value'|_ }} + {{ 'cvs_column_name'|_ }} + {{ 'cvs_column_example'|_ }} + {{ 'cvs_column_role'|_ }} + {{ 'csv_do_map_value'|_ }} {% for index,header in headers %} {{ header }} - {{ example[index] }} + {{ example[index] }} - {{ Form.select(('role['~index~']'), availableRoles,roles[index]) }} + {{ Form.select(('role['~index~']'), availableRoles,roles[index],{class: 'form-control'}) }} {{ Form.checkbox(('map['~index~']'),1,map[index]) }} diff --git a/resources/twig/csv/index.twig b/resources/twig/csv/index.twig index 7e8e79c97f..e4a465bc9e 100644 --- a/resources/twig/csv/index.twig +++ b/resources/twig/csv/index.twig @@ -61,6 +61,8 @@ {{ ExpandedForm.file('csv_config',{helpText: 'csv_csv_config_file_help'|_}) }} + + {% if not uploadPossible %}
    diff --git a/resources/twig/csv/map.twig b/resources/twig/csv/map.twig index 97ce18b582..ccd26c0e50 100644 --- a/resources/twig/csv/map.twig +++ b/resources/twig/csv/map.twig @@ -21,7 +21,7 @@

    - {{ 'csv_map_text'|_ }} + {{ 'csv_map_text'|_ }}

    @@ -45,18 +45,18 @@
    -
    - +
    +
    - + {% for value in values[index] %} - + {% endfor %} From 5b50abb2c7b47244adf966bb052c629cea9eaeb2 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 08:33:39 +0200 Subject: [PATCH 36/60] Bread crumbs and fine tuning. --- app/Http/Controllers/CsvController.php | 17 ++++++++---- app/Http/breadcrumbs.php | 37 ++++++++++++++++++++++++++ resources/lang/en/firefly.php | 8 ++++-- resources/twig/csv/process.twig | 1 + 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index a5de95072d..3111f23cef 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -65,7 +65,7 @@ class CsvController extends Controller return Redirect::route('csv.index'); } - $subTitle = trans('firefly.csv_process'); + $subTitle = trans('firefly.csv_define_column_roles'); $firstRow = $this->data->getReader()->fetchOne(); $count = count($firstRow); $headers = []; @@ -131,7 +131,9 @@ class CsvController extends Controller */ public function downloadConfigPage() { - return view('csv.download-config'); + $subTitle = trans('firefly.csv_download_config_title'); + + return view('csv.download-config', compact('subTitle')); } /** @@ -277,8 +279,9 @@ class CsvController extends Controller $values = $this->wizard->getMappableValues($reader, $map, $hasHeaders); $map = $this->data->getMap(); $mapped = $this->data->getMapped(); + $subTitle = trans('firefly.csv_map_values'); - return view('csv.map', compact('map', 'options', 'values', 'mapped')); + return view('csv.map', compact('map', 'options', 'values', 'mapped', 'subTitle')); } /** @@ -316,7 +319,9 @@ class CsvController extends Controller Preferences::mark(); - return view('csv.process', compact('rows', 'errors', 'imported')); + $subTitle = trans('firefly.csv_process_title'); + + return view('csv.process', compact('rows', 'errors', 'imported', 'subTitle')); } @@ -348,7 +353,9 @@ class CsvController extends Controller foreach (Input::get('mapping') as $index => $data) { $mapped[$index] = []; foreach ($data as $value => $mapping) { - $mapped[$index][$value] = $mapping; + if (intval($mapping) !== 0) { + $mapped[$index][$value] = $mapping; + } } } Session::put('csv-mapped', $mapped); diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index d9991cbf56..d9f64ab902 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -161,6 +161,43 @@ Breadcrumbs::register( } ); +// CSV: +Breadcrumbs::register( + 'csv.index', function (Generator $breadcrumbs) { + $breadcrumbs->parent('home'); + $breadcrumbs->push(trans('firefly.csv_index_title'), route('csv.index')); +} +); + +Breadcrumbs::register( + 'csv.column-roles', function (Generator $breadcrumbs) { + $breadcrumbs->parent('csv.index'); + $breadcrumbs->push(trans('firefly.csv_define_column_roles'), route('csv.column-roles')); +} +); + +Breadcrumbs::register( + 'csv.map', function (Generator $breadcrumbs) { + $breadcrumbs->parent('csv.index'); + $breadcrumbs->push(trans('firefly.csv_map_values'), route('csv.map')); +} +); + +Breadcrumbs::register( + 'csv.download-config-page', function (Generator $breadcrumbs) { + $breadcrumbs->parent('csv.index'); + $breadcrumbs->push(trans('firefly.csv_download_config'), route('csv.download-config-page')); +} +); + +Breadcrumbs::register( + 'csv.process', function (Generator $breadcrumbs) { + $breadcrumbs->parent('csv.index'); + $breadcrumbs->push(trans('firefly.csv_process_title'), route('csv.process')); +} +); + + // currencies. Breadcrumbs::register( 'currency.index', function (Generator $breadcrumbs) { diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php index c45f5d6ae4..692d534076 100644 --- a/resources/lang/en/firefly.php +++ b/resources/lang/en/firefly.php @@ -23,6 +23,9 @@ return [ 'csv_import' => 'Import CSV file', 'csv' => 'CSV', 'csv_index_title' => 'Upload and import a CSV file', + 'csv_define_column_roles' => 'Define column roles', + 'csv_map_values' => 'Map found values to existing values', + 'csv_download_config' => 'Download CSV configuration file.', 'csv_index_text' => 'This form allows you to import a CSV file with transactions into Firefly. It is based on the excellent CSV importer made by' . ' the folks at Atlassian. Simply upload your CSV file and follow the instructions.' . @@ -56,7 +59,8 @@ return [ 'csv_field_mapped_to' => 'Must be mapped to...', 'csv_download_config_title' => 'Download CSV configuration', 'csv_download_config_text' => 'Everything you\'ve just set up can be downloaded as a configuration file. Click the button to do so.', - 'csv_more_information_text' => 'If the import fails, you can use this configuration file so you don\'t have to start all over again.', + 'csv_more_information_text' => 'If the import fails, you can use this configuration file so you don\'t have to start all over again.' + . ' But, if the import succeeds, it will be easier to upload similar CSV files.', 'csv_do_download_config' => 'Download configuration file.', 'csv_empty_description' => '(empty description)', 'csv_upload_form' => 'CSV upload form', @@ -64,7 +68,7 @@ return [ 'csv_unsupported_map' => 'The importer cannot map the column ":columnRole" to existing values in the database.', 'csv_unsupported_value' => 'The importer does not know how to handle values in columns marked as ":columnRole".', 'csv_cannot_store_value' => 'The importer has not reserved space for columns marked ":columnRole" and will be incapable of processing them.', - 'csv_process_title' => 'CVS import finished', + 'csv_process_title' => 'CVS import finished!', 'csv_process_text' => 'The CVS importer has finished and has imported :rows rows', 'csv_row' => 'Row', 'csv_import_with_errors' => 'There was one error.|There were :errors errors.', diff --git a/resources/twig/csv/process.twig b/resources/twig/csv/process.twig index c45a882d20..b9a4c22221 100644 --- a/resources/twig/csv/process.twig +++ b/resources/twig/csv/process.twig @@ -39,6 +39,7 @@

    {{ 'csv_start_over'|_ }} {{ 'csv_to_index'|_ }} + {{ 'csv_do_download_config'|_ }}

    From 39af9e4414529b8f40b1a349d7e300d7f88638db Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 10:39:44 +0200 Subject: [PATCH 37/60] More translations. --- app/Helpers/Csv/Importer.php | 9 ++- app/Http/Controllers/CsvController.php | 5 +- config/firefly.php | 2 +- resources/lang/en/firefly.php | 37 ++++++++--- resources/lang/nl/firefly.php | 85 +++++++++++++++++++++++--- resources/lang/nl/form.php | 3 +- resources/twig/csv/process.twig | 6 ++ 7 files changed, 126 insertions(+), 21 deletions(-) diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 14a3e8705e..0ce9fab492 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -30,7 +30,7 @@ class Importer /** @var array */ protected $errors; /** @var int */ - protected $imported; + protected $imported = 0; /** @var array */ protected $map; /** @var array */ @@ -131,12 +131,14 @@ class Importer $journal = null; if ($result === true) { $journal = $this->createTransactionJournal($data); + } else { + return $result; } if ($journal instanceof TransactionJournal) { return true; } - return 'Not a journal.'; + return $journal; } @@ -278,6 +280,9 @@ class Importer if ($errors->count() == 0) { $journal->completed = 1; $journal->save(); + } else { + $text = join(',', $errors->all()); + return $text; } // add budget: diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 3111f23cef..744235606f 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -50,10 +50,9 @@ class CsvController extends Controller /** * Define column roles and mapping. * - * * STEP THREE * - * @return View + * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View */ public function columnRoles() { @@ -82,7 +81,7 @@ class CsvController extends Controller } foreach (Config::get('csv.roles') as $name => $role) { - $availableRoles[$name] = $role['name']; + $availableRoles[$name] = trans('firefly.csv_column_' . $name);//$role['name']; } ksort($availableRoles); diff --git a/config/firefly.php b/config/firefly.php index 81f741bd77..c7dde36697 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -5,7 +5,7 @@ return [ 'version' => '3.4.6', 'index_periods' => ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'], 'budget_periods' => ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'], - 'csv_import_enabled' => false, + 'csv_import_enabled' => true, 'piggy_bank_periods' => [ 'week' => 'Week', 'month' => 'Month', diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php index 692d534076..1fc0365f4f 100644 --- a/resources/lang/en/firefly.php +++ b/resources/lang/en/firefly.php @@ -69,21 +69,44 @@ return [ 'csv_unsupported_value' => 'The importer does not know how to handle values in columns marked as ":columnRole".', 'csv_cannot_store_value' => 'The importer has not reserved space for columns marked ":columnRole" and will be incapable of processing them.', 'csv_process_title' => 'CVS import finished!', - 'csv_process_text' => 'The CVS importer has finished and has imported :rows rows', + 'csv_process_text' => 'The CVS importer has finished and has processed :rows rows', 'csv_row' => 'Row', 'csv_import_with_errors' => 'There was one error.|There were :errors errors.', 'csv_error_see_logs' => 'Check the log files to see details.', + 'csv_process_new_entries' => 'Firefly has created :imported new transaction(s).', 'csv_start_over' => 'Import again', 'csv_to_index' => 'Back home', 'csv_do_not_map' => 'Do not map this value', - // 'csv_index_text' => 'Here be explanation.', - // 'csv_upload_form' => 'Upload form', - // 'upload_csv_file' => 'Upload CSV file', - // 'csv_header_help' => 'Check this when bla bla', - // 'csv_date_help' => - // 'csv_row' => 'row', 'csv_upload_not_writeable' => 'Cannot write to the path mentioned here. Cannot upload', + 'csv_column__ignore' => '(ignore this column)', + 'csv_column_account-iban' => 'Asset account (IBAN)', + 'csv_column_account-id' => 'Asset account ID (matching Firefly)', + 'csv_column_account-name' => 'Asset account (name)', + 'csv_column_amount' => 'Amount', + 'csv_column_bill-id' => 'Bill ID (matching Firefly)', + 'csv_column_bill-name' => 'Bill name', + 'csv_column_budget-id' => 'Budget ID (matching Firefly)', + 'csv_column_budget-name' => 'Budget name', + 'csv_column_category-id' => 'Category ID (matching Firefly)', + 'csv_column_category-name' => 'Category name', + 'csv_column_currency-code' => 'Currency code (ISO 4217)', + 'csv_column_currency-id' => 'Currency ID (matching Firefly)', + 'csv_column_currency-name' => 'Currency name (matching Firefly)', + 'csv_column_currency-symbol' => 'Currency symbol (matching Firefly)', + 'csv_column_date-rent' => 'Rent calculation date', + 'csv_column_date-transaction' => 'Date', + 'csv_column_description' => 'Description', + 'csv_column_opposing-iban' => 'Opposing account (IBAN)', + 'csv_column_opposing-id' => 'Opposing account ID (matching Firefly)', + 'csv_column_opposing-name' => 'Opposing account (name)', + 'csv_column_rabo-debet-credit' => 'Rabobank specific debet/credit indicator', + 'csv_column_sepa-ct-id' => 'SEPA Credit Transfer end-to-end ID', + 'csv_column_sepa-ct-op' => 'SEPA Credit Transfer opposing account', + 'csv_column_sepa-db' => 'SEPA Direct Debet', + 'csv_column_tags-comma' => 'Tags (comma separated)', + 'csv_column_tags-space' => 'Tags (space separated)', + // create new stuff: 'create_new_withdrawal' => 'Create new withdrawal', 'create_new_deposit' => 'Create new deposit', diff --git a/resources/lang/nl/firefly.php b/resources/lang/nl/firefly.php index aaa2a9a90e..a64b157eac 100644 --- a/resources/lang/nl/firefly.php +++ b/resources/lang/nl/firefly.php @@ -22,13 +22,84 @@ return [ // csv import: 'csv_import' => 'Importeer CSV-bestand', 'csv' => 'CSV', - 'csv_index_text' => 'Hier komt uitleg.', - 'csv_upload_form' => 'Upload formulier', - 'upload_csv_file' => 'Upload CSV-bestand', - 'csv_header_help' => 'Check dit als bla bla', - 'csv_row' => 'rij', - 'upload_not_writeable' => 'Cannot write to the path mentioned here. Cannot upload', - + 'csv_index_title' => 'Upload en importeer een kommagescheiden tekstbestand', + 'csv_index_text' => 'Met deze (en de komende) pagina\'s kan je kommagescheiden tekstbestanden importeren. Deze tool is gebaseerd ' + . 'op de prachtige tool van Atlassian. Om te beginnen selecteer' . + ' je jouw tekstbestand bij "CSV-bestand". ' + . 'Als je hulp nodig hebt, klik dan op het -icoontje rechtsboven.', + 'csv_index_beta_warning' => 'Deze tool is nog erg experimenteel. Wees dus voorzichtig.', + 'csv_header_help' => 'Zet hier een vinkje als de eerste rij van je tekstbestand bestaat uit kolomnamen, en niet uit daadwerkelijke gegevens.', + 'csv_date_help' => 'Het gebruikte datumformaat in jouw bestand. Gebruik het formaat zoals deze' . + ' pagina het uitlegt (Engels). Het standaardformaat kan omgaan met data zoals deze: ' . date('Ymd'), + 'csv_csv_file_help' => 'Voer hier je kommagescheiden tekstbestand in. Je kan er maar één tegelijkertijd invoeren.', + 'csv_csv_config_file_help' => 'Voer hier je configuratiebestand in. Als je deze niet hebt, geen zorgen. Latere stappen leggen dit uit.', + 'csv_upload_button' => 'Begin de import', + 'csv_define_column_roles' => 'Bepaal kolominhoud', + 'csv_column_roles_title' => 'Bepaal de inhoud van elke kolom', + 'csv_column_roles_text' => 'Firefly kan niet automatisch ontdekken wat elke kolom betekent. Je moet het zelf aangeven. Gebruik de' . + ' voorbeeldgegevens als je het ook niet zeker weet. Klik op het -icoontje ' . + 'rechtsboven om te ontdekken wat elke kolomsoort precies is. Als de kolominhoud een directe relatie heeft met gegevens' . + ' die al in Firefly staan, gebruik dan het vinkje. Tijdens de volgende stap komt Firefly hier dan op terug.', + 'csv_column' => 'CSV-kolom', + 'cvs_column_name' => 'CSV-kolomnaam', + 'cvs_column_example' => 'Voorbeeldgegevens', + 'cvs_column_role' => 'Kolom bevat?', + 'csv_do_map_value' => 'Directe relatie?', + 'csv_column__ignore' => '(negeer deze kolom)', + 'csv_column_account-iban' => 'Betaalrekening (IBAN)', + 'csv_column_account-id' => 'Betaalrekening (ID gelijk aan Firefly)', + 'csv_column_account-name' => 'Betaalrekeningnaam', + 'csv_column_amount' => 'Bedrag', + 'csv_column_bill-id' => 'Contract (ID gelijk aan Firefly)', + 'csv_column_bill-name' => 'Contractnaam', + 'csv_column_budget-id' => 'Budget (ID gelijk aan Firefly)', + 'csv_column_budget-name' => 'Budgetnaam', + 'csv_column_category-id' => 'Categorie (ID gelijk aan Firefly)', + 'csv_column_category-name' => 'Categorienaam', + 'csv_column_currency-code' => 'Valutacode (ISO 4217)', + 'csv_column_currency-id' => 'Valuta (ID gelijk aan Firefly)', + 'csv_column_currency-name' => 'Valutanaam', + 'csv_column_currency-symbol' => 'Valuta', + 'csv_column_date-rent' => 'Datum (renteberekening)', + 'csv_column_date-transaction' => 'Datum (transactie)', + 'csv_column_description' => 'Beschrijving', + 'csv_column_opposing-iban' => 'Tegenrekening (IBAN)', + 'csv_column_opposing-id' => 'Tegenrekening (ID gelijk aan Firefly)', + 'csv_column_opposing-name' => 'Tegenrekeningnaam', + 'csv_column_rabo-debet-credit' => 'Rabobankspecifiek bij/af indicator', + 'csv_column_sepa-ct-id' => 'SEPA transactienummer', + 'csv_column_sepa-ct-op' => 'SEPA tegenrekeningnummer', + 'csv_column_sepa-db' => 'SEPA "direct debet"-nummer', + 'csv_column_tags-comma' => 'Tags (kommagescheiden)', + 'csv_column_tags-space' => 'Tags (spatiegescheiden)', + 'csv_column_roles_table' => 'Kolominhoud', + 'csv_continue' => 'Naar de volgende stap', + 'csv_go_back' => 'Terug naar de vorige stap', + 'csv_map_values' => 'Leg relaties met kolomwaardes', + 'csv_map_title' => 'Leg relaties met kolomwaardes', + 'csv_map_text' => 'Sommige kolommen bevatten waardes die misschien al in Firefly bestaan. Selecteer hier de juiste combinaties' . + 'zodat het importeren netjes aansluit bij je huidige gegevens.', + 'cvs_field_value' => 'Veldwaarde', + 'csv_field_mapped_to' => 'Is gelijk aan', + 'csv_do_not_map' => 'Geen relatie', + 'csv_download_config_title' => 'Download importconfiguratie', + 'csv_download_config_text' => + 'Firefly is klaar om je bestand te importeren. De instellingen en selecties die je zojuist hebt gemaakt kan je downloaden' + . ' en opslaan. Bij de volgende keer kan je dit bestand ook uploaden. Als je kommagescheiden bestand dezelfde indeling' + . ' heeft, zullen alle selecties goed staan. Dat scheelt weer!', + 'csv_more_information_text' => 'Ook als het importeren fout gaat is dit bestand handig. Na het importeren krijg je nogmaals de gelegenheid dit bestand' + . 'te downloaden.', + 'csv_do_download_config' => 'Download het configuratiebestand', + 'csv_process_title' => 'Het importeren is klaar', + 'csv_row' => 'Rij', + 'csv_error_see_logs' => 'De logboeken bevatten mogelijk meer details.', + 'csv_process_new_entries' => 'Firefly heeft :imported nieuwe transactie(s) gemaakt.', + 'csv_start_over' => 'Begin opnieuw', + 'csv_to_index' => 'Naar de index', + 'csv_process_text' => ':rows rijen zijn verwerkt.', + 'csv_import_with_errors' => 'Er was één fout. Deze foutmelding is mogelijk in het Engels.|Er zijn :errors fouten opgetreden. De foutmeldingen' + . ' zijn mogelijk in het Engels.', // create new stuff: 'create_new_withdrawal' => 'Nieuwe uitgave', 'create_new_deposit' => 'Nieuwe inkomsten', diff --git a/resources/lang/nl/form.php b/resources/lang/nl/form.php index 397c87cb76..f209eb9f96 100644 --- a/resources/lang/nl/form.php +++ b/resources/lang/nl/form.php @@ -47,8 +47,9 @@ return [ 'code' => 'Code', 'iban' => 'IBAN', 'csv' => 'CSV-bestand', - 'has_headers' => 'Eerste rij zijn kolomnamen', + 'has_headers' => 'Kolomnamen op de eerste rij?', 'date_format' => 'Datumformaat', + 'csv_config' => 'Configuratiebestand', 'store_new_withdrawal' => 'Nieuwe uitgave opslaan', 'store_new_deposit' => 'Nieuwe inkomsten opslaan', diff --git a/resources/twig/csv/process.twig b/resources/twig/csv/process.twig index b9a4c22221..89911bc291 100644 --- a/resources/twig/csv/process.twig +++ b/resources/twig/csv/process.twig @@ -36,6 +36,12 @@ {{ trans('firefly.csv_error_see_logs') }}

    {% endif %} + +

    + + {{ trans('firefly.csv_process_new_entries',{imported: imported}) }} +

    +

    {{ 'csv_start_over'|_ }} {{ 'csv_to_index'|_ }} From 6e261abb7375196ee8379733cc630cf6ce8eec4a Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 16:08:36 +0200 Subject: [PATCH 38/60] Some code improvements. --- app/Http/Controllers/CsvController.php | 93 +++++++++++--------------- 1 file changed, 39 insertions(+), 54 deletions(-) diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 744235606f..9f923c6a3a 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -61,7 +61,7 @@ class CsvController extends Controller if (!$this->wizard->sessionHasValues($fields)) { Session::flash('warning', 'Could not recover upload.'); - return Redirect::route('csv.index'); + return redirect(route('csv.index')); } $subTitle = trans('firefly.csv_define_column_roles'); @@ -92,6 +92,8 @@ class CsvController extends Controller * Optional download of mapping. * * STEP FOUR THREE-A + * + * @return \Illuminate\Http\RedirectResponse|string */ public function downloadConfig() { @@ -99,7 +101,7 @@ class CsvController extends Controller if (!$this->wizard->sessionHasValues($fields)) { Session::flash('warning', 'Could not recover upload.'); - return Redirect::route('csv.index'); + return redirect(route('csv.index')); } $data = [ 'date-format' => Session::get('date-format'), @@ -122,11 +124,12 @@ class CsvController extends Controller header('Content-disposition: attachment; filename=' . $name); header('Content-type: application/json'); echo $result; - exit; + + return ''; } /** - * @return View + * @return \Illuminate\View\View */ public function downloadConfigPage() { @@ -140,7 +143,7 @@ class CsvController extends Controller * * STEP ONE * - * @return View + * @return \Illuminate\View\View */ public function index() { @@ -158,19 +161,6 @@ class CsvController extends Controller // get values which are yet unsaveable or unmappable: $unsupported = []; - foreach (Config::get('csv.roles') as $role) { - if (!isset($role['converter'])) { - $unsupported[] = trans('firefly.csv_unsupported_value', ['columnRole' => $role['name']]); - } - if ($role['mappable'] === true && !isset($role['mapper'])) { - $unsupported[] = trans('firefly.csv_unsupported_map', ['columnRole' => $role['name']]); - } - if (!isset($role['field'])) { - $unsupported[] = trans('firefly.csv_cannot_store_value', ['columnRole' => $role['name']]); - } - } - sort($unsupported); - // can actually upload? $uploadPossible = is_writable(storage_path('upload')); @@ -192,7 +182,7 @@ class CsvController extends Controller if (!$this->wizard->sessionHasValues($fields)) { Session::flash('warning', 'Could not recover upload.'); - return Redirect::route('csv.index'); + return redirect(route('csv.index')); } @@ -209,14 +199,14 @@ class CsvController extends Controller if (count($roles) === 0) { Session::flash('warning', 'Please select some roles.'); - return Redirect::route('csv.column-roles'); + return redirect(route('csv.column-roles')); } /* * Continue with map specification when necessary. */ if (count($maps) > 0) { - return Redirect::route('csv.map'); + return redirect(route('csv.map')); } /* @@ -224,7 +214,7 @@ class CsvController extends Controller */ // proceed to download config - return Redirect::route('csv.download-config-page'); + return redirect(route('csv.download-config-page')); } @@ -234,7 +224,7 @@ class CsvController extends Controller * * STEP FIVE. * - * @return \Illuminate\Http\RedirectResponse|View + * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View * @throws FireflyException */ public function map() @@ -247,7 +237,7 @@ class CsvController extends Controller if (!$this->wizard->sessionHasValues($fields)) { Session::flash('warning', 'Could not recover upload.'); - return Redirect::route('csv.index'); + return redirect(route('csv.index')); } /* @@ -284,9 +274,12 @@ class CsvController extends Controller } /** + * * Finally actually process the CSV file. * * STEP SEVEN + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View */ public function process() { @@ -297,7 +290,7 @@ class CsvController extends Controller if (!$this->wizard->sessionHasValues($fields)) { Session::flash('warning', 'Could not recover upload.'); - return Redirect::route('csv.index'); + return redirect(route('csv.index')); } Log::debug('Created importer'); @@ -328,6 +321,8 @@ class CsvController extends Controller * Store the mapping the user has made. This is * * STEP SIX + * + * @return \Illuminate\Http\RedirectResponse */ public function saveMapping() { @@ -338,7 +333,7 @@ class CsvController extends Controller if (!$this->wizard->sessionHasValues($fields)) { Session::flash('warning', 'Could not recover upload.'); - return Redirect::route('csv.index'); + return redirect(route('csv.index')); } // save mapping to session. @@ -346,7 +341,7 @@ class CsvController extends Controller if (!is_array(Input::get('mapping'))) { Session::flash('warning', 'Invalid mapping.'); - return Redirect::route('csv.map'); + return redirect(route('csv.map')); } foreach (Input::get('mapping') as $index => $data) { @@ -360,7 +355,7 @@ class CsvController extends Controller Session::put('csv-mapped', $mapped); // proceed to process. - return Redirect::route('csv.download-config-page'); + return redirect(route('csv.download-config-page')); } @@ -380,46 +375,36 @@ class CsvController extends Controller if (!$request->hasFile('csv')) { Session::flash('warning', 'No file uploaded.'); - return Redirect::route('csv.index'); + return redirect(route('csv.index')); } - /* - * Store CSV and put in session. - */ - $fullPath = $this->wizard->storeCsvFile($request->file('csv')->getRealPath()); - $dateFormat = Input::get('date_format'); - $hasHeaders = intval(Input::get('has_headers')) === 1; - $map = []; - $roles = []; - $mapped = []; - + $fullPath = $this->wizard->storeCsvFile($request->file('csv')->getRealPath()); + $settings = []; + $settings['date-format'] = Input::get('date_format'); + $settings['has-headers'] = intval(Input::get('has_headers')) === 1; + $settings['map'] = []; + $settings['mapped'] = []; + $settings['roles'] = []; /* * Process config file if present. */ if ($request->hasFile('csv_config')) { - $data = file_get_contents($request->file('csv_config')->getRealPath()); $json = json_decode($data, true); - - if (!is_null($json)) { - $dateFormat = isset($json['date-format']) ? $json['date-format'] : $dateFormat; - $hasHeaders = isset($json['has-headers']) ? $json['has-headers'] : $hasHeaders; - $map = isset($json['map']) && is_array($json['map']) ? $json['map'] : []; - $mapped = isset($json['mapped']) && is_array($json['mapped']) ? $json['mapped'] : []; - $roles = isset($json['roles']) && is_array($json['roles']) ? $json['roles'] : []; + if (is_array($json)) { + $settings = array_merge($settings, $json); } } $this->data->setCsvFileLocation($fullPath); - $this->data->setDateFormat($dateFormat); - $this->data->setHasHeaders($hasHeaders); - $this->data->setMap($map); - $this->data->setMapped($mapped); - $this->data->setRoles($roles); + $this->data->setDateFormat($settings['date-format']); + $this->data->setHasHeaders($settings['has-headers']); + $this->data->setMap($settings['map']); + $this->data->setMapped($settings['mapped']); + $this->data->setRoles($settings['roles']); - - return Redirect::route('csv.column-roles'); + return redirect(route('csv.column-roles')); } } \ No newline at end of file From c1f142af78a6b83fb2126850b448ede68191cbbd Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 16:12:22 +0200 Subject: [PATCH 39/60] Fix some redirect things. --- app/Http/Controllers/AccountController.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 6e8778949a..ea32a95b3d 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -215,13 +215,11 @@ class AccountController extends Controller // set value so create routine will not overwrite URL: Session::put('accounts.create.fromStore', true); - return Redirect::route('accounts.create')->withInput(); + return redirect(route('accounts.create', [$request->input('what')]))->withInput(); } // redirect to previous URL. - return Redirect::to(Session::get('accounts.create.url')); - - + return redirect(Session::get('accounts.create.url')); } /** @@ -258,11 +256,11 @@ class AccountController extends Controller // set value so edit routine will not overwrite URL: Session::put('accounts.edit.fromUpdate', true); - return Redirect::route('accounts.edit', [$account->id])->withInput(['return_to_edit' => 1]); + return redirect(route('accounts.edit', [$account->id]))->withInput(['return_to_edit' => 1]); } // redirect to previous URL. - return Redirect::to(Session::get('accounts.edit.url')); + return redirect(Session::get('accounts.edit.url')); } From ab53cdb8967d771039b13cd47bc26ba9aa308a7a Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 16:27:21 +0200 Subject: [PATCH 40/60] Cleanup redirect code. --- app/Http/Controllers/AccountController.php | 3 +-- app/Http/Controllers/BillController.php | 16 +++++++--------- app/Http/Controllers/BudgetController.php | 13 ++++++------- app/Http/Controllers/CategoryController.php | 11 +++++------ app/Http/Controllers/CsvController.php | 1 - app/Http/Controllers/CurrencyController.php | 17 ++++++++--------- app/Http/Controllers/HomeController.php | 8 +++----- app/Http/Controllers/NewUserController.php | 5 ++--- app/Http/Controllers/PiggyBankController.php | 15 +++++++-------- app/Http/Controllers/PreferencesController.php | 3 +-- app/Http/Controllers/ProfileController.php | 11 +++++------ app/Http/Controllers/TagController.php | 11 +++++------ app/Http/Controllers/TransactionController.php | 11 +++++------ 13 files changed, 55 insertions(+), 70 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index ea32a95b3d..1a589b9f4c 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -8,7 +8,6 @@ use FireflyIII\Models\Account; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use Input; use Preferences; -use Redirect; use Session; use Steam; use URL; @@ -89,7 +88,7 @@ class AccountController extends Controller Session::flash('success', trans('firefly.' . $typeName . '_deleted', ['name' => $name])); Preferences::mark(); - return Redirect::to(Session::get('accounts.delete.url')); + return redirect(Session::get('accounts.delete.url')); } /** diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index 5439dcb676..ca59f0d256 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -7,7 +7,6 @@ use FireflyIII\Models\TransactionJournal; use FireflyIII\Repositories\Bill\BillRepositoryInterface; use Input; use Preferences; -use Redirect; use Session; use URL; use View; @@ -79,8 +78,7 @@ class BillController extends Controller Session::flash('success', 'The bill was deleted.'); Preferences::mark(); - return Redirect::to(Session::get('bills.delete.url')); - + return redirect(Session::get('bills.delete.url')); } /** @@ -133,7 +131,7 @@ class BillController extends Controller if (intval($bill->active) == 0) { Session::flash('warning', 'Inactive bills cannot be scanned.'); - return Redirect::to(URL::previous()); + return redirect(URL::previous()); } $journals = $repository->getPossiblyRelatedJournals($bill); @@ -146,7 +144,7 @@ class BillController extends Controller Session::flash('success', 'Rescanned everything.'); Preferences::mark(); - return Redirect::to(URL::previous()); + return redirect(URL::previous()); } /** @@ -182,11 +180,11 @@ class BillController extends Controller // set value so create routine will not overwrite URL: Session::put('bills.create.fromStore', true); - return Redirect::route('bills.create')->withInput(); + return redirect(route('bills.create'))->withInput(); } // redirect to previous URL. - return Redirect::to(Session::get('bills.create.url')); + return redirect(Session::get('bills.create.url')); } @@ -209,11 +207,11 @@ class BillController extends Controller // set value so edit routine will not overwrite URL: Session::put('bills.edit.fromUpdate', true); - return Redirect::route('bills.edit', [$bill->id])->withInput(['return_to_edit' => 1]); + return redirect(route('bills.edit', [$bill->id]))->withInput(['return_to_edit' => 1]); } // redirect to previous URL. - return Redirect::to(Session::get('bills.edit.url')); + return redirect(Session::get('bills.edit.url')); } diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 04f3b4706a..5e698ee423 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -9,7 +9,6 @@ use FireflyIII\Models\LimitRepetition; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use Input; use Preferences; -use Redirect; use Response; use Session; use URL; @@ -106,7 +105,7 @@ class BudgetController extends Controller Preferences::mark(); - return Redirect::to(Session::get('budgets.delete.url')); + return redirect(Session::get('budgets.delete.url')); } /** @@ -200,7 +199,7 @@ class BudgetController extends Controller Preferences::set('budgetIncomeTotal' . $date, intval(Input::get('amount'))); Preferences::mark(); - return Redirect::route('budgets.index'); + return redirect(route('budgets.index')); } /** @@ -254,11 +253,11 @@ class BudgetController extends Controller // set value so create routine will not overwrite URL: Session::put('budgets.create.fromStore', true); - return Redirect::route('budgets.create')->withInput(); + return redirect(route('budgets.create'))->withInput(); } // redirect to previous URL. - return Redirect::to(Session::get('budgets.create.url')); + return redirect(Session::get('budgets.create.url')); } @@ -285,11 +284,11 @@ class BudgetController extends Controller // set value so edit routine will not overwrite URL: Session::put('budgets.edit.fromUpdate', true); - return Redirect::route('budgets.edit', [$budget->id])->withInput(['return_to_edit' => 1]); + return redirect(route('budgets.edit', [$budget->id]))->withInput(['return_to_edit' => 1]); } // redirect to previous URL. - return Redirect::to(Session::get('budgets.edit.url')); + return redirect(Session::get('budgets.edit.url')); } diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 0a6bc918b0..790d2fd822 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -8,7 +8,6 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use Illuminate\Pagination\LengthAwarePaginator; use Input; use Preferences; -use Redirect; use Session; use URL; use View; @@ -80,7 +79,7 @@ class CategoryController extends Controller Session::flash('success', 'The category "' . e($name) . '" was deleted.'); Preferences::mark(); - return Redirect::to(Session::get('categories.delete.url')); + return redirect(Session::get('categories.delete.url')); } /** @@ -178,10 +177,10 @@ class CategoryController extends Controller if (intval(Input::get('create_another')) === 1) { Session::put('categories.create.fromStore', true); - return Redirect::route('categories.create')->withInput(); + return redirect(route('categories.create'))->withInput(); } - return Redirect::route('categories.index'); + return redirect(route('categories.index')); } @@ -206,11 +205,11 @@ class CategoryController extends Controller if (intval(Input::get('return_to_edit')) === 1) { Session::put('categories.edit.fromUpdate', true); - return Redirect::route('categories.edit', [$category->id]); + return redirect(route('categories.edit', [$category->id])); } // redirect to previous URL. - return Redirect::to(Session::get('categories.edit.url')); + return redirect(Session::get('categories.edit.url')); } diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 9f923c6a3a..fb77c50924 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -12,7 +12,6 @@ use Illuminate\Http\Request; use Input; use Log; use Preferences; -use Redirect; use Session; use View; diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index a1e6ac294d..b808805255 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -7,7 +7,6 @@ use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use Input; use Preferences; -use Redirect; use Session; use URL; use View; @@ -65,7 +64,7 @@ class CurrencyController extends Controller Cache::forget('FFCURRENCYSYMBOL'); Cache::forget('FFCURRENCYCODE'); - return Redirect::route('currency.index'); + return redirect(route('currency.index')); } @@ -81,7 +80,7 @@ class CurrencyController extends Controller if ($repository->countJournals($currency) > 0) { Session::flash('error', 'Cannot delete ' . e($currency->name) . ' because there are still transactions attached to it.'); - return Redirect::route('currency.index'); + return redirect(route('currency.index')); } // put previous url in session @@ -106,7 +105,7 @@ class CurrencyController extends Controller if ($repository->countJournals($currency) > 0) { Session::flash('error', 'Cannot destroy ' . e($currency->name) . ' because there are still transactions attached to it.'); - return Redirect::route('currency.index'); + return redirect(route('currency.index')); } Session::flash('success', 'Currency "' . e($currency->name) . '" deleted'); @@ -114,7 +113,7 @@ class CurrencyController extends Controller $currency->delete(); } - return Redirect::to(Session::get('currency.delete.url')); + return redirect(Session::get('currency.delete.url')); } /** @@ -178,11 +177,11 @@ class CurrencyController extends Controller if (intval(Input::get('create_another')) === 1) { Session::put('currency.create.fromStore', true); - return Redirect::route('currency.create')->withInput(); + return redirect(route('currency.create'))->withInput(); } // redirect to previous URL. - return Redirect::to(Session::get('currency.create.url')); + return redirect(Session::get('currency.create.url')); } @@ -207,11 +206,11 @@ class CurrencyController extends Controller if (intval(Input::get('return_to_edit')) === 1) { Session::put('currency.edit.fromUpdate', true); - return Redirect::route('currency.edit', [$currency->id]); + return redirect(route('currency.edit', [$currency->id])); } // redirect to previous URL. - return Redirect::to(Session::get('currency.edit.url')); + return redirect(Session::get('currency.edit.url')); } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index d57649bd24..a0fb4c0e09 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -7,7 +7,6 @@ use FireflyIII\Models\Tag; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use Input; use Preferences; -use Redirect; use Route; use Session; use Steam; @@ -57,10 +56,9 @@ class HomeController extends Controller } - Session::clear(); - return Redirect::route('index'); + return redirect(route('index')); } /** @@ -75,7 +73,7 @@ class HomeController extends Controller if ($count == 0) { - return Redirect::route('new-user.index'); + return redirect(route('new-user.index')); } $title = 'Firefly'; @@ -127,7 +125,7 @@ class HomeController extends Controller if (!Auth::user()->hasRole('owner')) { Session::flash('warning', 'This page is broken.'); - return Redirect::route('index'); + return redirect(route('index')); } // get all routes: diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php index 563bf81e28..c8bd931660 100644 --- a/app/Http/Controllers/NewUserController.php +++ b/app/Http/Controllers/NewUserController.php @@ -7,7 +7,6 @@ use FireflyIII\Http\Requests\NewUserFormRequest; use FireflyIII\Models\AccountMeta; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use Preferences; -use Redirect; use Session; use View; @@ -35,7 +34,7 @@ class NewUserController extends Controller $count = $repository->countAccounts($types); if ($count > 0) { - return Redirect::route('index'); + return redirect(route('index')); } @@ -106,6 +105,6 @@ class NewUserController extends Controller Session::flash('success', 'New account(s) created!'); Preferences::mark(); - return Redirect::route('index'); + return redirect(route('index')); } } diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index fecc0978c3..00900f9d08 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -11,7 +11,6 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use Illuminate\Support\Collection; use Input; use Preferences; -use Redirect; use Session; use Steam; use URL; @@ -112,7 +111,7 @@ class PiggyBankController extends Controller Preferences::mark(); $repository->destroy($piggyBank); - return Redirect::to(Session::get('piggy-banks.delete.url')); + return redirect(Session::get('piggy-banks.delete.url')); } /** @@ -246,7 +245,7 @@ class PiggyBankController extends Controller Session::flash('error', 'Could not add ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".'); } - return Redirect::route('piggy-banks.index'); + return redirect(route('piggy-banks.index')); } /** @@ -275,7 +274,7 @@ class PiggyBankController extends Controller Session::flash('error', 'Could not remove ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".'); } - return Redirect::route('piggy-banks.index'); + return redirect(route('piggy-banks.index')); } /** @@ -331,12 +330,12 @@ class PiggyBankController extends Controller if (intval(Input::get('create_another')) === 1) { Session::put('piggy-banks.create.fromStore', true); - return Redirect::route('piggy-banks.create')->withInput(); + return redirect(route('piggy-banks.create'))->withInput(); } // redirect to previous URL. - return Redirect::to(Session::get('piggy-banks.create.url')); + return redirect(Session::get('piggy-banks.create.url')); } /** @@ -366,12 +365,12 @@ class PiggyBankController extends Controller if (intval(Input::get('return_to_edit')) === 1) { Session::put('piggy-banks.edit.fromUpdate', true); - return Redirect::route('piggy-banks.edit', [$piggyBank->id]); + return redirect(route('piggy-banks.edit', [$piggyBank->id])); } // redirect to previous URL. - return Redirect::to(Session::get('piggy-banks.edit.url')); + return redirect(Session::get('piggy-banks.edit.url')); } diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index 5fd6e4fd24..8bfd176f53 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -4,7 +4,6 @@ use Config; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use Input; use Preferences; -use Redirect; use Session; use View; @@ -79,7 +78,7 @@ class PreferencesController extends Controller Session::flash('success', 'Preferences saved!'); Preferences::mark(); - return Redirect::route('preferences'); + return redirect(route('preferences')); } } diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index ae39246843..8a1c02d227 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -5,7 +5,6 @@ use FireflyIII\Http\Requests; use FireflyIII\Http\Requests\DeleteAccountFormRequest; use FireflyIII\Http\Requests\ProfileFormRequest; use Hash; -use Redirect; use Session; /** @@ -56,13 +55,13 @@ class ProfileController extends Controller if (!Hash::check($request->get('current_password'), Auth::user()->password)) { Session::flash('error', 'Invalid current password!'); - return Redirect::route('profile.change-password'); + return redirect(route('profile.change-password')); } $result = $this->validatePassword($request->get('current_password'), $request->get('new_password')); if (!($result === true)) { Session::flash('error', $result); - return Redirect::route('profile.change-password'); + return redirect(route('profile.change-password')); } // update the user with the new password. @@ -71,7 +70,7 @@ class ProfileController extends Controller Session::flash('success', 'Password changed!'); - return Redirect::route('profile'); + return redirect(route('profile')); } /** @@ -103,7 +102,7 @@ class ProfileController extends Controller if (!Hash::check($request->get('password'), Auth::user()->password)) { Session::flash('error', 'Invalid password!'); - return Redirect::route('profile.delete-account'); + return redirect(route('profile.delete-account')); } // DELETE! @@ -112,7 +111,7 @@ class ProfileController extends Controller Session::flash('gaEventCategory', 'user'); Session::flash('gaEventAction', 'delete-account'); - return Redirect::route('index'); + return redirect(route('index')); } diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index d8a3d489c6..1a111a5448 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -10,7 +10,6 @@ use FireflyIII\Models\Tag; use FireflyIII\Repositories\Tag\TagRepositoryInterface; use Input; use Preferences; -use Redirect; use Response; use Session; use URL; @@ -108,7 +107,7 @@ class TagController extends Controller Session::flash('success', 'Tag "' . e($tagName) . '" was deleted.'); Preferences::mark(); - return Redirect::to(route('tags.index')); + return redirect(route('tags.index')); } /** @@ -248,11 +247,11 @@ class TagController extends Controller // set value so create routine will not overwrite URL: Session::put('tags.create.fromStore', true); - return Redirect::route('tags.create')->withInput(); + return redirect(route('tags.create'))->withInput(); } // redirect to previous URL. - return Redirect::to(Session::get('tags.create.url')); + return redirect(Session::get('tags.create.url')); } @@ -295,10 +294,10 @@ class TagController extends Controller // set value so edit routine will not overwrite URL: Session::put('tags.edit.fromUpdate', true); - return Redirect::route('tags.edit', [$tag->id])->withInput(['return_to_edit' => 1]); + return redirect(route('tags.edit', [$tag->id]))->withInput(['return_to_edit' => 1]); } // redirect to previous URL. - return Redirect::to(Session::get('tags.edit.url')); + return redirect(Session::get('tags.edit.url')); } } diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 0708263271..98896829d5 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -12,7 +12,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use Input; use Preferences; -use Redirect; use Response; use Session; use URL; @@ -108,7 +107,7 @@ class TransactionController extends Controller Preferences::mark(); // redirect to previous URL: - return Redirect::to(Session::get('transactions.delete.url')); + return redirect(Session::get('transactions.delete.url')); } /** @@ -295,11 +294,11 @@ class TransactionController extends Controller // set value so create routine will not overwrite URL: Session::put('transactions.create.fromStore', true); - return Redirect::route('transactions.create', [$request->input('what')])->withInput(); + return redirect(route('transactions.create', [$request->input('what')]))->withInput(); } // redirect to previous URL. - return Redirect::to(Session::get('transactions.create.url')); + return redirect(Session::get('transactions.create.url')); } @@ -327,11 +326,11 @@ class TransactionController extends Controller // set value so edit routine will not overwrite URL: Session::put('transactions.edit.fromUpdate', true); - return Redirect::route('transactions.edit', [$journal->id])->withInput(['return_to_edit' => 1]); + return redirect(route('transactions.edit', [$journal->id]))->withInput(['return_to_edit' => 1]); } // redirect to previous URL. - return Redirect::to(Session::get('transactions.edit.url')); + return redirect(Session::get('transactions.edit.url')); } From d05c165acebfe60a14bb336f077dc92298aba327 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 16:33:54 +0200 Subject: [PATCH 41/60] These might be the final issues on scrutiniser, apart from code complexity. --- app/Helpers/Csv/Importer.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 0ce9fab492..3c6ded585d 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -15,8 +15,6 @@ use FireflyIII\Models\TransactionType; use Illuminate\Support\MessageBag; use Log; -set_time_limit(0); - /** * Class Importer * @@ -69,6 +67,8 @@ class Importer */ public function run() { + set_time_limit(0); + $this->map = $this->data->getMap(); $this->roles = $this->data->getRoles(); $this->mapped = $this->data->getMapped(); @@ -193,14 +193,6 @@ class Importer $data = $postProcessor->process(); } - - // $specifix = new Specifix(); - // $specifix->setData($data); - // $specifix->setRow($row); - //$specifix->fix($data, $row); // TODO - // get data back: - //$data = $specifix->getData(); // TODO - return $data; } @@ -224,7 +216,7 @@ class Importer /** * @param array $data * - * @return static + * @return TransactionJournal|string */ protected function createTransactionJournal(array $data) { From 6bdb6db330966439a90d2fb03ca0efba0b61cec0 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 16:42:19 +0200 Subject: [PATCH 42/60] Fixed some problems. --- app/Helpers/Csv/Importer.php | 6 +++--- app/Http/Controllers/CsvController.php | 1 - app/Support/ExpandedForm.php | 1 - app/Validation/FireflyValidator.php | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 3c6ded585d..fa23c6f327 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -126,9 +126,8 @@ class Importer } // post processing and validating. - $data = $this->postProcess($data, $row); - $result = $this->validateData($data); - $journal = null; + $data = $this->postProcess($data, $row); + $result = $this->validateData($data); if ($result === true) { $journal = $this->createTransactionJournal($data); } else { @@ -274,6 +273,7 @@ class Importer $journal->save(); } else { $text = join(',', $errors->all()); + return $text; } diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index fb77c50924..5d0a7cffe7 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -106,7 +106,6 @@ class CsvController extends Controller 'date-format' => Session::get('date-format'), 'has-headers' => Session::get('csv-has-headers') ]; - // $fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-map', 'csv-roles', 'csv-mapped']; if (Session::has('csv-map')) { $data['map'] = Session::get('csv-map'); } diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index 62505adac6..37baf3dab0 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -349,7 +349,6 @@ class ExpandedForm /** * @param $name - * @param null $value * @param array $options * * @return string diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 6c177af69d..4d87ad39b8 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -59,7 +59,7 @@ class FireflyValidator extends Validator * @param $value * @param $parameters */ - public function validateIban($attribute, $value, $parameters) + public function validateIban($attribute, $value) { $value = strtoupper($value); From 3fb14b4708f39320f2e91c8f167ca87e33a22368 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 16:52:18 +0200 Subject: [PATCH 43/60] Code cleanup. --- .../Account/ChartJsAccountChartGenerator.php | 1 + .../Budget/GoogleBudgetChartGenerator.php | 1 + .../ChartJsCategoryChartGenerator.php | 3 ++- .../Category/GoogleCategoryChartGenerator.php | 1 + .../Report/ChartJsReportChartGenerator.php | 2 +- .../Csv/Converter/ConverterInterface.php | 22 +++++++++---------- app/Helpers/Csv/Converter/CurrencyCode.php | 1 + app/Helpers/Csv/Converter/CurrencyName.php | 1 + app/Helpers/Csv/Mapper/AnyAccount.php | 2 +- app/Helpers/Csv/PostProcessing/Currency.php | 7 +++--- .../PostProcessing/PostProcessorInterface.php | 13 ++++++----- app/Helpers/Csv/Wizard.php | 2 +- app/Helpers/Csv/WizardInterface.php | 1 + app/Models/AccountMeta.php | 2 +- app/Models/AccountType.php | 2 +- app/Models/Bill.php | 2 +- app/Models/Budget.php | 3 ++- app/Models/BudgetLimit.php | 2 +- app/Models/Component.php | 2 +- app/Models/LimitRepetition.php | 2 +- app/Models/PiggyBank.php | 8 +++---- app/Models/PiggyBankEvent.php | 2 +- app/Models/PiggyBankRepetition.php | 2 +- app/Models/Preference.php | 2 +- app/Models/Transaction.php | 2 +- app/Models/TransactionCurrency.php | 2 +- app/Models/TransactionGroup.php | 2 +- app/Models/TransactionRelation.php | 2 +- app/Models/TransactionType.php | 2 +- app/Support/Navigation.php | 10 ++++----- app/User.php | 2 +- 31 files changed, 59 insertions(+), 49 deletions(-) diff --git a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php index b084678de0..a6ab113571 100644 --- a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php +++ b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php @@ -20,6 +20,7 @@ class ChartJsAccountChartGenerator implements AccountChartGenerator /** * @codeCoverageIgnore + * * @param Collection $accounts * @param Carbon $start * @param Carbon $end diff --git a/app/Generator/Chart/Budget/GoogleBudgetChartGenerator.php b/app/Generator/Chart/Budget/GoogleBudgetChartGenerator.php index a463a6b296..848c493b68 100644 --- a/app/Generator/Chart/Budget/GoogleBudgetChartGenerator.php +++ b/app/Generator/Chart/Budget/GoogleBudgetChartGenerator.php @@ -37,6 +37,7 @@ class GoogleBudgetChartGenerator implements BudgetChartGenerator /** * @codeCoverageIgnore + * * @param Collection $entries * * @return array diff --git a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php index 49f92827b7..42e17d875c 100644 --- a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php +++ b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php @@ -17,7 +17,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator /** * @param Collection $entries - * @param string $dateFormat + * @param string $dateFormat * * @return array */ @@ -76,6 +76,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator /** * @codeCoverageIgnore + * * @param Collection $entries * * @return array diff --git a/app/Generator/Chart/Category/GoogleCategoryChartGenerator.php b/app/Generator/Chart/Category/GoogleCategoryChartGenerator.php index b6187f64ed..476f90c998 100644 --- a/app/Generator/Chart/Category/GoogleCategoryChartGenerator.php +++ b/app/Generator/Chart/Category/GoogleCategoryChartGenerator.php @@ -99,6 +99,7 @@ class GoogleCategoryChartGenerator implements CategoryChartGenerator $chart->addRowArray($entry); } $chart->generate(); + return $chart->getData(); } diff --git a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php index c1b5cdf5a7..516d2f5332 100644 --- a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php +++ b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php @@ -3,7 +3,6 @@ namespace FireflyIII\Generator\Chart\Report; use Config; -use Grumpydictator\Gchart\GChart; use Illuminate\Support\Collection; use Preferences; @@ -78,6 +77,7 @@ class ChartJsReportChartGenerator implements ReportChartGenerator $data['datasets'][1]['data'][] = round($expense, 2); $data['datasets'][0]['data'][] = round(($income / $count), 2); $data['datasets'][1]['data'][] = round(($expense / $count), 2); + return $data; } } diff --git a/app/Helpers/Csv/Converter/ConverterInterface.php b/app/Helpers/Csv/Converter/ConverterInterface.php index aad4e3999a..f6a0cae84d 100644 --- a/app/Helpers/Csv/Converter/ConverterInterface.php +++ b/app/Helpers/Csv/Converter/ConverterInterface.php @@ -15,6 +15,17 @@ interface ConverterInterface */ public function convert(); + /** + * @param array $data + */ + public function setData(array $data); + + /** + * @param string $field + * + */ + public function setField($field); + /** * @param int $index */ @@ -35,15 +46,4 @@ interface ConverterInterface */ public function setValue($value); - /** - * @param array $data - */ - public function setData(array $data); - - /** - * @param string $field - * - */ - public function setField($field); - } \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/CurrencyCode.php b/app/Helpers/Csv/Converter/CurrencyCode.php index 2e0baf50d5..e416257f92 100644 --- a/app/Helpers/Csv/Converter/CurrencyCode.php +++ b/app/Helpers/Csv/Converter/CurrencyCode.php @@ -1,6 +1,7 @@ accounts()->with('accountType')->orderBy('accounts.name', 'ASC')->get(['accounts.*']); - $list = []; + $list = []; /** @var Account $account */ foreach ($result as $account) { $list[$account->id] = $account->name . ' (' . $account->accountType->type . ')'; diff --git a/app/Helpers/Csv/PostProcessing/Currency.php b/app/Helpers/Csv/PostProcessing/Currency.php index 66c77ef189..f985c6a881 100644 --- a/app/Helpers/Csv/PostProcessing/Currency.php +++ b/app/Helpers/Csv/PostProcessing/Currency.php @@ -1,8 +1,9 @@ data['currency'])) { - $currencyPreference = Preferences::get('currencyPreference', 'EUR'); - $this->data['currency'] = TransactionCurrency::whereCode($currencyPreference->data)->first(); + $currencyPreference = Preferences::get('currencyPreference', 'EUR'); + $this->data['currency'] = TransactionCurrency::whereCode($currencyPreference->data)->first(); } return $this->data; diff --git a/app/Helpers/Csv/PostProcessing/PostProcessorInterface.php b/app/Helpers/Csv/PostProcessing/PostProcessorInterface.php index dc2b04e64c..88a8ad1da7 100644 --- a/app/Helpers/Csv/PostProcessing/PostProcessorInterface.php +++ b/app/Helpers/Csv/PostProcessing/PostProcessorInterface.php @@ -14,15 +14,16 @@ namespace FireflyIII\Helpers\Csv\PostProcessing; * * @package FireflyIII\Helpers\Csv\PostProcessing */ -interface PostProcessorInterface { - - /** - * @param array $data - */ - public function setData(array $data); +interface PostProcessorInterface +{ /** * @return array */ public function process(); + + /** + * @param array $data + */ + public function setData(array $data); } \ No newline at end of file diff --git a/app/Helpers/Csv/Wizard.php b/app/Helpers/Csv/Wizard.php index 92291e7f45..a443fa06f1 100644 --- a/app/Helpers/Csv/Wizard.php +++ b/app/Helpers/Csv/Wizard.php @@ -129,7 +129,7 @@ class Wizard implements WizardInterface */ public function showOptions(array $map) { - $options = []; + $options = []; foreach ($map as $index => $columnRole) { $mapper = Config::get('csv.roles.' . $columnRole . '.mapper'); diff --git a/app/Helpers/Csv/WizardInterface.php b/app/Helpers/Csv/WizardInterface.php index bd938ad248..bd86a21495 100644 --- a/app/Helpers/Csv/WizardInterface.php +++ b/app/Helpers/Csv/WizardInterface.php @@ -1,6 +1,7 @@ Date: Mon, 6 Jul 2015 17:45:59 +0200 Subject: [PATCH 44/60] Fixed some duplication. --- .../Account/GoogleAccountChartGenerator.php | 27 +------------------ .../Chart/Bill/ChartJsBillChartGenerator.php | 5 ++-- .../Chart/Bill/GoogleBillChartGenerator.php | 12 ++++++--- .../Budget/ChartJsBudgetChartGenerator.php | 4 +-- 4 files changed, 15 insertions(+), 33 deletions(-) diff --git a/app/Generator/Chart/Account/GoogleAccountChartGenerator.php b/app/Generator/Chart/Account/GoogleAccountChartGenerator.php index 3859175b3d..ab84e168ce 100644 --- a/app/Generator/Chart/Account/GoogleAccountChartGenerator.php +++ b/app/Generator/Chart/Account/GoogleAccountChartGenerator.php @@ -64,32 +64,7 @@ class GoogleAccountChartGenerator implements AccountChartGenerator */ public function frontpage(Collection $accounts, Carbon $start, Carbon $end) { - $chart = new GChart; - $chart->addColumn(trans('firefly.dayOfMonth'), 'date'); - - $index = 1; - /** @var Account $account */ - foreach ($accounts as $account) { - $chart->addColumn(trans('firefly.balanceFor', ['name' => $account->name]), 'number'); - $chart->addCertainty($index); - $index++; - } - $current = clone $start; - $current->subDay(); - $today = Carbon::now(); - while ($end >= $current) { - $row = [clone $current]; - $certain = $current < $today; - foreach ($accounts as $account) { - $row[] = Steam::balance($account, $current); - $row[] = $certain; - } - $chart->addRowArray($row); - $current->addDay(); - } - $chart->generate(); - - return $chart->getData(); + return $this->all($accounts, $start, $end); } /** diff --git a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php index c7ba8172d5..8580bbf1b2 100644 --- a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php +++ b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php @@ -31,12 +31,13 @@ class ChartJsBillChartGenerator implements BillChartGenerator $unpaidDescriptions = []; $unpaidAmount = 0; + bcscale(2); /** @var TransactionJournal $entry */ foreach ($paid as $entry) { $paidDescriptions[] = $entry->description; - $paidAmount += floatval($entry->amount); + $paidAmount = bcadd($paidAmount, $entry->amount); } // loop unpaid: @@ -45,7 +46,7 @@ class ChartJsBillChartGenerator implements BillChartGenerator $description = $entry[0]->name . ' (' . $entry[1]->format('jS M Y') . ')'; $amount = ($entry[0]->amount_max + $entry[0]->amount_min) / 2; $unpaidDescriptions[] = $description; - $unpaidAmount += $amount; + $unpaidAmount = bcadd($unpaidAmount, $amount); unset($amount, $description); } diff --git a/app/Generator/Chart/Bill/GoogleBillChartGenerator.php b/app/Generator/Chart/Bill/GoogleBillChartGenerator.php index 8864bb8306..87960405ec 100644 --- a/app/Generator/Chart/Bill/GoogleBillChartGenerator.php +++ b/app/Generator/Chart/Bill/GoogleBillChartGenerator.php @@ -30,12 +30,14 @@ class GoogleBillChartGenerator implements BillChartGenerator $unpaidDescriptions = []; $unpaidAmount = 0; + bcscale(2); + /** @var TransactionJournal $entry */ foreach ($paid as $entry) { $paidDescriptions[] = $entry->description; - $paidAmount += floatval($entry->amount); + $paidAmount = bcadd($paidAmount, $entry->amount); } // loop unpaid: @@ -44,7 +46,7 @@ class GoogleBillChartGenerator implements BillChartGenerator $description = $entry[0]->name . ' (' . $entry[1]->format('jS M Y') . ')'; $amount = ($entry[0]->amount_max + $entry[0]->amount_min) / 2; $unpaidDescriptions[] = $description; - $unpaidAmount += $amount; + $unpaidAmount = bcadd($unpaidAmount, $amount); unset($amount, $description); } @@ -77,7 +79,11 @@ class GoogleBillChartGenerator implements BillChartGenerator /** @var TransactionJournal $result */ foreach ($entries as $result) { - $chart->addRow(clone $result->date, floatval($bill->amount_max), floatval($bill->amount_min), floatval($result->amount)); + $chart->addRow( + clone $result->date, + floatval($bill->amount_max), + floatval($bill->amount_min), + floatval($result->amount)); } $chart->generate(); diff --git a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php index e7665fe9b9..d91a293286 100644 --- a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php +++ b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php @@ -28,7 +28,6 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator $format = Config::get('firefly.' . $dateFormat . '.' . $language); $data = [ - 'count' => 1, 'labels' => [], 'datasets' => [ [ @@ -45,6 +44,8 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator } + $data['count'] = count($data['datasets']); + return $data; } @@ -118,7 +119,6 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator $format = Config::get('firefly.month.' . $language); $data = [ - 'count' => 0, 'labels' => [], 'datasets' => [], ]; From 93b6c68938fb65910c13fa3d27572bda3956ae43 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 18:04:13 +0200 Subject: [PATCH 45/60] Some math fixes. Not bugs. --- app/Helpers/Report/ReportHelper.php | 13 +++++++------ app/Http/Controllers/AccountController.php | 3 ++- app/Http/Controllers/Chart/BudgetController.php | 5 +++-- app/Http/Controllers/HomeController.php | 3 ++- app/Http/Controllers/JsonController.php | 8 +++++--- app/Http/Controllers/PiggyBankController.php | 12 +++++++----- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index e6472824c1..37222d4123 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -60,9 +60,10 @@ class ReportHelper implements ReportHelperInterface $accounts = $this->query->getAllAccounts($date, $end, $shared); - $start = 0; - $end = 0; - $diff = 0; + $start = '0'; + $end = '0'; + $diff = '0'; + bcscale(2); // remove cash account, if any: $accounts = $accounts->filter( @@ -77,9 +78,9 @@ class ReportHelper implements ReportHelperInterface // summarize: foreach ($accounts as $account) { - $start += $account->startBalance; - $end += $account->endBalance; - $diff += ($account->endBalance - $account->startBalance); + $start = bcadd($start, $account->startBalance); + $end = bcadd($end, $account->endBalance); + $diff = bcadd($diff, ($account->endBalance - $account->startBalance)); } $object = new AccountCollection; diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 1a589b9f4c..0a904f593c 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -205,7 +205,8 @@ class AccountController extends Controller 'openingBalanceCurrency' => intval($request->input('balance_currency_id')), ]; - $account = $repository->store($accountData); + + $account = $repository->store($accountData); Session::flash('success', 'New account "' . $account->name . '" stored!'); Preferences::mark(); diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index 45bd8a2a44..ad7192415d 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -93,6 +93,7 @@ class BudgetController extends Controller { $start = clone $repetition->startdate; $end = $repetition->enddate; + bcscale(2); // chart properties for cache: $cache = new CacheProperties(); @@ -113,8 +114,8 @@ class BudgetController extends Controller /* * Sum of expenses on this day: */ - $sum = $repository->expensesOnDayCorrected($budget, $start); - $amount += $sum; + $sum = $repository->expensesOnDayCorrected($budget, $start); + $amount = bcadd($amount, $sum); $entries->push([clone $start, $amount]); $start->addDay(); } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index a0fb4c0e09..78db6cc105 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -70,6 +70,7 @@ class HomeController extends Controller { $types = Config::get('firefly.accountTypesByIdentifier.asset'); $count = $repository->countAccounts($types); + bcscale(2); if ($count == 0) { @@ -92,7 +93,7 @@ class HomeController extends Controller $savingsTotal = 0; foreach ($savings as $savingAccount) { - $savingsTotal += Steam::balance($savingAccount, $end); + $savingsTotal = bcadd($savingsTotal, Steam::balance($savingAccount, $end)); } $sum = $repository->sumOfEverything(); diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index 6dafae3266..e543534751 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -36,6 +36,7 @@ class JsonController extends Controller { $start = Session::get('start', Carbon::now()->startOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth()); + bcscale(2); // works for json too! $cache = new CacheProperties; @@ -54,7 +55,7 @@ class JsonController extends Controller /** @var Bill $bill */ foreach ($bills as $bill) { - $amount += $repository->billPaymentsInRange($bill, $start, $end); + $amount = bcadd($amount, $repository->billPaymentsInRange($bill, $start, $end)); } unset($bill, $bills); @@ -69,7 +70,7 @@ class JsonController extends Controller if ($balance == 0) { // find a transfer TO the credit card which should account for // anything paid. If not, the CC is not yet used. - $amount += $accountRepository->getTransfersInRange($creditCard, $start, $end)->sum('amount'); + $amount = bcadd($amount, $accountRepository->getTransfersInRange($creditCard, $start, $end)->sum('amount')); } } $data = ['box' => 'bills-paid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; @@ -90,6 +91,7 @@ class JsonController extends Controller $amount = 0; $start = Session::get('start', Carbon::now()->startOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth()); + bcscale(2); // works for json too! $cache = new CacheProperties; @@ -131,7 +133,7 @@ class JsonController extends Controller /** @var Bill $entry */ foreach ($unpaid as $entry) { $current = ($entry[0]->amount_max + $entry[0]->amount_min) / 2; - $amount += $current; + $amount = bcadd($amount, $current); } $data = ['box' => 'bills-unpaid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 00900f9d08..4f5fd75996 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -166,6 +166,7 @@ class PiggyBankController extends Controller /** @var Collection $piggyBanks */ $piggyBanks = $piggyRepository->getPiggyBanks(); $end = Session::get('end', Carbon::now()->endOfMonth()); + bcscale(2); $accounts = []; /** @var PiggyBank $piggyBank */ @@ -188,9 +189,9 @@ class PiggyBankController extends Controller 'leftToSave' => $piggyBank->leftToSave ]; } else { - $accounts[$account->id]['sumOfSaved'] += $piggyBank->savedSoFar; - $accounts[$account->id]['sumOfTargets'] += floatval($piggyBank->targetamount); - $accounts[$account->id]['leftToSave'] += $piggyBank->leftToSave; + $accounts[$account->id]['sumOfSaved'] = bcadd($accounts[$account->id]['sumOfSaved'], $piggyBank->savedSoFar); + $accounts[$account->id]['sumOfTargets'] = bcadd($accounts[$account->id]['sumOfTargets'], $piggyBank->targetamount); + $accounts[$account->id]['leftToSave'] = bcadd($accounts[$account->id]['leftToSave'], $piggyBank->leftToSave); } } @@ -230,10 +231,11 @@ class PiggyBankController extends Controller $savedSoFar = $piggyBank->currentRelevantRep()->currentamount; $leftToSave = $piggyBank->targetamount - $savedSoFar; $maxAmount = round(min($leftOnAccount, $leftToSave), 2); + bcscale(2); if ($amount <= $maxAmount) { - $repetition = $piggyBank->currentRelevantRep(); - $repetition->currentamount += $amount; + $repetition = $piggyBank->currentRelevantRep(); + $repetition->currentamount = bcadd($repetition->currentamount, $amount); $repetition->save(); // create event From f38d38f1398fe9c38ea58a4f10f41a45b776c47f Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 18:06:31 +0200 Subject: [PATCH 46/60] Math fixes. Not bugs. --- app/Http/Controllers/PiggyBankController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 4f5fd75996..049f4c83b3 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -259,12 +259,13 @@ class PiggyBankController extends Controller public function postRemove(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank) { $amount = floatval(Input::get('amount')); + bcscale(2); $savedSoFar = $piggyBank->currentRelevantRep()->currentamount; if ($amount <= $savedSoFar) { - $repetition = $piggyBank->currentRelevantRep(); - $repetition->currentamount -= $amount; + $repetition = $piggyBank->currentRelevantRep(); + $repetition->currentamount = bcsub($repetition->currentamount, $amount); $repetition->save(); // create event From cd08484a13c80397c698c35852b0a79e90d2cb64 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 18:13:57 +0200 Subject: [PATCH 47/60] Code cleanup. --- app/Http/Controllers/CsvController.php | 2 -- app/Http/routes.php | 12 ++++++------ app/Repositories/Account/AccountRepository.php | 4 +++- app/Support/Amount.php | 1 - 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 5d0a7cffe7..942bb899fd 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -155,8 +155,6 @@ class CsvController extends Controller Session::forget('csv-mapped'); Session::forget('csv-specifix'); - // specifix TODO - // get values which are yet unsaveable or unmappable: $unsupported = []; diff --git a/app/Http/routes.php b/app/Http/routes.php index a391ead7e5..956da6a26b 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -181,7 +181,7 @@ Route::group( * Bills Controller */ Route::get('/bills', ['uses' => 'BillController@index', 'as' => 'bills.index']); - Route::get('/bills/rescan/{bill}', ['uses' => 'BillController@rescan', 'as' => 'bills.rescan']); # rescan for matching. + Route::get('/bills/rescan/{bill}', ['uses' => 'BillController@rescan', 'as' => 'bills.rescan']); Route::get('/bills/create', ['uses' => 'BillController@create', 'as' => 'bills.create']); Route::get('/bills/edit/{bill}', ['uses' => 'BillController@edit', 'as' => 'bills.edit']); Route::get('/bills/delete/{bill}', ['uses' => 'BillController@delete', 'as' => 'bills.delete']); @@ -194,7 +194,7 @@ Route::group( * Budget Controller */ Route::get('/budgets', ['uses' => 'BudgetController@index', 'as' => 'budgets.index']); - Route::get('/budgets/income', ['uses' => 'BudgetController@updateIncome', 'as' => 'budgets.income']); # extra. + Route::get('/budgets/income', ['uses' => 'BudgetController@updateIncome', 'as' => 'budgets.income']); Route::get('/budgets/create', ['uses' => 'BudgetController@create', 'as' => 'budgets.create']); Route::get('/budgets/edit/{budget}', ['uses' => 'BudgetController@edit', 'as' => 'budgets.edit']); Route::get('/budgets/delete/{budget}', ['uses' => 'BudgetController@delete', 'as' => 'budgets.delete']); @@ -312,8 +312,8 @@ Route::group( * Piggy Bank Controller */ Route::get('/piggy-banks', ['uses' => 'PiggyBankController@index', 'as' => 'piggy-banks.index']); - Route::get('/piggy-banks/add/{piggyBank}', ['uses' => 'PiggyBankController@add', 'as' => 'piggy-banks.addMoney']); # add money - Route::get('/piggy-banks/remove/{piggyBank}', ['uses' => 'PiggyBankController@remove', 'as' => 'piggy-banks.removeMoney']); #remove money + Route::get('/piggy-banks/add/{piggyBank}', ['uses' => 'PiggyBankController@add', 'as' => 'piggy-banks.addMoney']); + Route::get('/piggy-banks/remove/{piggyBank}', ['uses' => 'PiggyBankController@remove', 'as' => 'piggy-banks.removeMoney']); Route::get('/piggy-banks/create', ['uses' => 'PiggyBankController@create', 'as' => 'piggy-banks.create']); Route::get('/piggy-banks/edit/{piggyBank}', ['uses' => 'PiggyBankController@edit', 'as' => 'piggy-banks.edit']); Route::get('/piggy-banks/delete/{piggyBank}', ['uses' => 'PiggyBankController@delete', 'as' => 'piggy-banks.delete']); @@ -321,8 +321,8 @@ Route::group( Route::post('/piggy-banks/store', ['uses' => 'PiggyBankController@store', 'as' => 'piggy-banks.store']); Route::post('/piggy-banks/update/{piggyBank}', ['uses' => 'PiggyBankController@update', 'as' => 'piggy-banks.update']); Route::post('/piggy-banks/destroy/{piggyBank}', ['uses' => 'PiggyBankController@destroy', 'as' => 'piggy-banks.destroy']); - Route::post('/piggy-banks/add/{piggyBank}', ['uses' => 'PiggyBankController@postAdd', 'as' => 'piggy-banks.add']); # add money - Route::post('/piggy-banks/remove/{piggyBank}', ['uses' => 'PiggyBankController@postRemove', 'as' => 'piggy-banks.remove']); # remove money. + Route::post('/piggy-banks/add/{piggyBank}', ['uses' => 'PiggyBankController@postAdd', 'as' => 'piggy-banks.add']); + Route::post('/piggy-banks/remove/{piggyBank}', ['uses' => 'PiggyBankController@postRemove', 'as' => 'piggy-banks.remove']); Route::post('/piggy-banks/sort', ['uses' => 'PiggyBankController@order', 'as' => 'piggy-banks.order']); /** diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 9ee8e6dca2..2631f655e5 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -404,7 +404,9 @@ class AccountRepository implements AccountRepositoryInterface 'iban' => '', ]; $opposing = $this->storeAccount($opposingData); - $this->storeInitialBalance($newAccount, $opposing, $data); + if (!is_null($opposing)) { + $this->storeInitialBalance($newAccount, $opposing, $data); + } } diff --git a/app/Support/Amount.php b/app/Support/Amount.php index 30259dbc68..9b4cb692fc 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -65,7 +65,6 @@ class Amount return '' . $symbol . ' ' . $string . ''; } - // € return $symbol . ' ' . $string; } From 52df2edc8fc7bc3802469953227c9db878a3795d Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 18:48:17 +0200 Subject: [PATCH 48/60] Fixed the last issues. Now onto code complexity. --- app/Repositories/Account/AccountRepository.php | 8 ++++++-- app/Repositories/Journal/JournalRepository.php | 10 ++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 2631f655e5..447bb4adbf 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -389,7 +389,9 @@ class AccountRepository implements AccountRepositoryInterface public function store(array $data) { $newAccount = $this->storeAccount($data); - $this->storeMetadata($newAccount, $data); + if (!is_null($newAccount)) { + $this->storeMetadata($newAccount, $data); + } // continue with the opposing account: @@ -457,7 +459,9 @@ class AccountRepository implements AccountRepositoryInterface 'virtualBalance' => 0, ]; $opposing = $this->storeAccount($opposingData); - $this->storeInitialBalance($account, $opposing, $data); + if (!is_null($opposing)) { + $this->storeInitialBalance($account, $opposing, $data); + } } } else { diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 11cce176e9..4bf1e742c4 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -143,7 +143,9 @@ class JournalRepository implements JournalRepositoryInterface foreach ($array as $name) { if (strlen(trim($name)) > 0) { $tag = Tag::firstOrCreateEncrypted(['tag' => $name, 'user_id' => $journal->user_id]); - $tagRepository->connect($journal, $tag); + if (!is_null($tag)) { + $tagRepository->connect($journal, $tag); + } } } } @@ -186,19 +188,19 @@ class JournalRepository implements JournalRepositoryInterface } // store accounts (depends on type) - list($from, $to) = $this->storeAccounts($transactionType, $data); + list($fromAccount, $toAccount) = $this->storeAccounts($transactionType, $data); // store accompanying transactions. Transaction::create( // first transaction. [ - 'account_id' => $from->id, + 'account_id' => $fromAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $data['amount'] * -1 ] ); Transaction::create( // second transaction. [ - 'account_id' => $to->id, + 'account_id' => $toAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $data['amount'] ] From af13d1943fcfe0b74eb6c22d0f426c0504e5e728 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 18:57:15 +0200 Subject: [PATCH 49/60] Should fix the last issues. --- app/Repositories/Account/AccountRepository.php | 2 +- app/Repositories/Journal/JournalRepository.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 447bb4adbf..9bf61a3099 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -406,7 +406,7 @@ class AccountRepository implements AccountRepositoryInterface 'iban' => '', ]; $opposing = $this->storeAccount($opposingData); - if (!is_null($opposing)) { + if (!is_null($opposing) && !is_null($newAccount)) { $this->storeInitialBalance($newAccount, $opposing, $data); } diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 4bf1e742c4..ae1882b4f9 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -248,7 +248,7 @@ class JournalRepository implements JournalRepositoryInterface } // store accounts (depends on type) - list($from, $to) = $this->storeAccounts($journal->transactionType, $data); + list($fromAccount, $toAccount) = $this->storeAccounts($journal->transactionType, $data); // update the from and to transaction. /** @var Transaction $transaction */ @@ -256,12 +256,12 @@ class JournalRepository implements JournalRepositoryInterface if (floatval($transaction->amount) < 0) { // this is the from transaction, negative amount: $transaction->amount = $data['amount'] * -1; - $transaction->account_id = $from->id; + $transaction->account_id = $fromAccount->id; $transaction->save(); } if (floatval($transaction->amount) > 0) { $transaction->amount = $data['amount']; - $transaction->account_id = $to->id; + $transaction->account_id = $toAccount->id; $transaction->save(); } } From c555e28988009fa7201096fbf16ccbae67c3cf47 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 20:21:55 +0200 Subject: [PATCH 50/60] Add new bank specific fixes. --- app/Helpers/Csv/Data.php | 28 ++ app/Helpers/Csv/Importer.php | 21 +- app/Helpers/Csv/Specifix/Dummy.php | 45 ++ app/Http/Controllers/CsvController.php | 11 +- app/Support/ExpandedForm.php | 21 + config/csv.php | 3 +- config/twigbridge.php | 2 +- resources/lang/en/firefly.php | 651 +++++++++++++------------ resources/lang/en/form.php | 3 +- resources/lang/nl/firefly.php | 2 + resources/lang/nl/form.php | 1 + resources/twig/csv/index.twig | 2 +- resources/twig/form/multiCheckbox.twig | 17 + 13 files changed, 471 insertions(+), 336 deletions(-) create mode 100644 app/Helpers/Csv/Specifix/Dummy.php create mode 100644 resources/twig/form/multiCheckbox.twig diff --git a/app/Helpers/Csv/Data.php b/app/Helpers/Csv/Data.php index 149cbda6e5..3230a346e6 100644 --- a/app/Helpers/Csv/Data.php +++ b/app/Helpers/Csv/Data.php @@ -33,6 +33,9 @@ class Data /** @var array */ protected $roles; + /** @var array */ + protected $specifix; + /** * */ @@ -44,6 +47,7 @@ class Data $this->sessionMap(); $this->sessionRoles(); $this->sessionMapped(); + $this->sessionSpecifix(); } protected function sessionHasHeaders() @@ -88,6 +92,13 @@ class Data } } + protected function sessionSpecifix() + { + if (Session::has('csv-specifix')) { + $this->specifix = (array)Session::get('csv-specifix'); + } + } + /** * @return string */ @@ -231,5 +242,22 @@ class Data $this->roles = $roles; } + /** + * @return array + */ + public function getSpecifix() + { + return $this->specifix; + } + + /** + * @param array $specifix + */ + public function setSpecifix($specifix) + { + Session::put('csv-specifix', $specifix); + $this->specifix = $specifix; + } + } \ No newline at end of file diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index fa23c6f327..9f14ee9836 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -37,6 +37,8 @@ class Importer protected $roles; /** @var int */ protected $rows = 0; + /** @var array */ + protected $specifix; /** * @return array @@ -69,9 +71,10 @@ class Importer { set_time_limit(0); - $this->map = $this->data->getMap(); - $this->roles = $this->data->getRoles(); - $this->mapped = $this->data->getMapped(); + $this->map = $this->data->getMap(); + $this->roles = $this->data->getRoles(); + $this->mapped = $this->data->getMapped(); + $this->specifix = $this->data->getSpecifix(); foreach ($this->data->getReader() as $index => $row) { if ($this->parseRow($index)) { @@ -174,8 +177,7 @@ class Importer { // do bank specific fixes (must be enabled but now all of them. - $set = Config::get('csv.specifix'); - foreach ($set as $className) { + foreach ($this->getSpecifix() as $className) { /** @var SpecifixInterface $specifix */ $specifix = App::make('FireflyIII\Helpers\Csv\Specifix\\' . $className); $specifix->setData($data); @@ -195,6 +197,14 @@ class Importer return $data; } + /** + * @return array + */ + public function getSpecifix() + { + return $this->specifix; + } + /** * @param $data * @@ -304,4 +314,5 @@ class Importer { $this->data = $data; } + } \ No newline at end of file diff --git a/app/Helpers/Csv/Specifix/Dummy.php b/app/Helpers/Csv/Specifix/Dummy.php new file mode 100644 index 0000000000..ee915b20dd --- /dev/null +++ b/app/Helpers/Csv/Specifix/Dummy.php @@ -0,0 +1,45 @@ +data; + + } + + /** + * @param array $data + */ + public function setData($data) + { + $this->data = $data; + } + + /** + * @param array $row + */ + public function setRow($row) + { + $this->row = $row; + } + + +} \ No newline at end of file diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 942bb899fd..c4f580169e 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -155,14 +155,17 @@ class CsvController extends Controller Session::forget('csv-mapped'); Session::forget('csv-specifix'); - // get values which are yet unsaveable or unmappable: - $unsupported = []; + // get list of supported specifix + $specifix = []; + foreach (Config::get('csv.specifix') as $entry) { + $specifix[$entry] = trans('firefly.csv_specifix_' . $entry); + } // can actually upload? $uploadPossible = is_writable(storage_path('upload')); $path = storage_path('upload'); - return view('csv.index', compact('subTitle', 'uploadPossible', 'path', 'unsupported')); + return view('csv.index', compact('subTitle', 'uploadPossible', 'path', 'specifix')); } /** @@ -378,6 +381,7 @@ class CsvController extends Controller $settings = []; $settings['date-format'] = Input::get('date_format'); $settings['has-headers'] = intval(Input::get('has_headers')) === 1; + $settings['specifix'] = Input::get('specifix'); $settings['map'] = []; $settings['mapped'] = []; $settings['roles'] = []; @@ -399,6 +403,7 @@ class CsvController extends Controller $this->data->setMap($settings['map']); $this->data->setMapped($settings['mapped']); $this->data->setRoles($settings['roles']); + $this->data->setSpecifix($settings['specifix']); return redirect(route('csv.column-roles')); diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index 37baf3dab0..ab4e0cfccb 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -262,6 +262,27 @@ class ExpandedForm return $selectList; } + /** + * @param $name + * @param array $list + * @param null $selected + * @param array $options + * + * @return string + */ + public function multiCheckbox($name, array $list = [], $selected = null, array $options = []) + { + $label = $this->label($name, $options); + $options = $this->expandOptionArray($name, $label, $options); + $classes = $this->getHolderClasses($name); + $selected = $this->fillFieldValue($name, $selected); + + unset($options['class']); + $html = View::make('form.multiCheckbox', compact('classes', 'name', 'label', 'selected', 'options', 'list'))->render(); + + return $html; + } + /** * @param $name * @param array $list diff --git a/config/csv.php b/config/csv.php index 9b5914f796..e9d57e473a 100644 --- a/config/csv.php +++ b/config/csv.php @@ -1,7 +1,8 @@ [ - 'RabobankDescription' + 'RabobankDescription', + 'Dummy' ], 'post_processors' => [ 'Description', diff --git a/config/twigbridge.php b/config/twigbridge.php index 8d5621c253..dd60091875 100644 --- a/config/twigbridge.php +++ b/config/twigbridge.php @@ -145,7 +145,7 @@ return [ 'ExpandedForm' => [ 'is_safe' => [ 'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location', - 'multiRadio','file' + 'multiRadio','file','multiCheckbox' ] ], 'Form' => [ diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php index 1fc0365f4f..f5cb77de1e 100644 --- a/resources/lang/en/firefly.php +++ b/resources/lang/en/firefly.php @@ -2,378 +2,381 @@ return [ // general stuff: - 'test' => 'You have selected English.', - 'close' => 'Close', - 'pleaseHold' => 'Please hold...', - 'actions' => 'Actions', - 'edit' => 'Edit', - 'delete' => 'Delete', - 'welcomeBack' => 'What\'s playing?', - 'everything' => 'Everything', - 'customRange' => 'Custom range', - 'apply' => 'Apply', - 'cancel' => 'Cancel', - 'from' => 'From', - 'to' => 'To', - 'showEverything' => 'Show everything', - 'never' => 'Never', - 'search_results_for' => 'Search results for ":query"', + 'test' => 'You have selected English.', + 'close' => 'Close', + 'pleaseHold' => 'Please hold...', + 'actions' => 'Actions', + 'edit' => 'Edit', + 'delete' => 'Delete', + 'welcomeBack' => 'What\'s playing?', + 'everything' => 'Everything', + 'customRange' => 'Custom range', + 'apply' => 'Apply', + 'cancel' => 'Cancel', + 'from' => 'From', + 'to' => 'To', + 'showEverything' => 'Show everything', + 'never' => 'Never', + 'search_results_for' => 'Search results for ":query"', // csv import: - 'csv_import' => 'Import CSV file', - 'csv' => 'CSV', - 'csv_index_title' => 'Upload and import a CSV file', - 'csv_define_column_roles' => 'Define column roles', - 'csv_map_values' => 'Map found values to existing values', - 'csv_download_config' => 'Download CSV configuration file.', - 'csv_index_text' => + 'csv_import' => 'Import CSV file', + 'csv' => 'CSV', + 'csv_index_title' => 'Upload and import a CSV file', + 'csv_define_column_roles' => 'Define column roles', + 'csv_map_values' => 'Map found values to existing values', + 'csv_download_config' => 'Download CSV configuration file.', + 'csv_index_text' => 'This form allows you to import a CSV file with transactions into Firefly. It is based on the excellent CSV importer made by' . ' the folks at Atlassian. Simply upload your CSV file and follow the instructions.' . ' If you would like to learn more, please click on the button at the top of this page.', - 'csv_index_beta_warning' => 'This tool is very much in beta. Please proceed with caution', - 'csv_header_help' => 'Check this box when your CSV file\'s first row consists of column names, not actual data', - 'csv_date_help' => 'Date time format in your CSV. Follow the format like this' . - ' page indicates. The default value will parse dates that look like this: ' . date('Ymd'), - 'csv_csv_file_help' => 'Select the CSV file here. You can only upload one file at a time', - 'csv_csv_config_file_help' => 'Select your CSV import configuration here. If you do not know what this is, ignore it. It will be explained later.', - 'csv_upload_button' => 'Start importing CSV', - 'csv_column_roles_title' => 'Define column roles', - 'csv_column_roles_text' => 'Firefly does not know what each column means. You need to indicate what every column is. Please check out the example ' - . 'data if you\'re not sure yourself. Click on the question mark (top right of the page) to learn what' - . ' each column means. If you want to map imported data onto existing data in Firefly, use the checkbox. ' - . 'The next step will show you what this button does.', - 'csv_column_roles_table' => 'Column roles', - 'csv_column' => 'CSV column', - 'cvs_column_name' => 'CSV column name', - 'cvs_column_example' => 'Column example data', - 'cvs_column_role' => 'Column contains?', - 'csv_do_map_value' => 'Map value?', - 'csv_continue' => 'Continue to the next step', - 'csv_go_back' => 'Go back to the previous step', - 'csv_map_title' => 'Map found values to existing values', - 'csv_map_text' => + 'csv_index_beta_warning' => 'This tool is very much in beta. Please proceed with caution', + 'csv_header_help' => 'Check this box when your CSV file\'s first row consists of column names, not actual data', + 'csv_date_help' => 'Date time format in your CSV. Follow the format like this' . + ' page indicates. The default value will parse dates that look like this: ' . date('Ymd'), + 'csv_csv_file_help' => 'Select the CSV file here. You can only upload one file at a time', + 'csv_csv_config_file_help' => 'Select your CSV import configuration here. If you do not know what this is, ignore it. It will be explained later.', + 'csv_upload_button' => 'Start importing CSV', + 'csv_column_roles_title' => 'Define column roles', + 'csv_column_roles_text' => + 'Firefly does not know what each column means. You need to indicate what every column is. Please check out the example ' + . 'data if you\'re not sure yourself. Click on the question mark (top right of the page) to learn what' + . ' each column means. If you want to map imported data onto existing data in Firefly, use the checkbox. ' + . 'The next step will show you what this button does.', + 'csv_column_roles_table' => 'Column roles', + 'csv_column' => 'CSV column', + 'cvs_column_name' => 'CSV column name', + 'cvs_column_example' => 'Column example data', + 'cvs_column_role' => 'Column contains?', + 'csv_do_map_value' => 'Map value?', + 'csv_continue' => 'Continue to the next step', + 'csv_go_back' => 'Go back to the previous step', + 'csv_map_title' => 'Map found values to existing values', + 'csv_map_text' => 'This page allows you to map the values from the CSV file to existing entries in your database. This ensures that accounts and other' . ' things won\'t be created twice.', - 'cvs_field_value' => 'Field value from CSV', - 'csv_field_mapped_to' => 'Must be mapped to...', - 'csv_download_config_title' => 'Download CSV configuration', - 'csv_download_config_text' => 'Everything you\'ve just set up can be downloaded as a configuration file. Click the button to do so.', - 'csv_more_information_text' => 'If the import fails, you can use this configuration file so you don\'t have to start all over again.' - . ' But, if the import succeeds, it will be easier to upload similar CSV files.', - 'csv_do_download_config' => 'Download configuration file.', - 'csv_empty_description' => '(empty description)', - 'csv_upload_form' => 'CSV upload form', - 'csv_index_unsupported_warning' => 'The CSV importer is yet incapable of doing the following:', - 'csv_unsupported_map' => 'The importer cannot map the column ":columnRole" to existing values in the database.', - 'csv_unsupported_value' => 'The importer does not know how to handle values in columns marked as ":columnRole".', - 'csv_cannot_store_value' => 'The importer has not reserved space for columns marked ":columnRole" and will be incapable of processing them.', - 'csv_process_title' => 'CVS import finished!', - 'csv_process_text' => 'The CVS importer has finished and has processed :rows rows', - 'csv_row' => 'Row', - 'csv_import_with_errors' => 'There was one error.|There were :errors errors.', - 'csv_error_see_logs' => 'Check the log files to see details.', - 'csv_process_new_entries' => 'Firefly has created :imported new transaction(s).', - 'csv_start_over' => 'Import again', - 'csv_to_index' => 'Back home', - 'csv_do_not_map' => 'Do not map this value', - 'csv_upload_not_writeable' => 'Cannot write to the path mentioned here. Cannot upload', + 'cvs_field_value' => 'Field value from CSV', + 'csv_field_mapped_to' => 'Must be mapped to...', + 'csv_download_config_title' => 'Download CSV configuration', + 'csv_download_config_text' => 'Everything you\'ve just set up can be downloaded as a configuration file. Click the button to do so.', + 'csv_more_information_text' => 'If the import fails, you can use this configuration file so you don\'t have to start all over again.' + . ' But, if the import succeeds, it will be easier to upload similar CSV files.', + 'csv_do_download_config' => 'Download configuration file.', + 'csv_empty_description' => '(empty description)', + 'csv_upload_form' => 'CSV upload form', + 'csv_index_unsupported_warning' => 'The CSV importer is yet incapable of doing the following:', + 'csv_unsupported_map' => 'The importer cannot map the column ":columnRole" to existing values in the database.', + 'csv_unsupported_value' => 'The importer does not know how to handle values in columns marked as ":columnRole".', + 'csv_cannot_store_value' => 'The importer has not reserved space for columns marked ":columnRole" and will be incapable of processing them.', + 'csv_process_title' => 'CVS import finished!', + 'csv_process_text' => 'The CVS importer has finished and has processed :rows rows', + 'csv_row' => 'Row', + 'csv_import_with_errors' => 'There was one error.|There were :errors errors.', + 'csv_error_see_logs' => 'Check the log files to see details.', + 'csv_process_new_entries' => 'Firefly has created :imported new transaction(s).', + 'csv_start_over' => 'Import again', + 'csv_to_index' => 'Back home', + 'csv_do_not_map' => 'Do not map this value', + 'csv_upload_not_writeable' => 'Cannot write to the path mentioned here. Cannot upload', - 'csv_column__ignore' => '(ignore this column)', - 'csv_column_account-iban' => 'Asset account (IBAN)', - 'csv_column_account-id' => 'Asset account ID (matching Firefly)', - 'csv_column_account-name' => 'Asset account (name)', - 'csv_column_amount' => 'Amount', - 'csv_column_bill-id' => 'Bill ID (matching Firefly)', - 'csv_column_bill-name' => 'Bill name', - 'csv_column_budget-id' => 'Budget ID (matching Firefly)', - 'csv_column_budget-name' => 'Budget name', - 'csv_column_category-id' => 'Category ID (matching Firefly)', - 'csv_column_category-name' => 'Category name', - 'csv_column_currency-code' => 'Currency code (ISO 4217)', - 'csv_column_currency-id' => 'Currency ID (matching Firefly)', - 'csv_column_currency-name' => 'Currency name (matching Firefly)', - 'csv_column_currency-symbol' => 'Currency symbol (matching Firefly)', - 'csv_column_date-rent' => 'Rent calculation date', - 'csv_column_date-transaction' => 'Date', - 'csv_column_description' => 'Description', - 'csv_column_opposing-iban' => 'Opposing account (IBAN)', - 'csv_column_opposing-id' => 'Opposing account ID (matching Firefly)', - 'csv_column_opposing-name' => 'Opposing account (name)', - 'csv_column_rabo-debet-credit' => 'Rabobank specific debet/credit indicator', - 'csv_column_sepa-ct-id' => 'SEPA Credit Transfer end-to-end ID', - 'csv_column_sepa-ct-op' => 'SEPA Credit Transfer opposing account', - 'csv_column_sepa-db' => 'SEPA Direct Debet', - 'csv_column_tags-comma' => 'Tags (comma separated)', - 'csv_column_tags-space' => 'Tags (space separated)', + 'csv_column__ignore' => '(ignore this column)', + 'csv_column_account-iban' => 'Asset account (IBAN)', + 'csv_column_account-id' => 'Asset account ID (matching Firefly)', + 'csv_column_account-name' => 'Asset account (name)', + 'csv_column_amount' => 'Amount', + 'csv_column_bill-id' => 'Bill ID (matching Firefly)', + 'csv_column_bill-name' => 'Bill name', + 'csv_column_budget-id' => 'Budget ID (matching Firefly)', + 'csv_column_budget-name' => 'Budget name', + 'csv_column_category-id' => 'Category ID (matching Firefly)', + 'csv_column_category-name' => 'Category name', + 'csv_column_currency-code' => 'Currency code (ISO 4217)', + 'csv_column_currency-id' => 'Currency ID (matching Firefly)', + 'csv_column_currency-name' => 'Currency name (matching Firefly)', + 'csv_column_currency-symbol' => 'Currency symbol (matching Firefly)', + 'csv_column_date-rent' => 'Rent calculation date', + 'csv_column_date-transaction' => 'Date', + 'csv_column_description' => 'Description', + 'csv_column_opposing-iban' => 'Opposing account (IBAN)', + 'csv_column_opposing-id' => 'Opposing account ID (matching Firefly)', + 'csv_column_opposing-name' => 'Opposing account (name)', + 'csv_column_rabo-debet-credit' => 'Rabobank specific debet/credit indicator', + 'csv_column_sepa-ct-id' => 'SEPA Credit Transfer end-to-end ID', + 'csv_column_sepa-ct-op' => 'SEPA Credit Transfer opposing account', + 'csv_column_sepa-db' => 'SEPA Direct Debet', + 'csv_column_tags-comma' => 'Tags (comma separated)', + 'csv_column_tags-space' => 'Tags (space separated)', + 'csv_specifix_RabobankDescription' => 'Select this when you\'re importing Rabobank CSV export files.', + 'csv_specifix_Dummy' => 'Checking this has no effect whatsoever.', // create new stuff: - 'create_new_withdrawal' => 'Create new withdrawal', - 'create_new_deposit' => 'Create new deposit', - 'create_new_transfer' => 'Create new transfer', - 'create_new_asset' => 'Create new asset account', - 'create_new_expense' => 'Create new expense account', - 'create_new_revenue' => 'Create new revenue account', - 'create_new_piggy_bank' => 'Create new piggy bank', - 'create_new_bill' => 'Create new bill', + 'create_new_withdrawal' => 'Create new withdrawal', + 'create_new_deposit' => 'Create new deposit', + 'create_new_transfer' => 'Create new transfer', + 'create_new_asset' => 'Create new asset account', + 'create_new_expense' => 'Create new expense account', + 'create_new_revenue' => 'Create new revenue account', + 'create_new_piggy_bank' => 'Create new piggy bank', + 'create_new_bill' => 'Create new bill', // currencies: - 'create_currency' => 'Create a new currency', - 'edit_currency' => 'Edit currency ":name"', + 'create_currency' => 'Create a new currency', + 'edit_currency' => 'Edit currency ":name"', // new user: - 'submit' => 'Submit', - 'getting_started' => 'Getting started', - 'to_get_started' => 'To get started with Firefly, please enter your current bank\'s name, and the balance of your checking account:', - 'savings_balance_text' => 'If you have a savings account, please enter the current balance of your savings account:', - 'cc_balance_text' => 'If you have a credit card, please enter your credit card\'s limit.', + 'submit' => 'Submit', + 'getting_started' => 'Getting started', + 'to_get_started' => 'To get started with Firefly, please enter your current bank\'s name, and the balance of your checking account:', + 'savings_balance_text' => 'If you have a savings account, please enter the current balance of your savings account:', + 'cc_balance_text' => 'If you have a credit card, please enter your credit card\'s limit.', // forms: - 'mandatoryFields' => 'Mandatory fields', - 'optionalFields' => 'Optional fields', - 'options' => 'Options', - 'something' => 'Something!', + 'mandatoryFields' => 'Mandatory fields', + 'optionalFields' => 'Optional fields', + 'options' => 'Options', + 'something' => 'Something!', // budgets: - 'create_new_budget' => 'Create a new budget', - 'store_new_budget' => ' Store new budget', - 'availableIn' => 'Available in :date', - 'transactionsWithoutBudget' => 'Expenses without budget', - 'transactionsWithoutBudgetDate' => 'Expenses without budget in :date', - 'createBudget' => 'New budget', - 'inactiveBudgets' => 'Inactive budgets', - 'without_budget_between' => 'Transactions without a budget between :start and :end', - 'budget_in_month' => ':name in :month', - 'delete_budget' => 'Delete budget ":name"', - 'edit_budget' => 'Edit budget ":name"', - 'update_amount' => 'Update amount', + 'create_new_budget' => 'Create a new budget', + 'store_new_budget' => ' Store new budget', + 'availableIn' => 'Available in :date', + 'transactionsWithoutBudget' => 'Expenses without budget', + 'transactionsWithoutBudgetDate' => 'Expenses without budget in :date', + 'createBudget' => 'New budget', + 'inactiveBudgets' => 'Inactive budgets', + 'without_budget_between' => 'Transactions without a budget between :start and :end', + 'budget_in_month' => ':name in :month', + 'delete_budget' => 'Delete budget ":name"', + 'edit_budget' => 'Edit budget ":name"', + 'update_amount' => 'Update amount', // bills: - 'delete_bill' => 'Delete bill ":name"', - 'edit_bill' => 'Edit bill ":name"', + 'delete_bill' => 'Delete bill ":name"', + 'edit_bill' => 'Edit bill ":name"', // accounts: - 'details_for_asset' => 'Details for asset account ":name"', - 'details_for_expense' => 'Details for expense account ":name"', - 'details_for_revenue' => 'Details for revenue account ":name"', - 'details_for_cash' => 'Details for cash account ":name"', + 'details_for_asset' => 'Details for asset account ":name"', + 'details_for_expense' => 'Details for expense account ":name"', + 'details_for_revenue' => 'Details for revenue account ":name"', + 'details_for_cash' => 'Details for cash account ":name"', - 'store_new_asset_account' => 'Store new asset account', - 'store_new_expense_account' => 'Store new expense account', - 'store_new_revenue_account' => 'Store new revenue account', + 'store_new_asset_account' => 'Store new asset account', + 'store_new_expense_account' => 'Store new expense account', + 'store_new_revenue_account' => 'Store new revenue account', - 'edit_asset_account' => 'Edit asset account ":name"', - 'edit_expense_account' => 'Edit expense account ":name"', - 'edit_revenue_account' => 'Edit revenue account ":name"', + 'edit_asset_account' => 'Edit asset account ":name"', + 'edit_expense_account' => 'Edit expense account ":name"', + 'edit_revenue_account' => 'Edit revenue account ":name"', - 'delete_asset_account' => 'Delete asset account ":name"', - 'delete_expense_account' => 'Delete expense account ":name"', - 'delete_revenue_account' => 'Delete revenue account ":name"', + 'delete_asset_account' => 'Delete asset account ":name"', + 'delete_expense_account' => 'Delete expense account ":name"', + 'delete_revenue_account' => 'Delete revenue account ":name"', - 'asset_deleted' => 'Successfully deleted asset account ":name"', - 'expense_deleted' => 'Successfully deleted expense account ":name"', - 'revenue_deleted' => 'Successfully deleted revenue account ":name"', + 'asset_deleted' => 'Successfully deleted asset account ":name"', + 'expense_deleted' => 'Successfully deleted expense account ":name"', + 'revenue_deleted' => 'Successfully deleted revenue account ":name"', - 'update_asset_account' => 'Update asset account', - 'update_expense_account' => 'Update expense account', - 'update_revenue_account' => 'Update revenue account', + 'update_asset_account' => 'Update asset account', + 'update_expense_account' => 'Update expense account', + 'update_revenue_account' => 'Update revenue account', - 'make_new_asset_account' => 'Create a new asset account', - 'make_new_expense_account' => 'Create a new expense account', - 'make_new_revenue_account' => 'Create a new revenue account', + 'make_new_asset_account' => 'Create a new asset account', + 'make_new_expense_account' => 'Create a new expense account', + 'make_new_revenue_account' => 'Create a new revenue account', - 'asset_accounts' => 'Asset accounts', - 'expense_accounts' => 'Expense accounts', - 'revenue_accounts' => 'Revenue accounts', + 'asset_accounts' => 'Asset accounts', + 'expense_accounts' => 'Expense accounts', + 'revenue_accounts' => 'Revenue accounts', - 'accountExtraHelp_asset' => '', - 'accountExtraHelp_expense' => '', - 'accountExtraHelp_revenue' => '', - 'account_type' => 'Account type', + 'accountExtraHelp_asset' => '', + 'accountExtraHelp_expense' => '', + 'accountExtraHelp_revenue' => '', + 'account_type' => 'Account type', // categories: - 'new_category' => 'New category', - 'create_new_category' => 'Create a new category', - 'without_category' => 'Without a category', - 'update_category' => 'Wijzig categorie', - 'categories' => 'Categories', - 'edit_category' => 'Edit category ":name"', - 'no_category' => '(no category)', - 'category' => 'Category', - 'delete_category' => 'Delete category ":name"', + 'new_category' => 'New category', + 'create_new_category' => 'Create a new category', + 'without_category' => 'Without a category', + 'update_category' => 'Wijzig categorie', + 'categories' => 'Categories', + 'edit_category' => 'Edit category ":name"', + 'no_category' => '(no category)', + 'category' => 'Category', + 'delete_category' => 'Delete category ":name"', // transactions: - 'update_withdrawal' => 'Update withdrawal', - 'update_deposit' => 'Update deposit', - 'update_transfer' => 'Update transfer', - 'delete_withdrawal' => 'Delete withdrawal ":description"', - 'delete_deposit' => 'Delete deposit ":description"', - 'delete_transfer' => 'Delete transfer ":description"', + 'update_withdrawal' => 'Update withdrawal', + 'update_deposit' => 'Update deposit', + 'update_transfer' => 'Update transfer', + 'delete_withdrawal' => 'Delete withdrawal ":description"', + 'delete_deposit' => 'Delete deposit ":description"', + 'delete_transfer' => 'Delete transfer ":description"', // new user: - 'welcome' => 'Welcome to Firefly!', - 'createNewAsset' => 'Create a new asset account to get started. ' . - 'This will allow you to create transactions and start your financial management', - 'createNewAssetButton' => 'Create new asset account', + 'welcome' => 'Welcome to Firefly!', + 'createNewAsset' => 'Create a new asset account to get started. ' . + 'This will allow you to create transactions and start your financial management', + 'createNewAssetButton' => 'Create new asset account', // home page: - 'yourAccounts' => 'Your accounts', - 'budgetsAndSpending' => 'Budgets and spending', - 'savings' => 'Savings', - 'markAsSavingsToContinue' => 'Mark your asset accounts as "Savings account" to fill this panel', - 'createPiggyToContinue' => 'Create piggy banks to fill this panel.', - 'newWithdrawal' => 'New expense', - 'newDeposit' => 'New deposit', - 'newTransfer' => 'New transfer', - 'moneyIn' => 'Money in', - 'moneyOut' => 'Money out', - 'billsToPay' => 'Bills to pay', - 'billsPaid' => 'Bills paid', - 'viewDetails' => 'View details', - 'divided' => 'divided', - 'toDivide' => 'left to divide', + 'yourAccounts' => 'Your accounts', + 'budgetsAndSpending' => 'Budgets and spending', + 'savings' => 'Savings', + 'markAsSavingsToContinue' => 'Mark your asset accounts as "Savings account" to fill this panel', + 'createPiggyToContinue' => 'Create piggy banks to fill this panel.', + 'newWithdrawal' => 'New expense', + 'newDeposit' => 'New deposit', + 'newTransfer' => 'New transfer', + 'moneyIn' => 'Money in', + 'moneyOut' => 'Money out', + 'billsToPay' => 'Bills to pay', + 'billsPaid' => 'Bills paid', + 'viewDetails' => 'View details', + 'divided' => 'divided', + 'toDivide' => 'left to divide', // menu and titles, should be recycled as often as possible: - 'toggleNavigation' => 'Toggle navigation', - 'currency' => 'Currency', - 'preferences' => 'Preferences', - 'logout' => 'Logout', - 'searchPlaceholder' => 'Search...', - 'dashboard' => 'Dashboard', - 'currencies' => 'Currencies', - 'accounts' => 'Accounts', - 'Asset account' => 'Asset account', - 'Default account' => 'Asset account', - 'Expense account' => 'Expense account', - 'Revenue account' => 'Revenue account', - 'budgets' => 'Budgets', - 'tags' => 'Tags', - 'reports' => 'Reports', - 'transactions' => 'Transactions', - 'expenses' => 'Expenses', - 'income' => 'Revenue / income', - 'transfers' => 'Transfers', - 'moneyManagement' => 'Money management', - 'piggyBanks' => 'Piggy banks', - 'bills' => 'Bills', - 'createNew' => 'Create new', - 'withdrawal' => 'Withdrawal', - 'deposit' => 'Deposit', - 'account' => 'Account', - 'transfer' => 'Transfer', - 'Withdrawal' => 'Withdrawal', - 'Deposit' => 'Deposit', - 'Transfer' => 'Transfer', - 'bill' => 'Bill', - 'yes' => 'Yes', - 'no' => 'No', - 'amount' => 'Amount', - 'newBalance' => 'New balance', - 'overview' => 'Overview', - 'saveOnAccount' => 'Save on account', - 'unknown' => 'Unknown', - 'daily' => 'Daily', - 'weekly' => 'Weekly', - 'monthly' => 'Monthly', - 'quarterly' => 'Quarterly', - 'half-year' => 'Every six months', - 'yearly' => 'Yearly', + 'toggleNavigation' => 'Toggle navigation', + 'currency' => 'Currency', + 'preferences' => 'Preferences', + 'logout' => 'Logout', + 'searchPlaceholder' => 'Search...', + 'dashboard' => 'Dashboard', + 'currencies' => 'Currencies', + 'accounts' => 'Accounts', + 'Asset account' => 'Asset account', + 'Default account' => 'Asset account', + 'Expense account' => 'Expense account', + 'Revenue account' => 'Revenue account', + 'budgets' => 'Budgets', + 'tags' => 'Tags', + 'reports' => 'Reports', + 'transactions' => 'Transactions', + 'expenses' => 'Expenses', + 'income' => 'Revenue / income', + 'transfers' => 'Transfers', + 'moneyManagement' => 'Money management', + 'piggyBanks' => 'Piggy banks', + 'bills' => 'Bills', + 'createNew' => 'Create new', + 'withdrawal' => 'Withdrawal', + 'deposit' => 'Deposit', + 'account' => 'Account', + 'transfer' => 'Transfer', + 'Withdrawal' => 'Withdrawal', + 'Deposit' => 'Deposit', + 'Transfer' => 'Transfer', + 'bill' => 'Bill', + 'yes' => 'Yes', + 'no' => 'No', + 'amount' => 'Amount', + 'newBalance' => 'New balance', + 'overview' => 'Overview', + 'saveOnAccount' => 'Save on account', + 'unknown' => 'Unknown', + 'daily' => 'Daily', + 'weekly' => 'Weekly', + 'monthly' => 'Monthly', + 'quarterly' => 'Quarterly', + 'half-year' => 'Every six months', + 'yearly' => 'Yearly', // reports: - 'reportForYear' => 'Yearly report for :year', - 'reportForYearShared' => 'Yearly report for :year (including shared accounts)', - 'reportForMonth' => 'Montly report for :month', - 'reportForMonthShared' => 'Montly report for :month (including shared accounts)', - 'incomeVsExpenses' => 'Income vs. expenses', - 'accountBalances' => 'Account balances', - 'balanceStartOfYear' => 'Balance at start of year', - 'balanceEndOfYear' => 'Balance at end of year', - 'balanceStartOfMonth' => 'Balance at start of month', - 'balanceEndOfMonth' => 'Balance at end of month', - 'balanceStart' => 'Balance at start of period', - 'balanceEnd' => 'Balance at end of period', - 'reportsOwnAccounts' => 'Reports for your own accounts', - 'reportsOwnAccountsAndShared' => 'Reports for your own accounts and shared accounts', - 'splitByAccount' => 'Split by account', - 'balancedByTransfersAndTags' => 'Balanced by transfers and tags', - 'coveredWithTags' => 'Covered with tags', - 'leftUnbalanced' => 'Left unbalanced', - 'expectedBalance' => 'Expected balance', - 'outsideOfBudgets' => 'Outside of budgets', - 'leftInBudget' => 'Left in budget', - 'sumOfSums' => 'Sum of sums', - 'notCharged' => 'Not charged (yet)', - 'inactive' => 'Inactive', - 'difference' => 'Difference', - 'in' => 'In', - 'out' => 'Out', - 'topX' => 'top :number', - 'showTheRest' => 'Show everything', - 'hideTheRest' => 'Show only the top :number', + 'reportForYear' => 'Yearly report for :year', + 'reportForYearShared' => 'Yearly report for :year (including shared accounts)', + 'reportForMonth' => 'Montly report for :month', + 'reportForMonthShared' => 'Montly report for :month (including shared accounts)', + 'incomeVsExpenses' => 'Income vs. expenses', + 'accountBalances' => 'Account balances', + 'balanceStartOfYear' => 'Balance at start of year', + 'balanceEndOfYear' => 'Balance at end of year', + 'balanceStartOfMonth' => 'Balance at start of month', + 'balanceEndOfMonth' => 'Balance at end of month', + 'balanceStart' => 'Balance at start of period', + 'balanceEnd' => 'Balance at end of period', + 'reportsOwnAccounts' => 'Reports for your own accounts', + 'reportsOwnAccountsAndShared' => 'Reports for your own accounts and shared accounts', + 'splitByAccount' => 'Split by account', + 'balancedByTransfersAndTags' => 'Balanced by transfers and tags', + 'coveredWithTags' => 'Covered with tags', + 'leftUnbalanced' => 'Left unbalanced', + 'expectedBalance' => 'Expected balance', + 'outsideOfBudgets' => 'Outside of budgets', + 'leftInBudget' => 'Left in budget', + 'sumOfSums' => 'Sum of sums', + 'notCharged' => 'Not charged (yet)', + 'inactive' => 'Inactive', + 'difference' => 'Difference', + 'in' => 'In', + 'out' => 'Out', + 'topX' => 'top :number', + 'showTheRest' => 'Show everything', + 'hideTheRest' => 'Show only the top :number', // charts: - 'dayOfMonth' => 'Day of the month', - 'month' => 'Month', - 'budget' => 'Budget', - 'spent' => 'Spent', - 'overspent' => 'Overspent', - 'left' => 'Left', - 'noBudget' => '(no budget)', - 'maxAmount' => 'Maximum amount', - 'minAmount' => 'Minumum amount', - 'billEntry' => 'Current bill entry', - 'name' => 'Name', - 'date' => 'Date', - 'paid' => 'Paid', - 'unpaid' => 'Unpaid', - 'day' => 'Day', - 'budgeted' => 'Budgeted', - 'period' => 'Period', - 'balance' => 'Balance', - 'summary' => 'Summary', - 'sum' => 'Sum', - 'average' => 'Average', - 'balanceFor' => 'Balance for :name', + 'dayOfMonth' => 'Day of the month', + 'month' => 'Month', + 'budget' => 'Budget', + 'spent' => 'Spent', + 'overspent' => 'Overspent', + 'left' => 'Left', + 'noBudget' => '(no budget)', + 'maxAmount' => 'Maximum amount', + 'minAmount' => 'Minumum amount', + 'billEntry' => 'Current bill entry', + 'name' => 'Name', + 'date' => 'Date', + 'paid' => 'Paid', + 'unpaid' => 'Unpaid', + 'day' => 'Day', + 'budgeted' => 'Budgeted', + 'period' => 'Period', + 'balance' => 'Balance', + 'summary' => 'Summary', + 'sum' => 'Sum', + 'average' => 'Average', + 'balanceFor' => 'Balance for :name', // piggy banks: - 'piggy_bank' => 'Piggy bank', - 'new_piggy_bank' => 'Create new piggy bank', - 'create_new_piggybank' => 'Create new piggy bank', - 'account_status' => 'Account status', - 'left_for_piggy_banks' => 'Left for piggy banks', - 'sum_of_piggy_banks' => 'Sum of piggy banks', - 'saved_so_far' => 'Saved so far', - 'left_to_save' => 'Left to save', - 'add_money_to_piggy_title' => 'Add money to piggy bank ":name"', - 'remove_money_from_piggy_title' => 'Remove money from piggy bank ":name"', - 'add' => 'Add', - 'remove' => 'Remove', - 'max_amount_add' => 'The maximum amount you can add is', - 'max_amount_remove' => 'The maximum amount you can remove is', - 'update_piggy_button' => 'Update piggy bank', - 'update_piggy_title' => 'Update piggy bank ":name"', - 'details' => 'Details', - 'events' => 'Events', - 'target_amount' => 'Target amount', - 'start_date' => 'Start date', - 'target_date' => 'Target date', - 'no_target_date' => 'No target date', - 'todo' => 'to do', - 'table' => 'Table', - 'piggy_bank_not_exists' => 'Piggy bank no longer exists.', - 'add_any_amount_to_piggy' => 'Add money to this piggy bank to reach your target of :amount.', - 'add_set_amount_to_piggy' => 'Add :amount to fill this piggy bank on :date', - 'delete_piggy_bank' => 'Delete piggy bank ":name"', + 'piggy_bank' => 'Piggy bank', + 'new_piggy_bank' => 'Create new piggy bank', + 'create_new_piggybank' => 'Create new piggy bank', + 'account_status' => 'Account status', + 'left_for_piggy_banks' => 'Left for piggy banks', + 'sum_of_piggy_banks' => 'Sum of piggy banks', + 'saved_so_far' => 'Saved so far', + 'left_to_save' => 'Left to save', + 'add_money_to_piggy_title' => 'Add money to piggy bank ":name"', + 'remove_money_from_piggy_title' => 'Remove money from piggy bank ":name"', + 'add' => 'Add', + 'remove' => 'Remove', + 'max_amount_add' => 'The maximum amount you can add is', + 'max_amount_remove' => 'The maximum amount you can remove is', + 'update_piggy_button' => 'Update piggy bank', + 'update_piggy_title' => 'Update piggy bank ":name"', + 'details' => 'Details', + 'events' => 'Events', + 'target_amount' => 'Target amount', + 'start_date' => 'Start date', + 'target_date' => 'Target date', + 'no_target_date' => 'No target date', + 'todo' => 'to do', + 'table' => 'Table', + 'piggy_bank_not_exists' => 'Piggy bank no longer exists.', + 'add_any_amount_to_piggy' => 'Add money to this piggy bank to reach your target of :amount.', + 'add_set_amount_to_piggy' => 'Add :amount to fill this piggy bank on :date', + 'delete_piggy_bank' => 'Delete piggy bank ":name"', // tags - 'delete_tag' => 'Delete tag ":name"', - 'new_tag' => 'Make new tag', - 'edit_tag' => 'Edit tag ":tag"', - 'no_year' => 'No year set', - 'no_month' => 'No month set', - 'tag_title_nothing' => 'Default tags', - 'tag_title_balancingAct' => 'Balancing act tags', - 'tag_title_advancePayment' => 'Advance payment tags', + 'delete_tag' => 'Delete tag ":name"', + 'new_tag' => 'Make new tag', + 'edit_tag' => 'Edit tag ":tag"', + 'no_year' => 'No year set', + 'no_month' => 'No month set', + 'tag_title_nothing' => 'Default tags', + 'tag_title_balancingAct' => 'Balancing act tags', + 'tag_title_advancePayment' => 'Advance payment tags', ]; diff --git a/resources/lang/en/form.php b/resources/lang/en/form.php index 8cb9937341..9172e7520c 100644 --- a/resources/lang/en/form.php +++ b/resources/lang/en/form.php @@ -45,11 +45,12 @@ return [ 'under' => 'Under', 'symbol' => 'Symbol', 'code' => 'Code', - 'iban' => 'IBAN', + 'iban' => 'IBAN', 'csv' => 'CSV file', 'has_headers' => 'Headers', 'date_format' => 'Date format', 'csv_config' => 'CSV import configuration', + 'specifix' => 'Bank- or file specific fixes', 'store_new_withdrawal' => 'Store new withdrawal', 'store_new_deposit' => 'Store new deposit', diff --git a/resources/lang/nl/firefly.php b/resources/lang/nl/firefly.php index a64b157eac..6194dd2940 100644 --- a/resources/lang/nl/firefly.php +++ b/resources/lang/nl/firefly.php @@ -100,6 +100,8 @@ return [ 'csv_process_text' => ':rows rijen zijn verwerkt.', 'csv_import_with_errors' => 'Er was één fout. Deze foutmelding is mogelijk in het Engels.|Er zijn :errors fouten opgetreden. De foutmeldingen' . ' zijn mogelijk in het Engels.', + 'csv_specifix_RabobankDescription' => 'Vink dit aan als je Rabobank bestanden importeert.', + 'csv_specifix_Dummy' => 'Dit vinkje doet niks (dummy).', // create new stuff: 'create_new_withdrawal' => 'Nieuwe uitgave', 'create_new_deposit' => 'Nieuwe inkomsten', diff --git a/resources/lang/nl/form.php b/resources/lang/nl/form.php index f209eb9f96..6e62b37901 100644 --- a/resources/lang/nl/form.php +++ b/resources/lang/nl/form.php @@ -50,6 +50,7 @@ return [ 'has_headers' => 'Kolomnamen op de eerste rij?', 'date_format' => 'Datumformaat', 'csv_config' => 'Configuratiebestand', + 'specifix' => 'Bank- or of bestandsspecifieke opties', 'store_new_withdrawal' => 'Nieuwe uitgave opslaan', 'store_new_deposit' => 'Nieuwe inkomsten opslaan', diff --git a/resources/twig/csv/index.twig b/resources/twig/csv/index.twig index e4a465bc9e..1de0109ae5 100644 --- a/resources/twig/csv/index.twig +++ b/resources/twig/csv/index.twig @@ -61,7 +61,7 @@ {{ ExpandedForm.file('csv_config',{helpText: 'csv_csv_config_file_help'|_}) }} - + {{ ExpandedForm.multiCheckbox('specifix', specifix) }} {% if not uploadPossible %}

    diff --git a/resources/twig/form/multiCheckbox.twig b/resources/twig/form/multiCheckbox.twig new file mode 100644 index 0000000000..ef43eedd67 --- /dev/null +++ b/resources/twig/form/multiCheckbox.twig @@ -0,0 +1,17 @@ +
    + + +
    + {% for value,description in list %} +
    + +
    + {% endfor %} + {% include 'form/help.twig' %} + {% include 'form/feedback.twig' %} + +
    +
    From 001d72a48428d2d4feb3da162eb03098db523978 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 20:56:20 +0200 Subject: [PATCH 51/60] Code cleanup. --- app/Helpers/Csv/Importer.php | 177 +++++++++++++++++++---------------- 1 file changed, 95 insertions(+), 82 deletions(-) diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 9f14ee9836..178048deb5 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -27,6 +27,10 @@ class Importer protected $data; /** @var array */ protected $errors; + /** @var array */ + protected $importData; + /** @var array */ + protected $importRow; /** @var int */ protected $imported = 0; /** @var array */ @@ -41,6 +45,8 @@ class Importer protected $specifix; /** + * Used by CsvController. + * * @return array */ public function getErrors() @@ -49,6 +55,8 @@ class Importer } /** + * Used by CsvController + * * @return int */ public function getImported() @@ -57,6 +65,8 @@ class Importer } /** + * Used by CsvController + * * @return int */ public function getRows() @@ -108,10 +118,7 @@ class Importer */ protected function importRow($row) { - /* - * These fields are necessary to create a new transaction journal. Some are optional: - */ - $data = $this->getFiller(); + $data = $this->getFiller(); // These fields are necessary to create a new transaction journal. Some are optional foreach ($row as $index => $value) { $role = isset($this->roles[$index]) ? $this->roles[$index] : '_ignore'; $class = Config::get('csv.roles.' . $role . '.converter'); @@ -128,20 +135,23 @@ class Importer $data[$field] = $converter->convert(); } + // move to class vars. + $this->importData = $data; + $this->importRow = $row; + unset($data, $row); // post processing and validating. - $data = $this->postProcess($data, $row); - $result = $this->validateData($data); - if ($result === true) { - $journal = $this->createTransactionJournal($data); - } else { - return $result; + $this->postProcess(); + $result = $this->validateData(); + + if (!($result === true)) { + return $result; // return error. } + $journal = $this->createTransactionJournal(); if ($journal instanceof TransactionJournal) { return true; } - return $journal; - + return false; } /** @@ -168,21 +178,18 @@ class Importer /** * Row denotes the original data. * - * @param array $data - * @param array $row - * - * @return array + * @return void */ - protected function postProcess(array $data, array $row) + protected function postProcess() { // do bank specific fixes (must be enabled but now all of them. foreach ($this->getSpecifix() as $className) { /** @var SpecifixInterface $specifix */ $specifix = App::make('FireflyIII\Helpers\Csv\Specifix\\' . $className); - $specifix->setData($data); - $specifix->setRow($row); - $data = $specifix->fix(); + $specifix->setData($this->importData); + $specifix->setRow($this->importRow); + $this->importData = $specifix->fix(); } @@ -190,11 +197,10 @@ class Importer foreach ($set as $className) { /** @var PostProcessorInterface $postProcessor */ $postProcessor = App::make('FireflyIII\Helpers\Csv\PostProcessing\\' . $className); - $postProcessor->setData($data); - $data = $postProcessor->process(); + $postProcessor->setData($this->importData); + $this->importData = $postProcessor->process(); } - return $data; } /** @@ -206,16 +212,15 @@ class Importer } /** - * @param $data * * @return bool|string */ - protected function validateData($data) + protected function validateData() { - if (is_null($data['date']) && is_null($data['date-rent'])) { + if (is_null($this->importData['date']) && is_null($this->importData['date-rent'])) { return 'No date value for this row.'; } - if (is_null($data['opposing-account-object'])) { + if (is_null($this->importData['opposing-account-object'])) { return 'Opposing account is null'; } @@ -223,59 +228,30 @@ class Importer } /** - * @param array $data * * @return TransactionJournal|string */ - protected function createTransactionJournal(array $data) + protected function createTransactionJournal() { bcscale(2); - $date = $data['date']; - if (is_null($data['date'])) { - $date = $data['date-rent']; + $date = $this->importData['date']; + if (is_null($this->importData['date'])) { + $date = $this->importData['date-rent']; } - - // defaults to deposit - $transactionType = TransactionType::where('type', 'Deposit')->first(); - if ($data['amount'] < 0) { - $transactionType = TransactionType::where('type', 'Withdrawal')->first(); - } - - if (in_array($data['opposing-account-object']->accountType->type, ['Asset account', 'Default account'])) { - $transactionType = TransactionType::where('type', 'Transfer')->first(); - } - - $errors = new MessageBag; - $journal = TransactionJournal::create( - [ - 'user_id' => Auth::user()->id, - 'transaction_type_id' => $transactionType->id, - 'transaction_currency_id' => $data['currency']->id, - 'description' => $data['description'], - 'completed' => 0, - 'date' => $date, - 'bill_id' => $data['bill-id'], - ] + $transactionType = $this->getTransactionType(); // defaults to deposit + $errors = new MessageBag; + $journal = TransactionJournal::create( + ['user_id' => Auth::user()->id, 'transaction_type_id' => $transactionType->id, 'transaction_currency_id' => $this->importData['currency']->id, + 'description' => $this->importData['description'], 'completed' => 0, 'date' => $date, 'bill_id' => $this->importData['bill-id'],] ); - $errors = $journal->getErrors()->merge($errors); if ($journal->getErrors()->count() == 0) { - // create both transactions: - $transaction = Transaction::create( - [ - 'transaction_journal_id' => $journal->id, - 'account_id' => $data['asset-account']->id, - 'amount' => $data['amount'] - ] - ); - $errors = $transaction->getErrors()->merge($errors); - - $transaction = Transaction::create( - [ - 'transaction_journal_id' => $journal->id, - 'account_id' => $data['opposing-account-object']->id, - 'amount' => bcmul($data['amount'], -1) - ] - ); + $accountId = $this->importData['asset-account']->id; // create first transaction: + $amount = $this->importData['amount']; + $transaction = Transaction::create(['transaction_journal_id' => $journal->id, 'account_id' => $accountId, 'amount' => $amount]); + $errors = $transaction->getErrors(); + $accountId = $this->importData['opposing-account-object']->id; // create second transaction: + $amount = bcmul($this->importData['amount'], -1); + $transaction = Transaction::create(['transaction_journal_id' => $journal->id, 'account_id' => $accountId, 'amount' => $amount]); $errors = $transaction->getErrors()->merge($errors); } if ($errors->count() == 0) { @@ -286,25 +262,62 @@ class Importer return $text; } + $this->saveBudget($journal); + $this->saveCategory($journal); + $this->saveTags($journal); + return $journal; + } + + /** + * @return TransactionType + */ + protected function getTransactionType() + { + $transactionType = TransactionType::where('type', 'Deposit')->first(); + if ($this->importData['amount'] < 0) { + $transactionType = TransactionType::where('type', 'Withdrawal')->first(); + } + + if (in_array($this->importData['opposing-account-object']->accountType->type, ['Asset account', 'Default account'])) { + $transactionType = TransactionType::where('type', 'Transfer')->first(); + } + + return $transactionType; + } + + /** + * @param TransactionJournal $journal + */ + protected function saveBudget(TransactionJournal $journal) + { // add budget: - if (!is_null($data['budget'])) { - $journal->budgets()->save($data['budget']); + if (!is_null($this->importData['budget'])) { + $journal->budgets()->save($this->importData['budget']); } + } + /** + * @param TransactionJournal $journal + */ + protected function saveCategory(TransactionJournal $journal) + { // add category: - if (!is_null($data['category'])) { - $journal->categories()->save($data['category']); + if (!is_null($this->importData['category'])) { + $journal->categories()->save($this->importData['category']); } - if (!is_null($data['tags'])) { - foreach ($data['tags'] as $tag) { + } + + /** + * @param TransactionJournal $journal + */ + protected function saveTags(TransactionJournal $journal) + { + if (!is_null($this->importData['tags'])) { + foreach ($this->importData['tags'] as $tag) { $journal->tags()->save($tag); } } - - return $journal; - - } /** From 516725456f91f689adc888742f54387b25b968cb Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 21:57:43 +0200 Subject: [PATCH 52/60] Scrutiniser will now include duplicate code. --- .../Csv/PostProcessing/OpposingAccount.php | 34 +------------------ 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/app/Helpers/Csv/PostProcessing/OpposingAccount.php b/app/Helpers/Csv/PostProcessing/OpposingAccount.php index e8fe7a4220..bf3b920568 100644 --- a/app/Helpers/Csv/PostProcessing/OpposingAccount.php +++ b/app/Helpers/Csv/PostProcessing/OpposingAccount.php @@ -24,25 +24,16 @@ class OpposingAccount implements PostProcessorInterface */ public function process() { - Log::debug('Start post processing opposing account'); - // first priority. try to find the account based on ID, - // if any. + // first priority. try to find the account based on ID, if any. if ($this->data['opposing-account-id'] instanceof Account) { - Log::debug('opposing-account-id is an account (#' . $this->data['opposing-account-id']->id . ': ' . $this->data['opposing-account-id']->name . ')'); $this->data['opposing-account-object'] = $this->data['opposing-account-id']; - Log::debug('Done post processing opposing account.'); return $this->data; } // second: try to find the account based on IBAN, if any. if ($this->data['opposing-account-iban'] instanceof Account) { - Log::debug( - 'opposing-account-iban is an account (#' . - $this->data['opposing-account-iban']->id . ': ' . $this->data['opposing-account-iban']->name . ')' - ); $this->data['opposing-account-object'] = $this->data['opposing-account-iban']; - Log::debug('Done post processing opposing account.'); return $this->data; } @@ -54,44 +45,27 @@ class OpposingAccount implements PostProcessorInterface if (is_string($this->data['opposing-account-iban']) && strlen($this->data['opposing-account-iban']) > 0) { - Log::debug('opposing-account-iban is an IBAN string (' . $this->data['opposing-account-iban'] . ')'); if ($result) { - Log::debug('opposing-account-iban is a valid IBAN string!'); - Log::debug('Go to parseIbanString()'); $this->data['opposing-account-object'] = $this->parseIbanString(); - Log::debug('Done post processing opposing account.'); return $this->data; - } else { - Log::debug('opposing-account-iban is NOT a valid IBAN string!'); } } // third: try to find account based on name, if any. if ($this->data['opposing-account-name'] instanceof Account) { - Log::debug( - 'opposing-account-name is an Account (#' . - $this->data['opposing-account-name']->id . ': ' . $this->data['opposing-account-name']->name . ') ' - ); $this->data['opposing-account-object'] = $this->data['opposing-account-name']; - Log::debug('Done post processing opposing account.'); return $this->data; } if (is_string($this->data['opposing-account-name'])) { - Log::debug('Opposing account name is a string: ' . $this->data['opposing-account-name']); - Log::debug('Go to parseNameString'); $this->data['opposing-account-object'] = $this->parseNameString(); - Log::debug('Done post processing opposing account.'); return $this->data; } - Log::debug('Done post processing opposing account.'); return null; - - } /** @@ -107,13 +81,11 @@ class OpposingAccount implements PostProcessorInterface */ protected function parseIbanString() { - Log::debug('Parse IBAN string!'); // create by name and/or iban. $accountType = $this->getAccountType(); $accounts = Auth::user()->accounts()->get(); foreach ($accounts as $entry) { if ($entry->iban == $this->data['opposing-account-iban']) { - Log::debug('Found existing account with this IBAN: (#' . $entry->id . ': ' . $entry->name . ')'); return $entry; } @@ -130,7 +102,6 @@ class OpposingAccount implements PostProcessorInterface 'active' => true, ] ); - Log::debug('Created new (' . $accountType->type . ')B account with this IBAN: (#' . $account->id . ': ' . $account->name . ')'); return $account; } @@ -180,9 +151,6 @@ class OpposingAccount implements PostProcessorInterface ] ); - Log::debug('Created a new (' . $accountType->type . ')A account with this name (#' . $account->id . ': ' . $account->name . ')'); - - return $account; } } \ No newline at end of file From d67db74ca28d264f529354863bd6e368adf11718 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 22:12:35 +0200 Subject: [PATCH 53/60] Optimized some code. --- app/Helpers/Report/ReportQuery.php | 3 +- app/Helpers/Report/ReportQueryInterface.php | 3 +- app/Http/Controllers/CsvController.php | 13 +- app/Http/Controllers/TagController.php | 6 +- .../Controllers/TransactionController.php | 32 +- config/firefly.php | 18 + resources/lang/en/firefly.php | 8 + resources/lang/nl/firefly.php | 658 +++++++++--------- 8 files changed, 375 insertions(+), 366 deletions(-) diff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.php index b2ac2eb624..9d427e67c0 100644 --- a/app/Helpers/Report/ReportQuery.php +++ b/app/Helpers/Report/ReportQuery.php @@ -227,11 +227,10 @@ class ReportQuery implements ReportQueryInterface * @param Account $account * @param Carbon $start * @param Carbon $end - * @param bool $shared * * @return string */ - public function spentNoBudget(Account $account, Carbon $start, Carbon $end, $shared = false) + public function spentNoBudget(Account $account, Carbon $start, Carbon $end) { return Auth::user()->transactionjournals() diff --git a/app/Helpers/Report/ReportQueryInterface.php b/app/Helpers/Report/ReportQueryInterface.php index 9705193dd0..c48aeeab59 100644 --- a/app/Helpers/Report/ReportQueryInterface.php +++ b/app/Helpers/Report/ReportQueryInterface.php @@ -71,11 +71,10 @@ interface ReportQueryInterface * @param Account $account * @param Carbon $start * @param Carbon $end - * @param bool $shared * * @return string */ - public function spentNoBudget(Account $account, Carbon $start, Carbon $end, $shared = false); + public function spentNoBudget(Account $account, Carbon $start, Carbon $end); } diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index c4f580169e..2f2ece6fad 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -229,16 +229,13 @@ class CsvController extends Controller public function map() { - /* - * Make sure all fields we need are accounted for. - */ + // Make sure all fields we need are accounted for. $fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-map', 'csv-roles']; if (!$this->wizard->sessionHasValues($fields)) { Session::flash('warning', 'Could not recover upload.'); return redirect(route('csv.index')); } - /* * The "options" array contains all options the user has * per column, where the key represents the column. @@ -246,10 +243,8 @@ class CsvController extends Controller * For each key there is an array which in turn represents * all the options available: grouped by ID. * - * Aka: - * * options[column index] = [ - * field id => field identifier. + * field id => field identifier. * ] */ try { @@ -258,9 +253,7 @@ class CsvController extends Controller return view('error', ['message' => $e->getMessage()]); } - /* - * After these values are prepped, read the actual CSV file - */ + // After these values are prepped, read the actual CSV file $reader = $this->data->getReader(); $map = $this->data->getMap(); $hasHeaders = $this->data->getHasHeaders(); diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 1a111a5448..80a680c9ba 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -220,9 +220,9 @@ class TagController extends Controller public function store(TagFormRequest $request, TagRepositoryInterface $repository) { if (Input::get('setTag') == 'true') { - $latitude = strlen($request->get('latitude')) > 0 ? $request->get('latitude') : null; - $longitude = strlen($request->get('longitude')) > 0 ? $request->get('longitude') : null; - $zoomLevel = strlen($request->get('zoomLevel')) > 0 ? $request->get('zoomLevel') : null; + $latitude = $request->get('latitude'); + $longitude = $request->get('longitude'); + $zoomLevel = $request->get('zoomLevel'); } else { $latitude = null; $longitude = null; diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 98896829d5..de425e82b7 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -2,6 +2,7 @@ use Auth; use Carbon\Carbon; +use Config; use ExpandedForm; use FireflyIII\Events\JournalCreated; use FireflyIII\Events\JournalSaved; @@ -189,31 +190,12 @@ class TransactionController extends Controller */ public function index(JournalRepositoryInterface $repository, $what) { - $types = []; - switch ($what) { - case 'expenses': - case 'withdrawal': - $subTitleIcon = 'fa-long-arrow-left'; - $subTitle = trans('firefly.expenses'); - $types = ['Withdrawal']; - break; - case 'revenue': - case 'deposit': - $subTitleIcon = 'fa-long-arrow-right'; - $subTitle = trans('firefly.income'); - $types = ['Deposit']; - break; - case 'transfer': - case 'transfers': - $subTitleIcon = 'fa-exchange'; - $subTitle = trans('firefly.transfers'); - $types = ['Transfer']; - break; - } - - $page = intval(Input::get('page')); - $offset = $page > 0 ? ($page - 1) * 50 : 0; - $journals = $repository->getJournalsOfTypes($types, $offset, $page); + $subTitleIcon = Config::get('firefly.transactionIconsByWhat.' . $what); + $types = Config::get('firefly.transactionTypesByWhat.' . $what); + $subTitle = trans('firefly.title_' . $what); + $page = intval(Input::get('page')); + $offset = $page > 0 ? ($page - 1) * 50 : 0; + $journals = $repository->getJournalsOfTypes($types, $offset, $page); $journals->setPath('transactions/' . $what); diff --git a/config/firefly.php b/config/firefly.php index c7dde36697..49251d3e79 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -102,6 +102,24 @@ return [ 'en' => ['en', 'English', 'en_US', 'en_US.utf8'], 'nl' => ['nl', 'Dutch', 'nl_NL', 'nl_NL.utf8'], ], + 'transactionTypesByWhat' => [ + 'expenses' => ['Withdrawal'], + 'withdrawal' => ['Withdrawal'], + 'revenue' => ['Deposit'], + 'deposit' => ['Deposit'], + 'transfer' => ['Transfer'], + 'transfers' => ['Transfer'], + ], + 'transactionIconsByWhat' => [ + 'expenses' => 'fa-long-arrow-left', + 'withdrawal' => 'fa-long-arrow-left', + 'revenue' => 'fa-long-arrow-right', + 'deposit' => 'fa-long-arrow-right', + 'transfer' => 'fa-exchange', + 'transfers' => 'fa-exchange', + + ], + 'month' => [ 'en' => '%B %Y', 'nl' => '%B %Y', diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php index f5cb77de1e..81c8a5cc7f 100644 --- a/resources/lang/en/firefly.php +++ b/resources/lang/en/firefly.php @@ -19,6 +19,14 @@ return [ 'never' => 'Never', 'search_results_for' => 'Search results for ":query"', + // transaction index + 'title_expenses' => 'Expenses', + 'title_withdrawal' => 'Expenses', + 'title_revenue' => 'Revenue / income', + 'title_deposit' => 'Revenue / income', + 'title_transfer' => 'Transfers', + 'title_transfers' => 'Transfers', + // csv import: 'csv_import' => 'Import CSV file', 'csv' => 'CSV', diff --git a/resources/lang/nl/firefly.php b/resources/lang/nl/firefly.php index 6194dd2940..c60a0aa951 100644 --- a/resources/lang/nl/firefly.php +++ b/resources/lang/nl/firefly.php @@ -2,381 +2,391 @@ return [ // general stuff: - 'test' => 'Nederlands geselecteerd!', - 'close' => 'Sluiten', - 'pleaseHold' => 'Momentje...', - 'actions' => 'Acties', - 'edit' => 'Wijzig', - 'delete' => 'Verwijder', - 'welcomeBack' => 'Hoe staat het er voor?', - 'everything' => 'Alles', - 'customRange' => 'Zelf bereik kiezen', - 'apply' => 'Go', - 'cancel' => 'Annuleren', - 'from' => 'Van', - 'to' => 'Tot', - 'showEverything' => 'Laat alles zien', - 'never' => 'Nooit', - 'search_results_for' => 'Zoekresultaten voor ":query"', + 'test' => 'Nederlands geselecteerd!', + 'close' => 'Sluiten', + 'pleaseHold' => 'Momentje...', + 'actions' => 'Acties', + 'edit' => 'Wijzig', + 'delete' => 'Verwijder', + 'welcomeBack' => 'Hoe staat het er voor?', + 'everything' => 'Alles', + 'customRange' => 'Zelf bereik kiezen', + 'apply' => 'Go', + 'cancel' => 'Annuleren', + 'from' => 'Van', + 'to' => 'Tot', + 'showEverything' => 'Laat alles zien', + 'never' => 'Nooit', + 'search_results_for' => 'Zoekresultaten voor ":query"', + + // transaction index + 'title_expenses' => 'Uitgaven', + 'title_withdrawal' => 'Uitgaven', + 'title_revenue' => 'Inkomsten', + 'title_deposit' => 'Inkomsten', + 'title_transfer' => 'Overboekingen', + 'title_transfers' => 'Overboekingen', // csv import: - 'csv_import' => 'Importeer CSV-bestand', - 'csv' => 'CSV', - 'csv_index_title' => 'Upload en importeer een kommagescheiden tekstbestand', - 'csv_index_text' => 'Met deze (en de komende) pagina\'s kan je kommagescheiden tekstbestanden importeren. Deze tool is gebaseerd ' - . 'op de prachtige tool van Atlassian. Om te beginnen selecteer' . - ' je jouw tekstbestand bij "CSV-bestand". ' - . 'Als je hulp nodig hebt, klik dan op het -icoontje rechtsboven.', - 'csv_index_beta_warning' => 'Deze tool is nog erg experimenteel. Wees dus voorzichtig.', - 'csv_header_help' => 'Zet hier een vinkje als de eerste rij van je tekstbestand bestaat uit kolomnamen, en niet uit daadwerkelijke gegevens.', - 'csv_date_help' => 'Het gebruikte datumformaat in jouw bestand. Gebruik het formaat zoals deze' . - ' pagina het uitlegt (Engels). Het standaardformaat kan omgaan met data zoals deze: ' . date('Ymd'), - 'csv_csv_file_help' => 'Voer hier je kommagescheiden tekstbestand in. Je kan er maar één tegelijkertijd invoeren.', - 'csv_csv_config_file_help' => 'Voer hier je configuratiebestand in. Als je deze niet hebt, geen zorgen. Latere stappen leggen dit uit.', - 'csv_upload_button' => 'Begin de import', - 'csv_define_column_roles' => 'Bepaal kolominhoud', - 'csv_column_roles_title' => 'Bepaal de inhoud van elke kolom', - 'csv_column_roles_text' => 'Firefly kan niet automatisch ontdekken wat elke kolom betekent. Je moet het zelf aangeven. Gebruik de' . - ' voorbeeldgegevens als je het ook niet zeker weet. Klik op het -icoontje ' . - 'rechtsboven om te ontdekken wat elke kolomsoort precies is. Als de kolominhoud een directe relatie heeft met gegevens' . - ' die al in Firefly staan, gebruik dan het vinkje. Tijdens de volgende stap komt Firefly hier dan op terug.', - 'csv_column' => 'CSV-kolom', - 'cvs_column_name' => 'CSV-kolomnaam', - 'cvs_column_example' => 'Voorbeeldgegevens', - 'cvs_column_role' => 'Kolom bevat?', - 'csv_do_map_value' => 'Directe relatie?', - 'csv_column__ignore' => '(negeer deze kolom)', - 'csv_column_account-iban' => 'Betaalrekening (IBAN)', - 'csv_column_account-id' => 'Betaalrekening (ID gelijk aan Firefly)', - 'csv_column_account-name' => 'Betaalrekeningnaam', - 'csv_column_amount' => 'Bedrag', - 'csv_column_bill-id' => 'Contract (ID gelijk aan Firefly)', - 'csv_column_bill-name' => 'Contractnaam', - 'csv_column_budget-id' => 'Budget (ID gelijk aan Firefly)', - 'csv_column_budget-name' => 'Budgetnaam', - 'csv_column_category-id' => 'Categorie (ID gelijk aan Firefly)', - 'csv_column_category-name' => 'Categorienaam', - 'csv_column_currency-code' => 'Valutacode (ISO 4217)', - 'csv_column_currency-id' => 'Valuta (ID gelijk aan Firefly)', - 'csv_column_currency-name' => 'Valutanaam', - 'csv_column_currency-symbol' => 'Valuta', - 'csv_column_date-rent' => 'Datum (renteberekening)', - 'csv_column_date-transaction' => 'Datum (transactie)', - 'csv_column_description' => 'Beschrijving', - 'csv_column_opposing-iban' => 'Tegenrekening (IBAN)', - 'csv_column_opposing-id' => 'Tegenrekening (ID gelijk aan Firefly)', - 'csv_column_opposing-name' => 'Tegenrekeningnaam', - 'csv_column_rabo-debet-credit' => 'Rabobankspecifiek bij/af indicator', - 'csv_column_sepa-ct-id' => 'SEPA transactienummer', - 'csv_column_sepa-ct-op' => 'SEPA tegenrekeningnummer', - 'csv_column_sepa-db' => 'SEPA "direct debet"-nummer', - 'csv_column_tags-comma' => 'Tags (kommagescheiden)', - 'csv_column_tags-space' => 'Tags (spatiegescheiden)', - 'csv_column_roles_table' => 'Kolominhoud', - 'csv_continue' => 'Naar de volgende stap', - 'csv_go_back' => 'Terug naar de vorige stap', - 'csv_map_values' => 'Leg relaties met kolomwaardes', - 'csv_map_title' => 'Leg relaties met kolomwaardes', - 'csv_map_text' => 'Sommige kolommen bevatten waardes die misschien al in Firefly bestaan. Selecteer hier de juiste combinaties' . - 'zodat het importeren netjes aansluit bij je huidige gegevens.', - 'cvs_field_value' => 'Veldwaarde', - 'csv_field_mapped_to' => 'Is gelijk aan', - 'csv_do_not_map' => 'Geen relatie', - 'csv_download_config_title' => 'Download importconfiguratie', - 'csv_download_config_text' => + 'csv_import' => 'Importeer CSV-bestand', + 'csv' => 'CSV', + 'csv_index_title' => 'Upload en importeer een kommagescheiden tekstbestand', + 'csv_index_text' => 'Met deze (en de komende) pagina\'s kan je kommagescheiden tekstbestanden importeren. Deze tool is gebaseerd ' + . 'op de prachtige tool van Atlassian. Om te beginnen selecteer' . + ' je jouw tekstbestand bij "CSV-bestand". ' + . 'Als je hulp nodig hebt, klik dan op het -icoontje rechtsboven.', + 'csv_index_beta_warning' => 'Deze tool is nog erg experimenteel. Wees dus voorzichtig.', + 'csv_header_help' => 'Zet hier een vinkje als de eerste rij van je tekstbestand bestaat uit kolomnamen, en niet uit daadwerkelijke gegevens.', + 'csv_date_help' => 'Het gebruikte datumformaat in jouw bestand. Gebruik het formaat zoals deze' . + ' pagina het uitlegt (Engels). Het standaardformaat kan omgaan met data zoals deze: ' . date('Ymd'), + 'csv_csv_file_help' => 'Voer hier je kommagescheiden tekstbestand in. Je kan er maar één tegelijkertijd invoeren.', + 'csv_csv_config_file_help' => 'Voer hier je configuratiebestand in. Als je deze niet hebt, geen zorgen. Latere stappen leggen dit uit.', + 'csv_upload_button' => 'Begin de import', + 'csv_define_column_roles' => 'Bepaal kolominhoud', + 'csv_column_roles_title' => 'Bepaal de inhoud van elke kolom', + 'csv_column_roles_text' => 'Firefly kan niet automatisch ontdekken wat elke kolom betekent. Je moet het zelf aangeven. Gebruik de' . + ' voorbeeldgegevens als je het ook niet zeker weet. Klik op het -icoontje ' . + 'rechtsboven om te ontdekken wat elke kolomsoort precies is. Als de kolominhoud een directe relatie heeft met gegevens' + . + ' die al in Firefly staan, gebruik dan het vinkje. Tijdens de volgende stap komt Firefly hier dan op terug.', + 'csv_column' => 'CSV-kolom', + 'cvs_column_name' => 'CSV-kolomnaam', + 'cvs_column_example' => 'Voorbeeldgegevens', + 'cvs_column_role' => 'Kolom bevat?', + 'csv_do_map_value' => 'Directe relatie?', + 'csv_column__ignore' => '(negeer deze kolom)', + 'csv_column_account-iban' => 'Betaalrekening (IBAN)', + 'csv_column_account-id' => 'Betaalrekening (ID gelijk aan Firefly)', + 'csv_column_account-name' => 'Betaalrekeningnaam', + 'csv_column_amount' => 'Bedrag', + 'csv_column_bill-id' => 'Contract (ID gelijk aan Firefly)', + 'csv_column_bill-name' => 'Contractnaam', + 'csv_column_budget-id' => 'Budget (ID gelijk aan Firefly)', + 'csv_column_budget-name' => 'Budgetnaam', + 'csv_column_category-id' => 'Categorie (ID gelijk aan Firefly)', + 'csv_column_category-name' => 'Categorienaam', + 'csv_column_currency-code' => 'Valutacode (ISO 4217)', + 'csv_column_currency-id' => 'Valuta (ID gelijk aan Firefly)', + 'csv_column_currency-name' => 'Valutanaam', + 'csv_column_currency-symbol' => 'Valuta', + 'csv_column_date-rent' => 'Datum (renteberekening)', + 'csv_column_date-transaction' => 'Datum (transactie)', + 'csv_column_description' => 'Beschrijving', + 'csv_column_opposing-iban' => 'Tegenrekening (IBAN)', + 'csv_column_opposing-id' => 'Tegenrekening (ID gelijk aan Firefly)', + 'csv_column_opposing-name' => 'Tegenrekeningnaam', + 'csv_column_rabo-debet-credit' => 'Rabobankspecifiek bij/af indicator', + 'csv_column_sepa-ct-id' => 'SEPA transactienummer', + 'csv_column_sepa-ct-op' => 'SEPA tegenrekeningnummer', + 'csv_column_sepa-db' => 'SEPA "direct debet"-nummer', + 'csv_column_tags-comma' => 'Tags (kommagescheiden)', + 'csv_column_tags-space' => 'Tags (spatiegescheiden)', + 'csv_column_roles_table' => 'Kolominhoud', + 'csv_continue' => 'Naar de volgende stap', + 'csv_go_back' => 'Terug naar de vorige stap', + 'csv_map_values' => 'Leg relaties met kolomwaardes', + 'csv_map_title' => 'Leg relaties met kolomwaardes', + 'csv_map_text' => 'Sommige kolommen bevatten waardes die misschien al in Firefly bestaan. Selecteer hier de juiste combinaties' . + 'zodat het importeren netjes aansluit bij je huidige gegevens.', + 'cvs_field_value' => 'Veldwaarde', + 'csv_field_mapped_to' => 'Is gelijk aan', + 'csv_do_not_map' => 'Geen relatie', + 'csv_download_config_title' => 'Download importconfiguratie', + 'csv_download_config_text' => 'Firefly is klaar om je bestand te importeren. De instellingen en selecties die je zojuist hebt gemaakt kan je downloaden' . ' en opslaan. Bij de volgende keer kan je dit bestand ook uploaden. Als je kommagescheiden bestand dezelfde indeling' . ' heeft, zullen alle selecties goed staan. Dat scheelt weer!', - 'csv_more_information_text' => 'Ook als het importeren fout gaat is dit bestand handig. Na het importeren krijg je nogmaals de gelegenheid dit bestand' - . 'te downloaden.', - 'csv_do_download_config' => 'Download het configuratiebestand', - 'csv_process_title' => 'Het importeren is klaar', - 'csv_row' => 'Rij', - 'csv_error_see_logs' => 'De logboeken bevatten mogelijk meer details.', - 'csv_process_new_entries' => 'Firefly heeft :imported nieuwe transactie(s) gemaakt.', - 'csv_start_over' => 'Begin opnieuw', - 'csv_to_index' => 'Naar de index', - 'csv_process_text' => ':rows rijen zijn verwerkt.', - 'csv_import_with_errors' => 'Er was één fout. Deze foutmelding is mogelijk in het Engels.|Er zijn :errors fouten opgetreden. De foutmeldingen' - . ' zijn mogelijk in het Engels.', + 'csv_more_information_text' => + 'Ook als het importeren fout gaat is dit bestand handig. Na het importeren krijg je nogmaals de gelegenheid dit bestand' + . 'te downloaden.', + 'csv_do_download_config' => 'Download het configuratiebestand', + 'csv_process_title' => 'Het importeren is klaar', + 'csv_row' => 'Rij', + 'csv_error_see_logs' => 'De logboeken bevatten mogelijk meer details.', + 'csv_process_new_entries' => 'Firefly heeft :imported nieuwe transactie(s) gemaakt.', + 'csv_start_over' => 'Begin opnieuw', + 'csv_to_index' => 'Naar de index', + 'csv_process_text' => ':rows rijen zijn verwerkt.', + 'csv_import_with_errors' => 'Er was één fout. Deze foutmelding is mogelijk in het Engels.|Er zijn :errors fouten opgetreden. De foutmeldingen' + . ' zijn mogelijk in het Engels.', 'csv_specifix_RabobankDescription' => 'Vink dit aan als je Rabobank bestanden importeert.', 'csv_specifix_Dummy' => 'Dit vinkje doet niks (dummy).', // create new stuff: - 'create_new_withdrawal' => 'Nieuwe uitgave', - 'create_new_deposit' => 'Nieuwe inkomsten', - 'create_new_transfer' => 'Nieuwe overschrijving', - 'create_new_asset' => 'Nieuwe betaalrekening', - 'create_new_expense' => 'Nieuwe crediteur', - 'create_new_revenue' => 'Nieuwe debiteur', - 'create_new_piggy_bank' => 'Nieuw spaarpotje', - 'create_new_bill' => 'Nieuw contract', + 'create_new_withdrawal' => 'Nieuwe uitgave', + 'create_new_deposit' => 'Nieuwe inkomsten', + 'create_new_transfer' => 'Nieuwe overschrijving', + 'create_new_asset' => 'Nieuwe betaalrekening', + 'create_new_expense' => 'Nieuwe crediteur', + 'create_new_revenue' => 'Nieuwe debiteur', + 'create_new_piggy_bank' => 'Nieuw spaarpotje', + 'create_new_bill' => 'Nieuw contract', // currencies: - 'create_currency' => 'Maak nieuwe munteenheid', - 'edit_currency' => 'Wijzig munteenheid ":name"', + 'create_currency' => 'Maak nieuwe munteenheid', + 'edit_currency' => 'Wijzig munteenheid ":name"', // new user: - 'submit' => 'Invoeren', - 'getting_started' => 'Aan de start!', - 'to_get_started' => 'Begin met de naam van de bank waar je je betaalrekening hebt, en het saldo van die rekening.', - 'savings_balance_text' => 'Voer ook het saldo van je spaarrekening in, als je die hebt.', - 'cc_balance_text' => 'Als je een credit card hebt, vul dan hier je credit cardlimiet in.', + 'submit' => 'Invoeren', + 'getting_started' => 'Aan de start!', + 'to_get_started' => 'Begin met de naam van de bank waar je je betaalrekening hebt, en het saldo van die rekening.', + 'savings_balance_text' => 'Voer ook het saldo van je spaarrekening in, als je die hebt.', + 'cc_balance_text' => 'Als je een credit card hebt, vul dan hier je credit cardlimiet in.', // forms: - 'mandatoryFields' => 'Verplichte velden', - 'optionalFields' => 'Optionele velden', - 'options' => 'Opties', - 'something' => 'Iets!', + 'mandatoryFields' => 'Verplichte velden', + 'optionalFields' => 'Optionele velden', + 'options' => 'Opties', + 'something' => 'Iets!', // budgets: - 'create_new_budget' => 'Maak een nieuw budget', - 'store_new_budget' => 'Sla nieuw budget op', - 'availableIn' => 'Beschikbaar in :date', - 'transactionsWithoutBudget' => 'Uitgaven zonder budget', - 'transactionsWithoutBudgetDate' => 'Uitgaven zonder budget in :date', - 'createBudget' => 'Maak nieuw budget', - 'inactiveBudgets' => 'Inactieve budgetten', - 'without_budget_between' => 'Transacties zonder budget tussen :start en :end', - 'budget_in_month' => ':name in :month', - 'delete_budget' => 'Verwijder budget ":name"', - 'edit_budget' => 'Wijzig budget ":name"', - 'update_amount' => 'Bedrag bijwerken', + 'create_new_budget' => 'Maak een nieuw budget', + 'store_new_budget' => 'Sla nieuw budget op', + 'availableIn' => 'Beschikbaar in :date', + 'transactionsWithoutBudget' => 'Uitgaven zonder budget', + 'transactionsWithoutBudgetDate' => 'Uitgaven zonder budget in :date', + 'createBudget' => 'Maak nieuw budget', + 'inactiveBudgets' => 'Inactieve budgetten', + 'without_budget_between' => 'Transacties zonder budget tussen :start en :end', + 'budget_in_month' => ':name in :month', + 'delete_budget' => 'Verwijder budget ":name"', + 'edit_budget' => 'Wijzig budget ":name"', + 'update_amount' => 'Bedrag bijwerken', // bills: - 'delete_bill' => 'Verwijder contract ":name"', - 'edit_bill' => 'Wijzig contract ":name"', + 'delete_bill' => 'Verwijder contract ":name"', + 'edit_bill' => 'Wijzig contract ":name"', // accounts: - 'details_for_asset' => 'Overzicht voor betaalrekening ":name"', - 'details_for_expense' => 'Overzicht voor crediteur ":name"', - 'details_for_revenue' => 'Overzicht voor debiteur ":name"', - 'details_for_cash' => 'Overzicht voor contant geldrekening ":name"', + 'details_for_asset' => 'Overzicht voor betaalrekening ":name"', + 'details_for_expense' => 'Overzicht voor crediteur ":name"', + 'details_for_revenue' => 'Overzicht voor debiteur ":name"', + 'details_for_cash' => 'Overzicht voor contant geldrekening ":name"', - 'store_new_asset_account' => 'Sla nieuwe betaalrekening op', - 'store_new_expense_account' => 'Sla nieuwe crediteur op', - 'store_new_revenue_account' => 'Sla nieuwe debiteur op', + 'store_new_asset_account' => 'Sla nieuwe betaalrekening op', + 'store_new_expense_account' => 'Sla nieuwe crediteur op', + 'store_new_revenue_account' => 'Sla nieuwe debiteur op', - 'edit_asset_account' => 'Wijzig betaalrekening ":name"', - 'edit_expense_account' => 'Wijzig crediteur ":name"', - 'edit_revenue_account' => 'Wijzig debiteur ":name"', + 'edit_asset_account' => 'Wijzig betaalrekening ":name"', + 'edit_expense_account' => 'Wijzig crediteur ":name"', + 'edit_revenue_account' => 'Wijzig debiteur ":name"', - 'delete_asset_account' => 'Verwijder betaalrekening ":name"', - 'delete_expense_account' => 'Verwijder crediteur ":name"', - 'delete_revenue_account' => 'Verwijder debiteur ":name"', + 'delete_asset_account' => 'Verwijder betaalrekening ":name"', + 'delete_expense_account' => 'Verwijder crediteur ":name"', + 'delete_revenue_account' => 'Verwijder debiteur ":name"', - 'asset_deleted' => 'Betaalrekening ":name" is verwijderd.', - 'expense_deleted' => 'Crediteur ":name" is verwijderd.', - 'revenue_deleted' => 'Debiteur ":name" is verwijderd.', + 'asset_deleted' => 'Betaalrekening ":name" is verwijderd.', + 'expense_deleted' => 'Crediteur ":name" is verwijderd.', + 'revenue_deleted' => 'Debiteur ":name" is verwijderd.', - 'update_asset_account' => 'Wijzig betaalrekening', - 'update_expense_account' => 'Wijzig crediteur', - 'update_revenue_account' => 'Wijzig debiteur', + 'update_asset_account' => 'Wijzig betaalrekening', + 'update_expense_account' => 'Wijzig crediteur', + 'update_revenue_account' => 'Wijzig debiteur', - 'make_new_asset_account' => 'Nieuwe betaalrekening', - 'make_new_expense_account' => 'Nieuwe crediteur', - 'make_new_revenue_account' => 'Nieuwe debiteur', + 'make_new_asset_account' => 'Nieuwe betaalrekening', + 'make_new_expense_account' => 'Nieuwe crediteur', + 'make_new_revenue_account' => 'Nieuwe debiteur', - 'asset_accounts' => 'Betaalrekeningen', - 'expense_accounts' => 'Crediteuren', - 'revenue_accounts' => 'Debiteuren', - 'account_type' => 'Account type', + 'asset_accounts' => 'Betaalrekeningen', + 'expense_accounts' => 'Crediteuren', + 'revenue_accounts' => 'Debiteuren', + 'account_type' => 'Account type', // some extra help: - 'accountExtraHelp_asset' => '', - 'accountExtraHelp_expense' => + 'accountExtraHelp_asset' => '', + 'accountExtraHelp_expense' => 'Een crediteur is een persoon of een bedrijf waar je geld aan moet betalen. Je staat bij ze in het krijt. Een verwarrende' . ' term misschien, maar zo werkt het nou eenmaal. De supermarkt, je huurbaas of de bank zijn crediteuren. Jouw ' . 'geld (krediet) gaat naar hen toe. De term komt uit de wereld van de boekhouding. De uitgaves die je hier ziet zijn ' . 'positief, want je kijkt uit hun perspectief. Zodra jij afrekent in een winkel, komt het geld er bij hen bij (positief).', - 'accountExtraHelp_revenue' => 'Als je geld krijgt van een bedrijf of een persoon is dat een debiteur. ' . - 'Dat kan salaris zijn, of een andere betaling. ' . - ' Ze hebben een schuld (debet) aan jou. De term komt uit de wereld van de boekhouding.' . - ' De inkomsten die je hier ziet zijn negatief, want je kijkt uit hun perspectief. Zodra een debiteur geld naar jou ' . - 'overmaakt gaat het er bij hen af (negatief).', + 'accountExtraHelp_revenue' => 'Als je geld krijgt van een bedrijf of een persoon is dat een debiteur. ' . + 'Dat kan salaris zijn, of een andere betaling. ' . + ' Ze hebben een schuld (debet) aan jou. De term komt uit de wereld van de boekhouding.' . + ' De inkomsten die je hier ziet zijn negatief, want je kijkt uit hun perspectief. Zodra een debiteur geld naar jou ' . + 'overmaakt gaat het er bij hen af (negatief).', // categories: - 'new_category' => 'Nieuwe categorie', - 'create_new_category' => 'Nieuwe categorie', - 'without_category' => 'Zonder categorie', - 'update_category' => 'Wijzig categorie', - 'edit_category' => 'Wijzig categorie ":name"', - 'categories' => 'Categorieën', - 'no_category' => '(geen categorie)', - 'category' => 'Categorie', - 'delete_category' => 'Verwijder categorie ":name"', + 'new_category' => 'Nieuwe categorie', + 'create_new_category' => 'Nieuwe categorie', + 'without_category' => 'Zonder categorie', + 'update_category' => 'Wijzig categorie', + 'edit_category' => 'Wijzig categorie ":name"', + 'categories' => 'Categorieën', + 'no_category' => '(geen categorie)', + 'category' => 'Categorie', + 'delete_category' => 'Verwijder categorie ":name"', // transactions: - 'update_withdrawal' => 'Wijzig uitgave', - 'update_deposit' => 'Wijzig inkomsten', - 'update_transfer' => 'Wijzig overschrijving', - 'delete_withdrawal' => 'Verwijder uitgave ":description"', - 'delete_deposit' => 'Verwijder inkomsten ":description"', - 'delete_transfer' => 'Verwijder overschrijving ":description"', + 'update_withdrawal' => 'Wijzig uitgave', + 'update_deposit' => 'Wijzig inkomsten', + 'update_transfer' => 'Wijzig overschrijving', + 'delete_withdrawal' => 'Verwijder uitgave ":description"', + 'delete_deposit' => 'Verwijder inkomsten ":description"', + 'delete_transfer' => 'Verwijder overschrijving ":description"', // new user: - 'welcome' => 'Welkom bij Firefly!', - 'createNewAsset' => 'Maak om te beginnen een nieuwe betaalrekening. Dit is je start van je financiële beheer.', - 'createNewAssetButton' => 'Maak een nieuwe betaalrekening', + 'welcome' => 'Welkom bij Firefly!', + 'createNewAsset' => 'Maak om te beginnen een nieuwe betaalrekening. Dit is je start van je financiële beheer.', + 'createNewAssetButton' => 'Maak een nieuwe betaalrekening', // home page: - 'yourAccounts' => 'Je betaalrekeningen', - 'budgetsAndSpending' => 'Budgetten en uitgaven', - 'savings' => 'Sparen', - 'markAsSavingsToContinue' => 'Om hier wat te zien stel je je betaalrekeningen in als "spaarrekening".', - 'createPiggyToContinue' => 'Maak spaarpotjes om hier iets te zien.', - 'newWithdrawal' => 'Nieuwe uitgave', - 'newDeposit' => 'Nieuwe inkomsten', - 'newTransfer' => 'Nieuwe overschrijving', - 'moneyIn' => 'Inkomsten', - 'moneyOut' => 'Uitgaven', - 'billsToPay' => 'Openstaande contracten', - 'billsPaid' => 'Betaalde contracten', - 'viewDetails' => 'Meer info', - 'divided' => 'verdeeld', - 'toDivide' => 'te verdelen', + 'yourAccounts' => 'Je betaalrekeningen', + 'budgetsAndSpending' => 'Budgetten en uitgaven', + 'savings' => 'Sparen', + 'markAsSavingsToContinue' => 'Om hier wat te zien stel je je betaalrekeningen in als "spaarrekening".', + 'createPiggyToContinue' => 'Maak spaarpotjes om hier iets te zien.', + 'newWithdrawal' => 'Nieuwe uitgave', + 'newDeposit' => 'Nieuwe inkomsten', + 'newTransfer' => 'Nieuwe overschrijving', + 'moneyIn' => 'Inkomsten', + 'moneyOut' => 'Uitgaven', + 'billsToPay' => 'Openstaande contracten', + 'billsPaid' => 'Betaalde contracten', + 'viewDetails' => 'Meer info', + 'divided' => 'verdeeld', + 'toDivide' => 'te verdelen', // menu and titles, should be recycled as often as possible: - 'toggleNavigation' => 'Navigatie aan of uit', - 'currency' => 'Munteenheden', - 'preferences' => 'Voorkeuren', - 'logout' => 'Uitloggen', - 'searchPlaceholder' => 'Zoeken...', - 'dashboard' => 'Dashboard', - 'currencies' => 'Munteenheden', - 'accounts' => 'Rekeningen', - 'Asset account' => 'Betaalrekening', - 'Default account' => 'Betaalrekening', - 'Expense account' => 'Crediteur', - 'Revenue account' => 'Debiteur', - 'budgets' => 'Budgetten', - 'tags' => 'Tags', - 'reports' => 'Overzichten', - 'transactions' => 'Transacties', - 'expenses' => 'Uitgaven', - 'income' => 'Inkomsten', - 'transfers' => 'Overschrijvingen', - 'moneyManagement' => 'Geldbeheer', - 'piggyBanks' => 'Spaarpotjes', - 'bills' => 'Contracten', - 'createNew' => 'Nieuw', - 'withdrawal' => 'Uitgave', - 'deposit' => 'Inkomsten', - 'account' => 'Rekening', - 'transfer' => 'Overschrijving', - 'Withdrawal' => 'Uitgave', - 'Deposit' => 'Inkomsten', - 'Transfer' => 'Overschrijving', - 'bill' => 'Contract', - 'yes' => 'Ja', - 'no' => 'Nee', - 'amount' => 'Bedrag', - 'newBalance' => 'Nieuw saldo', - 'overview' => 'Overzicht', - 'saveOnAccount' => 'Sparen op rekening', - 'unknown' => 'Onbekend', - 'daily' => 'Dagelijks', - 'weekly' => 'Wekelijks', - 'monthly' => 'Maandelijks', - 'quarterly' => 'Elk kwartaal', - 'half-year' => 'Elk half jaar', - 'yearly' => 'Jaarlijks', + 'toggleNavigation' => 'Navigatie aan of uit', + 'currency' => 'Munteenheden', + 'preferences' => 'Voorkeuren', + 'logout' => 'Uitloggen', + 'searchPlaceholder' => 'Zoeken...', + 'dashboard' => 'Dashboard', + 'currencies' => 'Munteenheden', + 'accounts' => 'Rekeningen', + 'Asset account' => 'Betaalrekening', + 'Default account' => 'Betaalrekening', + 'Expense account' => 'Crediteur', + 'Revenue account' => 'Debiteur', + 'budgets' => 'Budgetten', + 'tags' => 'Tags', + 'reports' => 'Overzichten', + 'transactions' => 'Transacties', + 'expenses' => 'Uitgaven', + 'income' => 'Inkomsten', + 'transfers' => 'Overschrijvingen', + 'moneyManagement' => 'Geldbeheer', + 'piggyBanks' => 'Spaarpotjes', + 'bills' => 'Contracten', + 'createNew' => 'Nieuw', + 'withdrawal' => 'Uitgave', + 'deposit' => 'Inkomsten', + 'account' => 'Rekening', + 'transfer' => 'Overschrijving', + 'Withdrawal' => 'Uitgave', + 'Deposit' => 'Inkomsten', + 'Transfer' => 'Overschrijving', + 'bill' => 'Contract', + 'yes' => 'Ja', + 'no' => 'Nee', + 'amount' => 'Bedrag', + 'newBalance' => 'Nieuw saldo', + 'overview' => 'Overzicht', + 'saveOnAccount' => 'Sparen op rekening', + 'unknown' => 'Onbekend', + 'daily' => 'Dagelijks', + 'weekly' => 'Wekelijks', + 'monthly' => 'Maandelijks', + 'quarterly' => 'Elk kwartaal', + 'half-year' => 'Elk half jaar', + 'yearly' => 'Jaarlijks', // reports: - 'reportForYear' => 'Jaaroverzicht :year', - 'reportForYearShared' => 'Jaaroverzicht :year (inclusief gedeelde rekeningen)', - 'reportForMonth' => 'Maandoverzicht van :date', - 'reportForMonthShared' => 'Maandoverzicht van :date (inclusief gedeelde rekeningen)', - 'incomeVsExpenses' => 'Inkomsten tegenover uitgaven', - 'accountBalances' => 'Rekeningsaldi', - 'balanceStartOfYear' => 'Saldo aan het begin van het jaar', - 'balanceEndOfYear' => 'Saldo aan het einde van het jaar', - 'balanceStartOfMonth' => 'Saldo aan het begin van de maand', - 'balanceEndOfMonth' => 'Saldo aan het einde van de maand', - 'balanceStart' => 'Saldo aan het begin van de periode', - 'balanceEnd' => 'Saldo aan het einde van de periode', - 'reportsOwnAccounts' => 'Overzichten voor je eigen betaalrekeningen', - 'reportsOwnAccountsAndShared' => 'Overzichten voor je eigen betaalrekeningen en gedeelde rekeningen', - 'splitByAccount' => 'Per betaalrekening', - 'balancedByTransfersAndTags' => 'Gecorrigeerd met overschrijvingen en tags', - 'coveredWithTags' => 'Gecorrigeerd met tags', - 'leftUnbalanced' => 'Ongecorrigeerd', - 'expectedBalance' => 'Verwacht saldo', - 'outsideOfBudgets' => 'Buiten budgetten', - 'leftInBudget' => 'Over van budget', - 'sumOfSums' => 'Alles bij elkaar', - 'notCharged' => '(Nog) niet betaald', - 'inactive' => 'Niet actief', - 'difference' => 'Verschil', - 'in' => 'In', - 'out' => 'Uit', - 'topX' => 'top :number', - 'showTheRest' => 'Laat alles zien', - 'hideTheRest' => 'Laat alleen de top :number zien', + 'reportForYear' => 'Jaaroverzicht :year', + 'reportForYearShared' => 'Jaaroverzicht :year (inclusief gedeelde rekeningen)', + 'reportForMonth' => 'Maandoverzicht van :date', + 'reportForMonthShared' => 'Maandoverzicht van :date (inclusief gedeelde rekeningen)', + 'incomeVsExpenses' => 'Inkomsten tegenover uitgaven', + 'accountBalances' => 'Rekeningsaldi', + 'balanceStartOfYear' => 'Saldo aan het begin van het jaar', + 'balanceEndOfYear' => 'Saldo aan het einde van het jaar', + 'balanceStartOfMonth' => 'Saldo aan het begin van de maand', + 'balanceEndOfMonth' => 'Saldo aan het einde van de maand', + 'balanceStart' => 'Saldo aan het begin van de periode', + 'balanceEnd' => 'Saldo aan het einde van de periode', + 'reportsOwnAccounts' => 'Overzichten voor je eigen betaalrekeningen', + 'reportsOwnAccountsAndShared' => 'Overzichten voor je eigen betaalrekeningen en gedeelde rekeningen', + 'splitByAccount' => 'Per betaalrekening', + 'balancedByTransfersAndTags' => 'Gecorrigeerd met overschrijvingen en tags', + 'coveredWithTags' => 'Gecorrigeerd met tags', + 'leftUnbalanced' => 'Ongecorrigeerd', + 'expectedBalance' => 'Verwacht saldo', + 'outsideOfBudgets' => 'Buiten budgetten', + 'leftInBudget' => 'Over van budget', + 'sumOfSums' => 'Alles bij elkaar', + 'notCharged' => '(Nog) niet betaald', + 'inactive' => 'Niet actief', + 'difference' => 'Verschil', + 'in' => 'In', + 'out' => 'Uit', + 'topX' => 'top :number', + 'showTheRest' => 'Laat alles zien', + 'hideTheRest' => 'Laat alleen de top :number zien', // charts: - 'dayOfMonth' => 'Dag vd maand', - 'month' => 'Maand', - 'budget' => 'Budget', - 'spent' => 'Uitgegeven', - 'overspent' => 'Teveel uitgegeven', - 'left' => 'Over', - 'noBudget' => '(geen budget)', - 'maxAmount' => 'Maximaal bedrag', - 'minAmount' => 'Minimaal bedrag', - 'billEntry' => 'Bedrag voor dit contract', - 'name' => 'Naam', - 'date' => 'Datum', - 'paid' => 'Betaald', - 'unpaid' => 'Niet betaald', - 'day' => 'Dag', - 'budgeted' => 'Gebudgetteerd', - 'period' => 'Periode', - 'balance' => 'Saldo', - 'summary' => 'Samenvatting', - 'sum' => 'Som', - 'average' => 'Gemiddeld', - 'balanceFor' => 'Saldo op :name', + 'dayOfMonth' => 'Dag vd maand', + 'month' => 'Maand', + 'budget' => 'Budget', + 'spent' => 'Uitgegeven', + 'overspent' => 'Teveel uitgegeven', + 'left' => 'Over', + 'noBudget' => '(geen budget)', + 'maxAmount' => 'Maximaal bedrag', + 'minAmount' => 'Minimaal bedrag', + 'billEntry' => 'Bedrag voor dit contract', + 'name' => 'Naam', + 'date' => 'Datum', + 'paid' => 'Betaald', + 'unpaid' => 'Niet betaald', + 'day' => 'Dag', + 'budgeted' => 'Gebudgetteerd', + 'period' => 'Periode', + 'balance' => 'Saldo', + 'summary' => 'Samenvatting', + 'sum' => 'Som', + 'average' => 'Gemiddeld', + 'balanceFor' => 'Saldo op :name', // piggy banks: - 'piggy_bank' => 'Spaarpotje', - 'new_piggy_bank' => 'Nieuw spaarpotje', - 'create_new_piggybank' => 'Nieuw spaarpotje', - 'account_status' => 'Rekeningoverzicht', - 'left_for_piggy_banks' => 'Over voor spaarpotjes', - 'sum_of_piggy_banks' => 'Som van spaarpotjes', - 'saved_so_far' => 'Gespaard', - 'left_to_save' => 'Te sparen', - 'add_money_to_piggy_title' => 'Stop geld in spaarpotje ":name"', - 'remove_money_from_piggy_title' => 'Haal geld uit spaarpotje ":name"', - 'add' => 'Toevoegen', - 'remove' => 'Verwijderen', - 'max_amount_add' => 'Hooguit toe te voegen', - 'max_amount_remove' => 'Hooguit te verwijderen', - 'update_piggy_button' => 'Wijzig spaarpotje', - 'update_piggy_title' => 'Wijzig spaarpotje ":name"', - 'details' => 'Details', - 'events' => 'Gebeurtenissen', - 'target_amount' => 'Doelbedrag', - 'start_date' => 'Startdatum', - 'target_date' => 'Doeldatum', - 'no_target_date' => 'Geen doeldatum', - 'todo' => 'te doen', - 'table' => 'Tabel', - 'piggy_bank_not_exists' => 'Dit spaarpotje bestaat niet meer.', - 'add_any_amount_to_piggy' => 'Stop geld in dit spaarpotje om het doel van :amount te halen.', - 'add_set_amount_to_piggy' => 'Stop voor :date :amount in dit spaarpotje om hem op tijd te vullen.', - 'delete_piggy_bank' => 'Verwijder spaarpotje ":name"', + 'piggy_bank' => 'Spaarpotje', + 'new_piggy_bank' => 'Nieuw spaarpotje', + 'create_new_piggybank' => 'Nieuw spaarpotje', + 'account_status' => 'Rekeningoverzicht', + 'left_for_piggy_banks' => 'Over voor spaarpotjes', + 'sum_of_piggy_banks' => 'Som van spaarpotjes', + 'saved_so_far' => 'Gespaard', + 'left_to_save' => 'Te sparen', + 'add_money_to_piggy_title' => 'Stop geld in spaarpotje ":name"', + 'remove_money_from_piggy_title' => 'Haal geld uit spaarpotje ":name"', + 'add' => 'Toevoegen', + 'remove' => 'Verwijderen', + 'max_amount_add' => 'Hooguit toe te voegen', + 'max_amount_remove' => 'Hooguit te verwijderen', + 'update_piggy_button' => 'Wijzig spaarpotje', + 'update_piggy_title' => 'Wijzig spaarpotje ":name"', + 'details' => 'Details', + 'events' => 'Gebeurtenissen', + 'target_amount' => 'Doelbedrag', + 'start_date' => 'Startdatum', + 'target_date' => 'Doeldatum', + 'no_target_date' => 'Geen doeldatum', + 'todo' => 'te doen', + 'table' => 'Tabel', + 'piggy_bank_not_exists' => 'Dit spaarpotje bestaat niet meer.', + 'add_any_amount_to_piggy' => 'Stop geld in dit spaarpotje om het doel van :amount te halen.', + 'add_set_amount_to_piggy' => 'Stop voor :date :amount in dit spaarpotje om hem op tijd te vullen.', + 'delete_piggy_bank' => 'Verwijder spaarpotje ":name"', // tags - 'delete_tag' => 'Verwijder tag ":name"', - 'new_tag' => 'Maak nieuwe tag', - 'edit_tag' => 'Wijzig tag ":tag"', - 'no_year' => 'Zonder jaar', - 'no_maand' => 'Zonder jaar', - 'tag_title_nothing' => 'Standaard tags', - 'tag_title_balancingAct' => 'Balancing act tags', - 'tag_title_advancePayment' => 'Advance payment tags', + 'delete_tag' => 'Verwijder tag ":name"', + 'new_tag' => 'Maak nieuwe tag', + 'edit_tag' => 'Wijzig tag ":tag"', + 'no_year' => 'Zonder jaar', + 'no_maand' => 'Zonder jaar', + 'tag_title_nothing' => 'Standaard tags', + 'tag_title_balancingAct' => 'Balancing act tags', + 'tag_title_advancePayment' => 'Advance payment tags', ]; From 2d4b148b2ce3e9cf2d9ec3949630a5fe0527a952 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 6 Jul 2015 22:23:34 +0200 Subject: [PATCH 54/60] Various optimisations. --- .../Chart/Bill/ChartJsBillChartGenerator.php | 10 ++----- .../Csv/Converter/RabobankDebetCredit.php | 5 ++++ app/Helpers/Csv/Data.php | 2 +- app/Helpers/Csv/Importer.php | 2 +- .../Csv/PostProcessing/OpposingAccount.php | 15 +++-------- app/Helpers/Report/ReportHelper.php | 3 +-- app/Helpers/Report/ReportHelperInterface.php | 3 +-- .../Controllers/Chart/CategoryController.php | 13 +++------- app/Http/Controllers/CsvController.php | 9 +++---- .../Account/AccountRepository.php | 26 +++++-------------- .../Journal/JournalRepository.php | 6 ++--- .../Journal/JournalRepositoryInterface.php | 4 +-- app/Validation/FireflyValidator.php | 6 +++-- tests/_support/Helper/Acceptance.php | 5 ++++ tests/_support/Helper/Functional.php | 5 ++++ tests/_support/Helper/Unit.php | 5 ++++ .../_generated/AcceptanceTesterActions.php | 5 ++++ .../_generated/FunctionalTesterActions.php | 5 ++++ .../_support/_generated/UnitTesterActions.php | 5 ++++ 19 files changed, 66 insertions(+), 68 deletions(-) diff --git a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php index 8580bbf1b2..e4dd7a6857 100644 --- a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php +++ b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php @@ -24,25 +24,19 @@ class ChartJsBillChartGenerator implements BillChartGenerator */ public function frontpage(Collection $paid, Collection $unpaid) { - - // loop paid and create single entry: $paidDescriptions = []; $paidAmount = 0; $unpaidDescriptions = []; $unpaidAmount = 0; - bcscale(2); /** @var TransactionJournal $entry */ - foreach ($paid as $entry) { - + foreach ($paid as $entry) { // loop paid and create single entry: $paidDescriptions[] = $entry->description; $paidAmount = bcadd($paidAmount, $entry->amount); } - - // loop unpaid: /** @var Bill $entry */ - foreach ($unpaid as $entry) { + foreach ($unpaid as $entry) { // loop unpaid: $description = $entry[0]->name . ' (' . $entry[1]->format('jS M Y') . ')'; $amount = ($entry[0]->amount_max + $entry[0]->amount_min) / 2; $unpaidDescriptions[] = $description; diff --git a/app/Helpers/Csv/Converter/RabobankDebetCredit.php b/app/Helpers/Csv/Converter/RabobankDebetCredit.php index f410c03d92..bfe1babc5e 100644 --- a/app/Helpers/Csv/Converter/RabobankDebetCredit.php +++ b/app/Helpers/Csv/Converter/RabobankDebetCredit.php @@ -3,6 +3,11 @@ namespace FireflyIII\Helpers\Csv\Converter; +/** + * Class RabobankDebetCredit + * + * @package FireflyIII\Helpers\Csv\Converter + */ class RabobankDebetCredit extends BasicConverter implements ConverterInterface { diff --git a/app/Helpers/Csv/Data.php b/app/Helpers/Csv/Data.php index 3230a346e6..f6eca2f145 100644 --- a/app/Helpers/Csv/Data.php +++ b/app/Helpers/Csv/Data.php @@ -119,7 +119,7 @@ class Data /** * @return bool */ - public function getHasHeaders() + public function hasHeaders() { return $this->hasHeaders; } diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 178048deb5..fe8ca0f7dc 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -107,7 +107,7 @@ class Importer */ protected function parseRow($index) { - return (($this->data->getHasHeaders() && $index > 1) || !$this->data->getHasHeaders()); + return (($this->data->hasHeaders() && $index > 1) || !$this->data->hasHeaders()); } /** diff --git a/app/Helpers/Csv/PostProcessing/OpposingAccount.php b/app/Helpers/Csv/PostProcessing/OpposingAccount.php index bf3b920568..55d3b67ea4 100644 --- a/app/Helpers/Csv/PostProcessing/OpposingAccount.php +++ b/app/Helpers/Csv/PostProcessing/OpposingAccount.php @@ -24,26 +24,20 @@ class OpposingAccount implements PostProcessorInterface */ public function process() { - // first priority. try to find the account based on ID, if any. - if ($this->data['opposing-account-id'] instanceof Account) { + if ($this->data['opposing-account-id'] instanceof Account) { // first priority. try to find the account based on ID, if any $this->data['opposing-account-object'] = $this->data['opposing-account-id']; return $this->data; } - - // second: try to find the account based on IBAN, if any. - if ($this->data['opposing-account-iban'] instanceof Account) { + if ($this->data['opposing-account-iban'] instanceof Account) { // second: try to find the account based on IBAN, if any. $this->data['opposing-account-object'] = $this->data['opposing-account-iban']; return $this->data; } - $rules = ['iban' => 'iban']; $check = ['iban' => $this->data['opposing-account-iban']]; $validator = Validator::make($check, $rules); $result = !$validator->fails(); - - if (is_string($this->data['opposing-account-iban']) && strlen($this->data['opposing-account-iban']) > 0) { if ($result) { $this->data['opposing-account-object'] = $this->parseIbanString(); @@ -51,14 +45,11 @@ class OpposingAccount implements PostProcessorInterface return $this->data; } } - - // third: try to find account based on name, if any. - if ($this->data['opposing-account-name'] instanceof Account) { + if ($this->data['opposing-account-name'] instanceof Account) { // third: try to find account based on name, if any. $this->data['opposing-account-object'] = $this->data['opposing-account-name']; return $this->data; } - if (is_string($this->data['opposing-account-name'])) { $this->data['opposing-account-object'] = $this->parseNameString(); diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index 37222d4123..691189df68 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -202,11 +202,10 @@ class ReportHelper implements ReportHelperInterface * * @param Carbon $start * @param Carbon $end - * @param boolean $shared * * @return BillCollection */ - public function getBillReport(Carbon $start, Carbon $end, $shared) + public function getBillReport(Carbon $start, Carbon $end) { /** @var \FireflyIII\Repositories\Bill\BillRepositoryInterface $repository */ $repository = App::make('FireflyIII\Repositories\Bill\BillRepositoryInterface'); diff --git a/app/Helpers/Report/ReportHelperInterface.php b/app/Helpers/Report/ReportHelperInterface.php index 75ffbdfd0c..f3dbf42546 100644 --- a/app/Helpers/Report/ReportHelperInterface.php +++ b/app/Helpers/Report/ReportHelperInterface.php @@ -37,11 +37,10 @@ interface ReportHelperInterface * * @param Carbon $start * @param Carbon $end - * @param boolean $shared * * @return BillCollection */ - public function getBillReport(Carbon $start, Carbon $end, $shared); + public function getBillReport(Carbon $start, Carbon $end); /** * @param Carbon $start diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index 28f4f17bf5..917bb76b08 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -176,9 +176,7 @@ class CategoryController extends Controller $start = new Carbon($year . '-01-01'); $end = new Carbon($year . '-12-31'); - - // chart properties for cache: - $cache = new CacheProperties; + $cache = new CacheProperties; // chart properties for cache: $cache->addProperty($start); $cache->addProperty($end); $cache->addProperty('category'); @@ -192,14 +190,11 @@ class CategoryController extends Controller $entries = new Collection; while ($start < $end) { - // month is the current end of the period: - $month = clone $start; + $month = clone $start; // month is the current end of the period $month->endOfMonth(); - // make a row: - $row = [clone $start]; + $row = [clone $start]; // make a row: - // each budget, fill the row: - foreach ($categories as $category) { + foreach ($categories as $category) { // each budget, fill the row $spent = $repository->spentInPeriodCorrected($category, $start, $month, $shared); $row[] = $spent; } diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 2f2ece6fad..6349b0a47a 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -75,7 +75,7 @@ class CsvController extends Controller for ($i = 1; $i <= $count; $i++) { $headers[] = trans('firefly.csv_column') . ' #' . $i; } - if ($this->data->getHasHeaders()) { + if ($this->data->hasHeaders()) { $headers = $firstRow; } @@ -184,7 +184,6 @@ class CsvController extends Controller return redirect(route('csv.index')); } - // process given roles and mapping: $roles = $this->wizard->processSelectedRoles(Input::get('role')); $maps = $this->wizard->processSelectedMapping($roles, Input::get('map')); @@ -192,9 +191,7 @@ class CsvController extends Controller Session::put('csv-map', $maps); Session::put('csv-roles', $roles); - /* - * Go back when no roles defined: - */ + // Go back when no roles defined: if (count($roles) === 0) { Session::flash('warning', 'Please select some roles.'); @@ -256,7 +253,7 @@ class CsvController extends Controller // After these values are prepped, read the actual CSV file $reader = $this->data->getReader(); $map = $this->data->getMap(); - $hasHeaders = $this->data->getHasHeaders(); + $hasHeaders = $this->data->hasHeaders(); $values = $this->wizard->getMappableValues($reader, $map, $hasHeaders); $map = $this->data->getMap(); $mapped = $this->data->getMapped(); diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 9bf61a3099..39b601a1c9 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -566,7 +566,6 @@ class AccountRepository implements AccountRepositoryInterface ); $journal->save(); - if ($data['openingBalance'] < 0) { $firstAccount = $opposing; $secondAccount = $account; @@ -578,26 +577,11 @@ class AccountRepository implements AccountRepositoryInterface $firstAmount = $data['openingBalance']; $secondAmount = $data['openingBalance'] * -1; } + $one = new Transaction(['account_id' => $firstAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $firstAmount]); + $one->save();// first transaction: from - // first transaction: from - $one = new Transaction( - [ - 'account_id' => $firstAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $firstAmount - ] - ); - $one->save(); - - // second transaction: to - $two = new Transaction( - [ - 'account_id' => $secondAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $secondAmount - ] - ); - $two->save(); + $two = new Transaction(['account_id' => $secondAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $secondAmount]); + $two->save(); // second transaction: to return $journal; @@ -606,6 +590,8 @@ class AccountRepository implements AccountRepositoryInterface /** * @param Account $account * @param array $data + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function updateMetadata(Account $account, array $data) { diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index ae1882b4f9..169a746e40 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -115,14 +115,14 @@ class JournalRepository implements JournalRepositoryInterface } /** - * @param $id + * @param int $journalId * @param Carbon $date * * @return TransactionJournal */ - public function getWithDate($id, Carbon $date) + public function getWithDate($journalId, Carbon $date) { - return Auth::user()->transactionjournals()->where('id', $id)->where('date', $date->format('Y-m-d 00:00:00'))->first(); + return Auth::user()->transactionjournals()->where('id', $journalId)->where('date', $date->format('Y-m-d 00:00:00'))->first(); } /** diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php index baaee122f2..fb7ccb6cc9 100644 --- a/app/Repositories/Journal/JournalRepositoryInterface.php +++ b/app/Repositories/Journal/JournalRepositoryInterface.php @@ -62,12 +62,12 @@ interface JournalRepositoryInterface public function getTransactionType($type); /** - * @param $id + * @param int $journalId * @param Carbon $date * * @return TransactionJournal */ - public function getWithDate($id, Carbon $date); + public function getWithDate($journalId, Carbon $date); /** * @param TransactionJournal $journal diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 4d87ad39b8..3b11fbebb6 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -57,7 +57,8 @@ class FireflyValidator extends Validator /** * @param $attribute * @param $value - * @param $parameters + * + * @return bool */ public function validateIban($attribute, $value) { @@ -200,9 +201,10 @@ class FireflyValidator extends Validator /** * @param $value - * @param $parameters * * @return bool + * @internal param $parameters + * */ protected function validateByAccountId($value) { diff --git a/tests/_support/Helper/Acceptance.php b/tests/_support/Helper/Acceptance.php index dde208237b..ee5062d3e6 100644 --- a/tests/_support/Helper/Acceptance.php +++ b/tests/_support/Helper/Acceptance.php @@ -3,6 +3,11 @@ namespace Helper; // here you can define custom actions // all public methods declared in helper class will be available in $I +/** + * Class Acceptance + * + * @package Helper + */ class Acceptance extends \Codeception\Module { diff --git a/tests/_support/Helper/Functional.php b/tests/_support/Helper/Functional.php index 34fbe73652..1bd97acc12 100644 --- a/tests/_support/Helper/Functional.php +++ b/tests/_support/Helper/Functional.php @@ -3,6 +3,11 @@ namespace Helper; // here you can define custom actions // all public methods declared in helper class will be available in $I +/** + * Class Functional + * + * @package Helper + */ class Functional extends \Codeception\Module { diff --git a/tests/_support/Helper/Unit.php b/tests/_support/Helper/Unit.php index 4862e82dd7..6c520ad7dc 100644 --- a/tests/_support/Helper/Unit.php +++ b/tests/_support/Helper/Unit.php @@ -3,6 +3,11 @@ namespace Helper; // here you can define custom actions // all public methods declared in helper class will be available in $I +/** + * Class Unit + * + * @package Helper + */ class Unit extends \Codeception\Module { diff --git a/tests/_support/_generated/AcceptanceTesterActions.php b/tests/_support/_generated/AcceptanceTesterActions.php index 2e30fdcee4..c11f2f30d5 100644 --- a/tests/_support/_generated/AcceptanceTesterActions.php +++ b/tests/_support/_generated/AcceptanceTesterActions.php @@ -8,6 +8,11 @@ namespace _generated; use Codeception\Module\PhpBrowser; use Helper\Acceptance; +/** + * Class AcceptanceTesterActions + * + * @package _generated + */ trait AcceptanceTesterActions { /** diff --git a/tests/_support/_generated/FunctionalTesterActions.php b/tests/_support/_generated/FunctionalTesterActions.php index 0d6c61fe91..293b5d56ef 100644 --- a/tests/_support/_generated/FunctionalTesterActions.php +++ b/tests/_support/_generated/FunctionalTesterActions.php @@ -7,6 +7,11 @@ namespace _generated; use Helper\Functional; +/** + * Class FunctionalTesterActions + * + * @package _generated + */ trait FunctionalTesterActions { /** diff --git a/tests/_support/_generated/UnitTesterActions.php b/tests/_support/_generated/UnitTesterActions.php index 32aa10351e..886e82ea5b 100644 --- a/tests/_support/_generated/UnitTesterActions.php +++ b/tests/_support/_generated/UnitTesterActions.php @@ -9,6 +9,11 @@ use Codeception\Module\Laravel5; use Codeception\Module\Asserts; use Helper\Unit; +/** + * Class UnitTesterActions + * + * @package _generated + */ trait UnitTesterActions { /** From bdf7eee72f3e7b25bce9a1276678ca0a259a5e28 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 7 Jul 2015 01:07:19 +0200 Subject: [PATCH 55/60] Clean up some code routines. --- .../Csv/Converter/AssetAccountIban.php | 48 ++++---- .../Csv/Converter/OpposingAccountIban.php | 29 +++-- .../Csv/PostProcessing/OpposingAccount.php | 105 +++++++++++++----- app/Http/Controllers/ReportController.php | 2 +- app/Validation/FireflyValidator.php | 7 ++ 5 files changed, 135 insertions(+), 56 deletions(-) diff --git a/app/Helpers/Csv/Converter/AssetAccountIban.php b/app/Helpers/Csv/Converter/AssetAccountIban.php index a2229bdc94..c928534663 100644 --- a/app/Helpers/Csv/Converter/AssetAccountIban.php +++ b/app/Helpers/Csv/Converter/AssetAccountIban.php @@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Csv\Converter; use Auth; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; -use Log; /** * Class AssetAccountIban @@ -28,31 +27,42 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface } if (strlen($this->value) > 0) { // find or create new account: + $account = $this->findAccount(); $accountType = AccountType::where('type', 'Asset account')->first(); - $set = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->get(['accounts.*']); - /** @var Account $entry */ - foreach ($set as $entry) { - if ($entry->iban == $this->value) { - Log::debug('AssetAccountIban::convert found an Account (#' . $entry->id . ': ' . $entry->name . ') with IBAN ' . $this->value); - return $entry; - } + if (is_null($account)) { + // create it if doesn't exist. + $account = Account::firstOrCreateEncrypted( + [ + 'name' => $this->value, + 'iban' => $this->value, + 'user_id' => Auth::user()->id, + 'account_type_id' => $accountType->id, + 'active' => 1, + ] + ); } - // create it if doesn't exist. - $account = Account::firstOrCreateEncrypted( - [ - 'name' => $this->value, - 'iban' => $this->value, - 'user_id' => Auth::user()->id, - 'account_type_id' => $accountType->id, - 'active' => 1, - ] - ); - return $account; } return null; } + + /** + * @return Account|null + */ + protected function findAccount() + { + $set = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->get(['accounts.*']); + /** @var Account $entry */ + foreach ($set as $entry) { + if ($entry->iban == $this->value) { + + return $entry; + } + } + + return null; + } } \ No newline at end of file diff --git a/app/Helpers/Csv/Converter/OpposingAccountIban.php b/app/Helpers/Csv/Converter/OpposingAccountIban.php index 92bad04d5e..ff615e2b82 100644 --- a/app/Helpers/Csv/Converter/OpposingAccountIban.php +++ b/app/Helpers/Csv/Converter/OpposingAccountIban.php @@ -27,18 +27,31 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface return $account; } else { if (strlen($this->value) > 0) { - $set = Auth::user()->accounts()->get(); - /** @var Account $account */ - foreach ($set as $account) { - if ($account->iban == $this->value) { - Log::debug('OpposingAccountIban::convert found an Account (#' . $account->id . ': ' . $account->name . ') with IBAN ' . $this->value); - - return $account; - } + $account = $this->findAccount(); + if (!is_null($account)) { + return $account; } } return $this->value; } } + + /** + * @return Account|null + */ + protected function findAccount() + { + $set = Auth::user()->accounts()->get(); + /** @var Account $account */ + foreach ($set as $account) { + if ($account->iban == $this->value) { + Log::debug('OpposingAccountIban::convert found an Account (#' . $account->id . ': ' . $account->name . ') with IBAN ' . $this->value); + + return $account; + } + } + + return null; + } } \ No newline at end of file diff --git a/app/Helpers/Csv/PostProcessing/OpposingAccount.php b/app/Helpers/Csv/PostProcessing/OpposingAccount.php index 55d3b67ea4..f7690438be 100644 --- a/app/Helpers/Csv/PostProcessing/OpposingAccount.php +++ b/app/Helpers/Csv/PostProcessing/OpposingAccount.php @@ -24,36 +24,19 @@ class OpposingAccount implements PostProcessorInterface */ public function process() { - if ($this->data['opposing-account-id'] instanceof Account) { // first priority. try to find the account based on ID, if any - $this->data['opposing-account-object'] = $this->data['opposing-account-id']; - - return $this->data; + $result = $this->checkIdNameObject(); + if (!is_null($result)) { + return $result; } - if ($this->data['opposing-account-iban'] instanceof Account) { // second: try to find the account based on IBAN, if any. - $this->data['opposing-account-object'] = $this->data['opposing-account-iban']; - return $this->data; + $result = $this->checkIbanString(); + if (!is_null($result)) { + return $result; } - $rules = ['iban' => 'iban']; - $check = ['iban' => $this->data['opposing-account-iban']]; - $validator = Validator::make($check, $rules); - $result = !$validator->fails(); - if (is_string($this->data['opposing-account-iban']) && strlen($this->data['opposing-account-iban']) > 0) { - if ($result) { - $this->data['opposing-account-object'] = $this->parseIbanString(); - return $this->data; - } - } - if ($this->data['opposing-account-name'] instanceof Account) { // third: try to find account based on name, if any. - $this->data['opposing-account-object'] = $this->data['opposing-account-name']; - - return $this->data; - } - if (is_string($this->data['opposing-account-name'])) { - $this->data['opposing-account-object'] = $this->parseNameString(); - - return $this->data; + $result = $this->checkNameString(); + if (!is_null($result)) { + return $result; } return null; @@ -67,20 +50,67 @@ class OpposingAccount implements PostProcessorInterface $this->data = $data; } + /** + * @return array + */ + protected function checkIdNameObject() + { + if ($this->data['opposing-account-id'] instanceof Account) { // first priority. try to find the account based on ID, if any + $this->data['opposing-account-object'] = $this->data['opposing-account-id']; + + return $this->data; + } + if ($this->data['opposing-account-iban'] instanceof Account) { // second: try to find the account based on IBAN, if any. + $this->data['opposing-account-object'] = $this->data['opposing-account-iban']; + + return $this->data; + } + + return null; + } + + /** + * @return array|null + */ + protected function checkIbanString() + { + $rules = ['iban' => 'iban']; + $check = ['iban' => $this->data['opposing-account-iban']]; + $validator = Validator::make($check, $rules); + if (!$validator->fails()) { + $this->data['opposing-account-object'] = $this->parseIbanString(); + + return $this->data; + } + + return null; + } + /** * @return Account|null */ protected function parseIbanString() { // create by name and/or iban. - $accountType = $this->getAccountType(); - $accounts = Auth::user()->accounts()->get(); + $accounts = Auth::user()->accounts()->get(); foreach ($accounts as $entry) { if ($entry->iban == $this->data['opposing-account-iban']) { return $entry; } } + $account = $this->createAccount(); + + return $account; + } + + /** + * @return Account|null + */ + protected function createAccount() + { + $accountType = $this->getAccountType(); + // create if not exists: $name = is_string($this->data['opposing-account-name']) && strlen($this->data['opposing-account-name']) > 0 ? $this->data['opposing-account-name'] : $this->data['opposing-account-iban']; @@ -117,6 +147,25 @@ class OpposingAccount implements PostProcessorInterface } } + /** + * @return array|null + */ + protected function checkNameString() + { + if ($this->data['opposing-account-name'] instanceof Account) { // third: try to find account based on name, if any. + $this->data['opposing-account-object'] = $this->data['opposing-account-name']; + + return $this->data; + } + if (is_string($this->data['opposing-account-name'])) { + $this->data['opposing-account-object'] = $this->parseNameString(); + + return $this->data; + } + + return null; + } + /** * @return Account|null */ diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 4ed436aabf..4d1ca65470 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -88,7 +88,7 @@ class ReportController extends Controller $budgets = $this->helper->getBudgetReport($start, $end, $shared); $categories = $this->helper->getCategoryReport($start, $end, $shared); $balance = $this->helper->getBalanceReport($start, $end, $shared); - $bills = $this->helper->getBillReport($start, $end, $shared); + $bills = $this->helper->getBillReport($start, $end); Session::flash('gaEventCategory', 'report'); Session::flash('gaEventAction', 'month'); diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 3b11fbebb6..faa07a5e49 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -62,6 +62,13 @@ class FireflyValidator extends Validator */ public function validateIban($attribute, $value) { + if (!is_string($value)) { + return false; + } + + if (strlen($value) === 0) { + return false; + } $value = strtoupper($value); if (strlen($value) < 6) { From 76a1b2cd51d987ac2f64cd98880934a84c301a8d Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 7 Jul 2015 09:46:19 +0200 Subject: [PATCH 56/60] Improve some search methods. --- app/Models/Account.php | 21 +++++++++++---------- app/Models/Budget.php | 10 +++++----- app/Models/Category.php | 11 ++++++----- app/Models/Tag.php | 13 ++++++------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/app/Models/Account.php b/app/Models/Account.php index 42bf226a20..6e64f4d853 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -74,11 +74,12 @@ class Account extends Model public static function firstOrCreateEncrypted(array $fields) { // everything but the name: - $query = Account::orderBy('id'); - foreach ($fields as $name => $value) { - if ($name != 'name' && $name != 'iban') { - $query->where($name, $value); - } + $query = Account::orderBy('id'); + $search = $fields; + unset($search['name'], $search['iban']); + + foreach ($search as $name => $value) { + $query->where($name, $value); } $set = $query->get(['accounts.*']); /** @var Account $account */ @@ -107,11 +108,11 @@ class Account extends Model public static function firstOrNullEncrypted(array $fields) { // everything but the name: - $query = Account::orderBy('id'); - foreach ($fields as $name => $value) { - if ($name != 'name') { - $query->where($name, $value); - } + $query = Account::orderBy('id'); + $search = $fields; + unset($search['name']); + foreach ($search as $name => $value) { + $query->where($name, $value); } $set = $query->get(['accounts.*']); /** @var Account $account */ diff --git a/app/Models/Budget.php b/app/Models/Budget.php index f6a8f9ec04..f631a0666f 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -48,11 +48,11 @@ class Budget extends Model public static function firstOrCreateEncrypted(array $fields) { // everything but the name: - $query = Budget::orderBy('id'); - foreach ($fields as $name => $value) { - if ($name != 'name') { - $query->where($name, $value); - } + $query = Budget::orderBy('id'); + $search = $fields; + unset($search['name']); + foreach ($search as $name => $value) { + $query->where($name, $value); } $set = $query->get(['budgets.*']); /** @var Budget $budget */ diff --git a/app/Models/Category.php b/app/Models/Category.php index dc4f7cbbff..e86cfb72e3 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -43,11 +43,12 @@ class Category extends Model public static function firstOrCreateEncrypted(array $fields) { // everything but the name: - $query = Category::orderBy('id'); - foreach ($fields as $name => $value) { - if ($name != 'name') { - $query->where($name, $value); - } + $query = Category::orderBy('id'); + $search = $fields; + unset($search['name']); + foreach ($search as $name => $value) { + $query->where($name, $value); + } $set = $query->get(['categories.*']); /** @var Category $category */ diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 637f93b2c4..73f23b7699 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -62,14 +62,13 @@ class Tag extends Model public static function firstOrCreateEncrypted(array $fields) { // everything but the tag: - if (isset($fields['tagMode'])) { - unset($fields['tagMode']); - } + unset($fields['tagMode']); + $search = $fields; + unset($search['name']); + $query = Tag::orderBy('id'); - foreach ($fields as $name => $value) { - if ($name != 'tag') { - $query->where($name, $value); - } + foreach ($search as $name => $value) { + $query->where($name, $value); } $set = $query->get(['tags.*']); /** @var Tag $tag */ From 3172bc90da1cb746ec40eb2174e8e4368d0d53b8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 7 Jul 2015 10:05:11 +0200 Subject: [PATCH 57/60] Some small fixes. --- app/Helpers/Csv/Wizard.php | 21 +++++++++++----- app/Helpers/Report/ReportQuery.php | 4 +--- .../Shared/ComponentRepository.php | 24 +++++-------------- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/app/Helpers/Csv/Wizard.php b/app/Helpers/Csv/Wizard.php index a443fa06f1..24dc382795 100644 --- a/app/Helpers/Csv/Wizard.php +++ b/app/Helpers/Csv/Wizard.php @@ -19,7 +19,6 @@ use Session; class Wizard implements WizardInterface { - /** * @param Reader $reader * @param array $map @@ -33,11 +32,12 @@ class Wizard implements WizardInterface /* * Loop over the CSV and collect mappable data: */ + $keys = array_keys($map); foreach ($reader as $index => $row) { - if (($hasHeaders && $index > 1) || !$hasHeaders) { + if ($this->useRow($hasHeaders, $index)) { // collect all map values - foreach ($map as $column => $irrelevant) { - // check if $irrelevant is mappable! + + foreach ($keys as $column) { $values[$column][] = $row[$column]; } } @@ -52,7 +52,6 @@ class Wizard implements WizardInterface return $values; } - /** * @param array $roles * @param mixed $map @@ -120,7 +119,6 @@ class Wizard implements WizardInterface return true; } - /** * @param array $map * @@ -168,4 +166,15 @@ class Wizard implements WizardInterface } + + /** + * @param bool $hasHeaders + * @param int $index + * + * @return bool + */ + protected function useRow($hasHeaders, $index) + { + return ($hasHeaders && $index > 1) || !$hasHeaders; + } } \ No newline at end of file diff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.php index 9d427e67c0..4d73653c9f 100644 --- a/app/Helpers/Report/ReportQuery.php +++ b/app/Helpers/Report/ReportQuery.php @@ -54,9 +54,7 @@ class ReportQuery implements ReportQueryInterface $query->where('transaction_types.type', 'Withdrawal'); // any withdrawal is fine. } $query->orderBy('transaction_journals.date'); - - // get everything - $data = $query->get( + $data = $query->get( // get everything ['transaction_journals.*', 'transaction_types.type', 'ac_to.name as name', 'ac_to.id as account_id', 'ac_to.encrypted as account_encrypted'] ); diff --git a/app/Repositories/Shared/ComponentRepository.php b/app/Repositories/Shared/ComponentRepository.php index e4187f9e58..c97019880a 100644 --- a/app/Repositories/Shared/ComponentRepository.php +++ b/app/Repositories/Shared/ComponentRepository.php @@ -26,9 +26,7 @@ class ComponentRepository */ protected function spentInPeriod($object, Carbon $start, Carbon $end, $shared = false) { - // we must cache this. - - $cache = new CacheProperties; + $cache = new CacheProperties; // we must cache this. $cache->addProperty($object->id); $cache->addProperty(get_class($object)); $cache->addProperty($start); @@ -40,21 +38,13 @@ class ComponentRepository return $cache->get(); // @codeCoverageIgnore } - - if ($shared === true) { - // shared is true. - // always ignore transfers between accounts! - $sum - = $object->transactionjournals() - ->transactionTypes(['Withdrawal']) - ->before($end)->after($start)->get(['transaction_journals.*'])->sum('amount'); - + if ($shared === true) { // shared is true: always ignore transfers between accounts! + $sum = $object->transactionjournals()->transactionTypes(['Withdrawal'])->before($end)->after($start) + ->get(['transaction_journals.*'])->sum('amount'); } else { // do something else, SEE budgets. // get all journals in this month where the asset account is NOT shared. - $sum = $object->transactionjournals() - ->before($end) - ->after($start) + $sum = $object->transactionjournals()->before($end)->after($start) ->transactionTypes(['Withdrawal']) ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') @@ -62,9 +52,7 @@ class ComponentRepository 'account_meta', function (JoinClause $join) { $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole'); } - ) - ->where('account_meta.data', '!=', '"sharedAsset"') - ->get(['transaction_journals.*'])->sum('amount'); + )->where('account_meta.data', '!=', '"sharedAsset"')->get(['transaction_journals.*'])->sum('amount'); } $cache->store($sum); From 5153591c8f810d0463c7bc3c19dbd68ff2dcdc96 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 7 Jul 2015 10:38:53 +0200 Subject: [PATCH 58/60] New version. --- config/firefly.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/firefly.php b/config/firefly.php index 49251d3e79..aa34693bf9 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -1,8 +1,8 @@ 'chartjs', // or 'chartjs' - 'version' => '3.4.6', + 'chart' => 'chartjs', + 'version' => '3.4.7', 'index_periods' => ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'], 'budget_periods' => ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'], 'csv_import_enabled' => true, From 3b73b416d54286cc59abb31749025024ce2103eb Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 7 Jul 2015 11:10:07 +0200 Subject: [PATCH 59/60] New read me. --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a601b48810..a3de7d2e42 100644 --- a/README.md +++ b/README.md @@ -61,19 +61,19 @@ Everything is organised: _Please note that everything in these screenshots is fictional and may not be realistic._ -![Index](https://i.nder.be/gdryw73q) +![Index](https://i.nder.be/c6hz06d3) -![Accounts](https://i.nder.be/hmpkq8q0) +![Accounts](https://i.nder.be/gzxxyz6n) -![Budgets](https://i.nder.be/cbq2n5g9) +![Budgets](https://i.nder.be/hhu3krqk) -![Reports 1](https://i.nder.be/cmwvqrds) +![Reports 1](https://i.nder.be/cc3yspf6) -![Reports 2](https://i.nder.be/cv4dqbp4) +![Reports 2](https://i.nder.be/h6fp7xkb) -![Bills](https://i.nder.be/gmkxqdw7) +![Bills](https://i.nder.be/c30zkcpv) -![Piggy banks](https://i.nder.be/cc5u6h3b) +![Piggy banks](https://i.nder.be/g20k0mdq) ## Running and installing From 43669648cef91869947c0303e008b6ea70a34f69 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 7 Jul 2015 11:10:13 +0200 Subject: [PATCH 60/60] New test data. --- database/seeds/TestDataSeeder.php | 160 ++++++++++++++++++++++++++---- 1 file changed, 141 insertions(+), 19 deletions(-) diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php index b187830979..cca8a151fd 100644 --- a/database/seeds/TestDataSeeder.php +++ b/database/seeds/TestDataSeeder.php @@ -7,6 +7,7 @@ use FireflyIII\Models\Budget; use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\Category; use FireflyIII\Models\PiggyBank; +use FireflyIII\Models\PiggyBankEvent; use FireflyIII\Models\Role; use FireflyIII\Models\Tag; use FireflyIII\Models\Transaction; @@ -45,6 +46,7 @@ class TestDataSeeder extends Seeder $this->createExpenseAccounts(); $this->createRevenueAccounts(); $this->createBills(); + $this->createPiggybanks(); // dates: $start = Carbon::now()->subyear()->startOfMonth(); @@ -213,6 +215,144 @@ class TestDataSeeder extends Seeder ); } + protected function createPiggybanks() + { + $account = $this->findAccount('Savings'); + + $camera = PiggyBank::create( + [ + 'account_id' => $account->id, + 'name' => 'New camera', + 'targetamount' => 1000, + 'startdate' => '2015-04-01', + 'reminder_skip' => 0, + 'remind_me' => 0, + 'order' => 1, + ] + ); + $repetition = $camera->piggyBankRepetitions()->first(); + $repetition->currentamount = 735; + $repetition->save(); + + // events: + PiggyBankEvent::create( + [ + 'piggy_bank_id' => $camera->id, + 'date' => '2015-05-01', + 'amount' => '245' + ] + ); + PiggyBankEvent::create( + [ + 'piggy_bank_id' => $camera->id, + 'date' => '2015-06-01', + 'amount' => '245' + ] + ); + PiggyBankEvent::create( + [ + 'piggy_bank_id' => $camera->id, + 'date' => '2015-07-01', + 'amount' => '245' + ] + ); + + + $phone = PiggyBank::create( + [ + 'account_id' => $account->id, + 'name' => 'New phone', + 'targetamount' => 600, + 'startdate' => '2015-04-01', + 'reminder_skip' => 0, + 'remind_me' => 0, + 'order' => 1, + ] + ); + $repetition = $phone->piggyBankRepetitions()->first(); + $repetition->currentamount = 333; + $repetition->save(); + + // events: + PiggyBankEvent::create( + [ + 'piggy_bank_id' => $phone->id, + 'date' => '2015-05-01', + 'amount' => '111' + ] + ); + PiggyBankEvent::create( + [ + 'piggy_bank_id' => $phone->id, + 'date' => '2015-06-01', + 'amount' => '111' + ] + ); + PiggyBankEvent::create( + [ + 'piggy_bank_id' => $phone->id, + 'date' => '2015-07-01', + 'amount' => '111' + ] + ); + + $couch = PiggyBank::create( + [ + 'account_id' => $account->id, + 'name' => 'New couch', + 'targetamount' => 500, + 'startdate' => '2015-04-01', + 'reminder_skip' => 0, + 'remind_me' => 0, + 'order' => 1, + ] + ); + $repetition = $couch->piggyBankRepetitions()->first(); + $repetition->currentamount = 120; + $repetition->save(); + + // events: + PiggyBankEvent::create( + [ + 'piggy_bank_id' => $couch->id, + 'date' => '2015-05-01', + 'amount' => '40' + ] + ); + PiggyBankEvent::create( + [ + 'piggy_bank_id' => $couch->id, + 'date' => '2015-06-01', + 'amount' => '40' + ] + ); + PiggyBankEvent::create( + [ + 'piggy_bank_id' => $couch->id, + 'date' => '2015-07-01', + 'amount' => '40' + ] + ); + } + + /** + * @param $name + * + * @return Account|null + */ + protected function findAccount($name) + { + /** @var Account $account */ + foreach (Account::get() as $account) { + if ($account->name == $name && $this->user->id == $account->user_id) { + return $account; + break; + } + } + + return null; + } + /** * @param $description * @param Carbon $date @@ -260,24 +400,6 @@ class TestDataSeeder extends Seeder } - /** - * @param $name - * - * @return Account|null - */ - protected function findAccount($name) - { - /** @var Account $account */ - foreach (Account::get() as $account) { - if ($account->name == $name && $this->user->id == $account->user_id) { - return $account; - break; - } - } - - return null; - } - /** * @param $description * @param Carbon $date @@ -593,7 +715,7 @@ class TestDataSeeder extends Seeder $journal = TransactionJournal::create( [ 'user_id' => $this->user->id, - 'transaction_type_id' => 2, + 'transaction_type_id' => 3, 'transaction_currency_id' => 1, 'description' => 'Save money', 'completed' => 1,
    {{ 'cvs_field_value'|_ }}{{ 'cvs_field_value'|_ }} {{ 'csv_field_mapped_to'|_ }}
    {{ value }}{{ value }} - {{ Form.select('mapping['~index~']['~value~']',options[index], mapped[index][value]) }} + {{ Form.select('mapping['~index~']['~value~']',options[index], mapped[index][value], {class: 'form-control'}) }}