. */ declare(strict_types=1); namespace Tests\Feature\Controllers\Transaction; use Amount; use DB; use Exception; use FireflyIII\Events\StoredTransactionJournal; use FireflyIII\Events\UpdatedTransactionJournal; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Models\AccountType; use FireflyIII\Models\Note; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Collection; use Illuminate\Support\MessageBag; use Log; use Steam; use Tests\TestCase; /** * Class SingleControllerTest * * @SuppressWarnings(PHPMD.TooManyPublicMethods) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class SingleControllerTest extends TestCase { /** * */ public function setUp() { parent::setUp(); Log::debug(sprintf('Now in %s.', get_class($this))); } /** * @covers \FireflyIII\Http\Controllers\Transaction\SingleController::cloneTransaction */ public function testCloneTransaction() { $accountRepos = $this->mock(AccountRepositoryInterface::class); $budgetRepos = $this->mock(BudgetRepositoryInterface::class); $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class); $attRepos = $this->mock(AttachmentHelperInterface::class); $currencyRepos = $this->mock(CurrencyRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); $account = $this->user()->accounts()->first(); $journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account])); $journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account])); $journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0); $journalRepos->shouldReceive('getJournalCategoryName')->andReturn(''); $journalRepos->shouldReceive('getTags')->andReturn([]); $note = new Note(); $note->id = 5; $note->text = 'I see you...'; $journalRepos->shouldReceive('getNote')->andReturn($note)->once(); $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() { $accountRepos = $this->mock(AccountRepositoryInterface::class); $budgetRepos = $this->mock(BudgetRepositoryInterface::class); $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class); $attRepos = $this->mock(AttachmentHelperInterface::class); $currencyRepos = $this->mock(CurrencyRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); Steam::shouldReceive('phpBytes')->andReturn(2048); $budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection)->once(); $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('