Skip to content

Firefly III: a personal finances manager

Let's cancel these tests for now.

James Cole52656b25dae6
diff --git a/tests/Unit/Console/Commands/CreateExportTest.php b/tests/Unit/Console/Commands/CreateExportTest.php
deleted file mode 100644
index 79143e1ec3..0000000000
--- a/tests/Unit/Console/Commands/CreateExportTest.php
+++ /dev/null
@@ -1,184 +0,0 @@
-<?php
-/**
- * CreateExportTest.php
- * Copyright (c) 2018 [email protected]
- *
- * This file is part of Firefly III.
- *
- * Firefly III is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Firefly III is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Tests\Unit\Console\Commands;
-
-use FireflyIII\Export\ProcessorInterface;
-use FireflyIII\Models\ExportJob;
-use FireflyIII\Models\Preference;
-use FireflyIII\Repositories\Account\AccountRepositoryInterface;
-use FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
-use FireflyIII\Repositories\User\UserRepositoryInterface;
-use Illuminate\Support\Collection;
-use Mockery;
-use Preferences;
-use Storage;
-use Tests\TestCase;
-
-/**
- * Class CreateExportTest
- */
-class CreateExportTest extends TestCase
-{
-
- /**
- * @covers \FireflyIII\Console\Commands\CreateExport
- * @covers \FireflyIII\Console\Commands\VerifiesAccessToken
- */
- public function testBasic()
- {
- $journal = $this->user()->transactionJournals()->inRandomOrder()->first();
- $preference = new Preference;
- $preference->data = 'token';
- $job = new ExportJob;
- $job->key = 'export-' . random_int(1, 1000);
- $journalRepository = $this->mock(JournalRepositoryInterface::class);
- $userRepository = $this->mock(UserRepositoryInterface::class);
- $jobRepository = $this->mock(ExportJobRepositoryInterface::class);
- $accountRepository = $this->mock(AccountRepositoryInterface::class);
- $processor = $this->mock(ProcessorInterface::class);
-
- $journalRepository->shouldReceive('setUser')->once();
- $journalRepository->shouldReceive('first')->once()->andReturn($journal);
-
- Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token', null])->andReturn($preference)->once();
-
- $accountRepository->shouldReceive('setUser')->once();
- $accountRepository->shouldReceive('getAccountsByType')->andReturn(new Collection)->once();
-
- $jobRepository->shouldReceive('setUser')->once();
- $jobRepository->shouldReceive('create')->once()->andReturn($job);
-
- $userRepository->shouldReceive('findNull')->andReturn($this->user())->twice();
-
- $processor->shouldReceive('setSettings')->once();
- $processor->shouldReceive('collectJournals')->once();
- $processor->shouldReceive('exportJournals')->once();
- $processor->shouldReceive('convertJournals')->once();
- $processor->shouldReceive('collectAttachments')->once();
- $processor->shouldReceive('collectOldUploads')->once();
- $processor->shouldReceive('createZipFile')->once();
-
- $fakeNews = 'I am a zipfile';
- Storage::fake('export');
- Storage::disk('export')->put(sprintf('%s.zip', $job->key), $fakeNews);
- $output = $this->artisan(
- 'firefly:create-export',
- [
- '--user' => 1,
- '--token' => 'token',
- '--with_attachments' => true,
- '--with_uploads' => true,
-
- ]
- );
-
- Storage::disk('export')->delete(sprintf('%s.zip', $job->key));
- $this->assertEquals(0, $output);
- }
-
- /**
- * @covers \FireflyIII\Console\Commands\CreateExport
- * @covers \FireflyIII\Console\Commands\VerifiesAccessToken
- */
- public function testInvalidToken()
- {
- $preference = new Preference;
- $preference->data = 'token';
- $job = new ExportJob;
- $job->key = 'export-' . random_int(1, 1000);
- $userRepository = $this->mock(UserRepositoryInterface::class);
-
- Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token', null])->andReturn($preference)->once();
- $userRepository->shouldReceive('findNull')->andReturn($this->user())->once();
-
- $output = $this->artisan(
- 'firefly:create-export',
- [
- '--user' => 1,
- '--token' => 'wrong_token',
- '--with_attachments' => true,
- '--with_uploads' => true,
-
- ]
- );
- $this->assertEquals(1, $output);
- }
-
- /**
- * @covers \FireflyIII\Console\Commands\CreateExport
- * @covers \FireflyIII\Console\Commands\VerifiesAccessToken
- */
- public function testNoSuchUser()
- {
- $preference = new Preference;
- $preference->data = 'token';
- $job = new ExportJob;
- $job->key = 'export-' . random_int(1, 1000);
- $userRepository = $this->mock(UserRepositoryInterface::class);
-
- $userRepository->shouldReceive('findNull')->andReturn(null)->once();
-
- $output = $this->artisan(
- 'firefly:create-export',
- [
- '--user' => 0,
- '--token' => 'wrong_token',
- '--with_attachments' => true,
- '--with_uploads' => true,
-
- ]
- );
- $this->assertEquals(1, $output);
- }
-
- /**
- * @covers \FireflyIII\Console\Commands\CreateExport
- * @covers \FireflyIII\Console\Commands\VerifiesAccessToken
- */
- public function testNoToken()
- {
- $preference = new Preference;
- $preference->data = 'token';
- $job = new ExportJob;
- $job->key = 'export-' . random_int(1, 1000);
- $userRepository = $this->mock(UserRepositoryInterface::class);
-
- Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token', null])->andReturn(null)->once();
- $userRepository->shouldReceive('findNull')->andReturn($this->user())->once();
-
- $output = $this->artisan(
- 'firefly:create-export',
- [
- '--user' => 1,
- '--token' => 'wrong_token',
- '--with_attachments' => true,
- '--with_uploads' => true,
-
- ]
- );
- $this->assertEquals(1, $output);
- }
-
-}
diff --git a/tests/Unit/Console/Commands/CreateImportTest.php b/tests/Unit/Console/Commands/CreateImportTest.php
deleted file mode 100644
index 1934c3c14e..0000000000
--- a/tests/Unit/Console/Commands/CreateImportTest.php
+++ /dev/null
@@ -1,287 +0,0 @@
-<?php
-/**
- * CreateImportTest.php
- * Copyright (c) 2018 [email protected]
- *
- * This file is part of Firefly III.
- *
- * Firefly III is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Firefly III is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Tests\Unit\Console\Commands;
-
-
-use FireflyIII\Import\Routine\FileRoutine;
-use FireflyIII\Models\ImportJob;
-use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
-use FireflyIII\Repositories\User\UserRepositoryInterface;
-use FireflyIII\Services\Internal\File\EncryptService;
-use Illuminate\Support\Collection;
-use Storage;
-use Tests\TestCase;
-
-
-/**
- * TODO these tests don't seem to work on Travis CI.
- *
- * Class CreateImportTest
- */
-class CreateImportTest extends TestCase
-{
- /**
- * @covers \FireflyIII\Console\Commands\CreateImport
- * @covers \FireflyIII\Console\Commands\EncryptFile
- * @covers \FireflyIII\Console\Commands\VerifiesAccessToken
- */
- public function testBasic()
- {
- $jobRepos = $this->mock(ImportJobRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $encrypter = $this->mock(EncryptService::class);
- $routine = $this->mock(FileRoutine::class);
-
- $collection = new Collection();
- $collection->push('I am error');
-
- $job = new ImportJob;
- $job->key = 'import-' . random_int(1, 1000);
- $job->file_type = 'csv';
- $job->user = $this->user();
-
- $userRepos->shouldReceive('findNull')->andReturn($this->user())->times(2);
- $jobRepos->shouldReceive('setUser')->once();
- $jobRepos->shouldReceive('create')->once()->andReturn($job);
- $jobRepos->shouldReceive('setConfiguration')->once();
- $jobRepos->shouldReceive('updateStatus')->once();
- $encrypter->shouldReceive('encrypt')->once();
- $routine->shouldReceive('setJob')->once();
- $routine->shouldReceive('run')->once();
- $routine->shouldReceive('getErrors')->once()->andReturn($collection);
- $routine->shouldReceive('getJournals')->once()->andReturn(new Collection());
- $routine->shouldReceive('getLines')->once()->andReturn(7);
-
-
-
- Storage::fake('upload');
-
- $output = $this->artisan(
- 'firefly:create-import',
- [
- '--user' => 1,
- '--token' => 'token',
- 'file' => 'storage/build/test-upload.csv',
- 'configuration' => 'storage/build/test-upload.json',
- '--start' => true,
-
- ]
- );
-
- $this->assertTrue(true);
- }
-
- /**
- * @covers \FireflyIII\Console\Commands\CreateImport
- * @covers \FireflyIII\Console\Commands\EncryptFile
- * @covers \FireflyIII\Console\Commands\VerifiesAccessToken
- */
- public function testInvalidToken()
- {
- $jobRepos = $this->mock(ImportJobRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $encrypter = $this->mock(EncryptService::class);
- $routine = $this->mock(FileRoutine::class);
-
- $collection = new Collection();
- $collection->push('I am error');
-
- $job = new ImportJob;
- $job->key = 'import-' . random_int(1, 1000);
- $job->file_type = 'csv';
- $job->user = $this->user();
-
- $userRepos->shouldReceive('findNull')->andReturn($this->user())->times(1);
-
- Storage::fake('upload');
-
- $output = $this->artisan(
- 'firefly:create-import',
- [
- '--user' => 1,
- '--token' => 'tokenX',
- 'file' => 'storage/build/test-upload.csv',
- 'configuration' => 'storage/build/test-upload.json',
- '--start' => true,
-
- ]
- );
-
- $this->assertTrue(true);
- }
-
- /**
- * @covers \FireflyIII\Console\Commands\CreateImport
- * @covers \FireflyIII\Console\Commands\EncryptFile
- * @covers \FireflyIII\Console\Commands\VerifiesAccessToken
- */
- public function testInvalidType()
- {
- $jobRepos = $this->mock(ImportJobRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $encrypter = $this->mock(EncryptService::class);
- $routine = $this->mock(FileRoutine::class);
-
- $collection = new Collection();
- $collection->push('I am error');
-
- $job = new ImportJob;
- $job->key = 'import-' . random_int(1, 1000);
- $job->file_type = 'csv';
- $job->user = $this->user();
-
- $userRepos->shouldReceive('findNull')->andReturn($this->user())->times(2);
-
- $output = $this->artisan(
- 'firefly:create-import',
- [
- '--user' => 1,
- '--token' => 'token',
- '--type' => 'csvX',
- 'file' => 'storage/build/test-upload.csv',
- 'configuration' => 'storage/build/test-upload.json',
- '--start' => true,
-
- ]
- );
-
- $this->assertTrue(true);
- }
-
-
- /**
- * @covers \FireflyIII\Console\Commands\CreateImport
- * @covers \FireflyIII\Console\Commands\EncryptFile
- * @covers \FireflyIII\Console\Commands\VerifiesAccessToken
- */
- public function testInvalidJSON()
- {
- $jobRepos = $this->mock(ImportJobRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $encrypter = $this->mock(EncryptService::class);
- $routine = $this->mock(FileRoutine::class);
-
- $collection = new Collection();
- $collection->push('I am error');
-
- $job = new ImportJob;
- $job->key = 'import-' . random_int(1, 1000);
- $job->file_type = 'csv';
- $job->user = $this->user();
-
- $userRepos->shouldReceive('findNull')->andReturn($this->user())->times(2);
-
- $output = $this->artisan(
- 'firefly:create-import',
- [
- '--user' => 1,
- '--token' => 'token',
- '--type' => 'csv',
- 'file' => 'storage/build/test-upload.csv',
- 'configuration' => 'storage/build/test-upload.csv',
- '--start' => true,
-
- ]
- );
-
- $this->assertTrue(true);
- }
-
- /**
- * @covers \FireflyIII\Console\Commands\CreateImport
- * @covers \FireflyIII\Console\Commands\EncryptFile
- * @covers \FireflyIII\Console\Commands\VerifiesAccessToken
- */
- public function testFileNotFound()
- {
- $jobRepos = $this->mock(ImportJobRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $encrypter = $this->mock(EncryptService::class);
- $routine = $this->mock(FileRoutine::class);
-
- $collection = new Collection();
- $collection->push('I am error');
-
- $job = new ImportJob;
- $job->key = 'import-' . random_int(1, 1000);
- $job->file_type = 'csv';
- $job->user = $this->user();
-
- $userRepos->shouldReceive('findNull')->andReturn($this->user())->times(2);
-
- $output = $this->artisan(
- 'firefly:create-import',
- [
- '--user' => 1,
- '--token' => 'token',
- '--type' => 'csv',
- 'file' => 'storage/build/test-uploadX.csv',
- 'configuration' => 'storage/build/test-upload.json',
- '--start' => true,
-
- ]
- );
-
- $this->assertTrue(true);
- }
-
- /**
- * @covers \FireflyIII\Console\Commands\CreateImport
- * @covers \FireflyIII\Console\Commands\EncryptFile
- * @covers \FireflyIII\Console\Commands\VerifiesAccessToken
- */
- public function testConfigNotFound()
- {
- $jobRepos = $this->mock(ImportJobRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $encrypter = $this->mock(EncryptService::class);
- $routine = $this->mock(FileRoutine::class);
-
- $collection = new Collection();
- $collection->push('I am error');
-
- $job = new ImportJob;
- $job->key = 'import-' . random_int(1, 1000);
- $job->file_type = 'csv';
- $job->user = $this->user();
-
- $userRepos->shouldReceive('findNull')->andReturn($this->user())->times(2);
-
- $output = $this->artisan(
- 'firefly:create-import',
- [
- '--user' => 1,
- '--token' => 'token',
- '--type' => 'csv',
- 'file' => 'storage/build/test-upload.csv',
- 'configuration' => 'storage/build/test-uploadX.json',
- '--start' => true,
-
- ]
- );
-
- $this->assertTrue(true);
- }
-
-}