mock(JournalRepositoryInterface::class);
$google = $this->mock(Google2FA::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$google->shouldReceive('generateSecretKey')->andReturn('secret');
$google->shouldReceive('getQRCodeInline')->andReturn('long-data-url');
$this->be($this->user());
$response = $this->get(route('preferences.code'));
$response->assertStatus(200);
$response->assertSee('
');
}
/**
* @covers \FireflyIII\Http\Controllers\PreferencesController::deleteCode
*/
public function testDeleteCode()
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('preferences.delete-code'));
$response->assertStatus(302);
$response->assertSessionHas('success');
$response->assertSessionHas('info');
$response->assertRedirect(route('preferences.index'));
}
/**
* @covers \FireflyIII\Http\Controllers\PreferencesController::index
* @covers \FireflyIII\Http\Controllers\PreferencesController::__construct
*/
public function testIndex()
{
// mock stuff
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection)->once();
$this->be($this->user());
$response = $this->get(route('preferences.index'));
$response->assertStatus(200);
$response->assertSee('');
}
/**
* @covers \FireflyIII\Http\Controllers\PreferencesController::postIndex
*/
public function testPostIndex()
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$data = [
'fiscalYearStart' => '2016-01-01',
'frontPageAccounts' => [],
'viewRange' => '1M',
'customFiscalYear' => 0,
'showDepositsFrontpage' => 0,
'transactionPageSize' => 100,
'twoFactorAuthEnabled' => 0,
'language' => 'en_US',
'tj' => [],
];
$this->be($this->user());
$response = $this->post(route('preferences.update'), $data);
$response->assertStatus(302);
$response->assertSessionHas('success');
$response->assertRedirect(route('preferences.index'));
}
}