Files
firefly-iii/tests/acceptance/Controllers/Admin/ConfigurationControllerTest.php
James Cole 7ea15761a6 Fix tests.
2016-12-26 09:50:37 +01:00

91 lines
3.6 KiB
PHP

<?php
/**
* ConfigurationControllerTest.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 Admin;
use FireflyIII\Models\Configuration;
use FireflyIII\Support\Facades\FireflyConfig;
use TestCase;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-12-07 at 18:50:31.
*/
class ConfigurationControllerTest 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();
FireflyConfig::shouldReceive('get')->withArgs(['must_confirm_account', false])->once();
}
/**
* @covers \FireflyIII\Http\Controllers\Admin\ConfigurationController::index
*/
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])->times(2)->andReturn($falseConfig);
// new settings:
FireflyConfig::shouldReceive('get')->withArgs(['mail_for_lockout', false])->once()->andReturn($falseConfig);
FireflyConfig::shouldReceive('get')->withArgs(['mail_for_blocked_domain', false])->once()->andReturn($falseConfig);
FireflyConfig::shouldReceive('get')->withArgs(['mail_for_blocked_email', false])->once()->andReturn($falseConfig);
FireflyConfig::shouldReceive('get')->withArgs(['mail_for_bad_login', false])->once()->andReturn($falseConfig);
FireflyConfig::shouldReceive('get')->withArgs(['mail_for_blocked_login', false])->once()->andReturn($falseConfig);
$this->call('GET', route('admin.configuration.index'));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\Admin\ConfigurationController::store
*/
public function testPostIndex()
{
$falseConfig = new Configuration;
$falseConfig->data = false;
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
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();
FireflyConfig::shouldReceive('set')->withArgs(['mail_for_lockout', false])->once();
FireflyConfig::shouldReceive('set')->withArgs(['mail_for_blocked_domain', false])->once();
FireflyConfig::shouldReceive('set')->withArgs(['mail_for_blocked_email', false])->once();
FireflyConfig::shouldReceive('set')->withArgs(['mail_for_bad_login', false])->once();
FireflyConfig::shouldReceive('set')->withArgs(['mail_for_blocked_login', false])->once();
$this->be($this->user());
$this->call('POST', route('admin.configuration.index.post'));
$this->assertSessionHas('success');
$this->assertResponseStatus(302);
}
}