This fixes the tests.

This commit is contained in:
James Cole 2016-12-07 20:45:26 +01:00
parent da3988cc63
commit efe290d96c
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
4 changed files with 38 additions and 23 deletions

View File

@ -46,7 +46,12 @@ class IsConfirmed
return redirect()->guest('login');
}
// must the user be confirmed in the first place?
$mustConfirmAccount = FireflyConfig::get('must_confirm_account', config('firefly.configuration.must_confirm_account'))->data;
$confirmPreference = FireflyConfig::get('must_confirm_account', config('firefly.configuration.must_confirm_account'));
$mustConfirmAccount = false;
if (!is_null($confirmPreference)) {
$mustConfirmAccount = $confirmPreference->data;
}
// user must be logged in, then continue:
$isConfirmed = Preferences::get('user_confirmed', false)->data;

View File

@ -11,6 +11,8 @@
namespace Admin;
use FireflyIII\Models\Configuration;
use FireflyIII\Support\Facades\FireflyConfig;
use TestCase;
/**
@ -27,6 +29,8 @@ class ConfigurationControllerTest extends TestCase
public function setUp()
{
parent::setUp();
FireflyConfig::shouldReceive('get')->withArgs(['must_confirm_account', false])->once();
}
/**
@ -36,6 +40,17 @@ class ConfigurationControllerTest extends TestCase
public function testIndex()
{
$this->be($this->user());
$falseConfig = new Configuration;
$falseConfig->data = false;
$trueConfig = new Configuration;
$trueConfig->data = true;
FireflyConfig::shouldReceive('get')->withArgs(['single_user_mode', true])->once()->andReturn($trueConfig);
FireflyConfig::shouldReceive('get')->withArgs(['must_confirm_account', false])->once()->andReturn($falseConfig);
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
$this->call('GET', route('admin.configuration.index'));
$this->assertResponseStatus(200);
}
@ -46,14 +61,13 @@ class ConfigurationControllerTest extends TestCase
*/
public function testPostIndex()
{
FireflyConfig::shouldReceive('set')->withArgs(['single_user_mode', false])->once();
FireflyConfig::shouldReceive('set')->withArgs(['must_confirm_account', false])->once();
FireflyConfig::shouldReceive('set')->withArgs(['is_demo_site', false])->once();
$this->be($this->user());
$this->call('POST', route('admin.configuration.index.post'));
// mock FireflyConfig
\FireflyConfig::shouldReceive('get')->withArgs(['single_user_mode', false])->once();
\FireflyConfig::shouldReceive('get')->withArgs(['must_confirm_account', false])->once();
\FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once();
$this->assertSessionHas('success');
$this->assertResponseStatus(302);
}

View File

@ -35,10 +35,9 @@ class HomeControllerTest extends TestCase
*/
public function testIndex()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('GET', route('admin.index'));
$this->assertResponseStatus(200);
}
/**

View File

@ -35,10 +35,9 @@ class UserControllerTest extends TestCase
*/
public function testEdit()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('GET', route('admin.users.edit', [1]));
$this->assertResponseStatus(200);
}
/**
@ -47,10 +46,9 @@ class UserControllerTest extends TestCase
*/
public function testIndex()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('GET', route('admin.users'));
$this->assertResponseStatus(200);
}
/**
@ -59,10 +57,9 @@ class UserControllerTest extends TestCase
*/
public function testShow()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('GET', route('admin.users.edit', [1]));
$this->assertResponseStatus(200);
}
/**