Files
firefly-iii/tests/acceptance/Controllers/Auth/TwoFactorControllerTest.php

83 lines
2.7 KiB
PHP
Raw Normal View History

2016-11-19 20:30:30 +01:00
<?php
2016-12-06 09:16:36 +01:00
/**
* 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.
*/
2016-11-19 20:30:30 +01:00
namespace Auth;
2016-11-20 11:43:19 +01:00
2016-12-09 18:53:13 +01:00
use FireflyIII\Models\Preference;
use FireflyIII\Support\Facades\Preferences;
use Google2FA;
2016-11-19 20:30:30 +01:00
use TestCase;
/**
2016-12-07 19:53:41 +01:00
* Generated by PHPUnit_SkeletonGenerator on 2016-12-07 at 18:50:32.
2016-11-19 20:30:30 +01:00
*/
class TwoFactorControllerTest extends TestCase
{
2016-11-20 07:24:18 +01:00
2016-11-19 20:30:30 +01:00
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
2016-11-20 08:30:25 +01:00
parent::setUp();
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\Auth\TwoFactorController::index
2016-11-26 08:55:26 +01:00
* Implement testIndex().
2016-11-19 20:30:30 +01:00
*/
public function testIndex()
{
2016-12-09 18:53:13 +01:00
$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);
//$has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret'));
$this->call('get', route('two-factor.index'));
$this->assertResponseStatus(200);
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\Auth\TwoFactorController::lostTwoFactor
2016-11-26 08:55:26 +01:00
* Implement testLostTwoFactor().
2016-11-19 20:30:30 +01:00
*/
public function testLostTwoFactor()
{
2016-12-09 18:53:13 +01:00
$this->be($this->user());
2016-11-19 20:30:30 +01:00
2016-12-09 18:53:13 +01:00
$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);
//$has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret'));
$this->call('get', route('two-factor.lost'));
$this->assertResponseStatus(200);
2016-11-19 20:30:30 +01:00
}
2016-11-20 11:43:19 +01:00
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
2016-11-19 20:30:30 +01:00
}