This fixes the tests.

This commit is contained in:
James Cole
2016-12-07 20:45:26 +01:00
parent da3988cc63
commit efe290d96c
4 changed files with 38 additions and 23 deletions

View File

@@ -46,7 +46,12 @@ class IsConfirmed
return redirect()->guest('login'); return redirect()->guest('login');
} }
// must the user be confirmed in the first place? // 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: // user must be logged in, then continue:
$isConfirmed = Preferences::get('user_confirmed', false)->data; $isConfirmed = Preferences::get('user_confirmed', false)->data;

View File

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

View File

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

View File

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