. */ declare(strict_types=1); namespace Tests\Feature\Controllers\Transaction; use DB; use FireflyIII\Events\StoredTransactionJournal; use FireflyIII\Events\UpdatedTransactionJournal; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Models\AccountType; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Collection; use Illuminate\Support\MessageBag; use Steam; use Tests\TestCase; /** * Class SingleControllerTest * * @SuppressWarnings(PHPMD.TooManyPublicMethods) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class SingleControllerTest extends TestCase { /** * @covers \FireflyIII\Http\Controllers\Transaction\SingleController::cloneTransaction */ public function testCloneTransaction() { $this->be($this->user()); $withdrawal = TransactionJournal::where('transaction_type_id', 1)->whereNull('deleted_at')->where('user_id', $this->user()->id)->first(); $response = $this->get(route('transactions.clone', [$withdrawal->id])); $response->assertStatus(302); } /** * @covers \FireflyIII\Http\Controllers\Transaction\SingleController::create * @covers \FireflyIII\Http\Controllers\Transaction\SingleController::__construct */ public function testCreate() { Steam::shouldReceive('phpBytes')->andReturn(2048); $repository = $this->mock(AccountRepositoryInterface::class); $repository->shouldReceive('getActiveAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection); $budgetRepos = $this->mock(BudgetRepositoryInterface::class); $budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection)->once(); $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class); $piggyRepos->shouldReceive('getPiggyBanksWithAmount')->andReturn(new Collection)->once(); $this->be($this->user()); $response = $this->get(route('transactions.create', ['withdrawal'])); $response->assertStatus(200); // has bread crumb $response->assertSee('