mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 19:01:58 +00:00
71 lines
2.3 KiB
PHP
71 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* TwoFactorControllerTest.php
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
*
|
|
* This software may be modified and distributed under the terms of the
|
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
|
*
|
|
* See the LICENSE file for details.
|
|
*/
|
|
|
|
namespace Auth;
|
|
|
|
use FireflyIII\Models\Preference;
|
|
use FireflyIII\Support\Facades\Preferences;
|
|
use TestCase;
|
|
|
|
/**
|
|
* Generated by PHPUnit_SkeletonGenerator on 2016-12-07 at 18:50:32.
|
|
*/
|
|
class TwoFactorControllerTest extends TestCase
|
|
{
|
|
|
|
|
|
/**
|
|
* Sets up the fixture, for example, opens a network connection.
|
|
* This method is called before a test is executed.
|
|
*/
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
}
|
|
|
|
/**
|
|
* @covers \FireflyIII\Http\Controllers\Auth\TwoFactorController::index
|
|
*/
|
|
public function testIndex()
|
|
{
|
|
$this->be($this->user());
|
|
|
|
$falsePreference = new Preference;
|
|
$falsePreference->data = true;
|
|
$secretPreference = new Preference;
|
|
$secretPreference->data = 'BlablaSeecret';
|
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($falsePreference);
|
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference);
|
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference);
|
|
$this->call('get', route('two-factor.index'));
|
|
$this->assertResponseStatus(200);
|
|
}
|
|
|
|
/**
|
|
* @covers \FireflyIII\Http\Controllers\Auth\TwoFactorController::lostTwoFactor
|
|
*/
|
|
public function testLostTwoFactor()
|
|
{
|
|
$this->be($this->user());
|
|
|
|
$truePreference = new Preference;
|
|
$truePreference->data = true;
|
|
$secretPreference = new Preference;
|
|
$secretPreference->data = 'BlablaSeecret';
|
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($truePreference);
|
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference);
|
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference);
|
|
$this->call('get', route('two-factor.lost'));
|
|
$this->assertResponseStatus(200);
|
|
}
|
|
|
|
}
|