Expanded test coverage.

This commit is contained in:
James Cole
2017-03-24 15:01:53 +01:00
parent 222b3008d5
commit fe66d089ad
20 changed files with 357 additions and 149 deletions

View File

@@ -7,14 +7,12 @@
* See the LICENSE file for details.
*/
declare(strict_types = 1);
declare(strict_types=1);
namespace Tests\Feature\Controllers\Admin;
use FireflyIII\Models\Preference;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Support\Facades\Preferences;
use Illuminate\Support\Collection;
use Tests\TestCase;
@@ -60,14 +58,43 @@ class UserControllerTest extends TestCase
public function testShow()
{
$repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('getUserData')->andReturn([]);
$repository->shouldReceive('getUserData')->andReturn(
[
'export_jobs_success' => 0,
'import_jobs_success' => 0,
'attachments_size' => 0,
]
);
$this->be($this->user());
$response = $this->get(route('admin.users.edit', [1]));
$response = $this->get(route('admin.users.show', [1]));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\Admin\UserController::update
*/
public function testUpdate()
{
$repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('changePassword')->once();
$repository->shouldReceive('changeStatus')->once();
$data = [
'id' => 1,
'email' => 'test@example.com',
'password' => 'james',
'password_confirmation' => 'james',
'blocked_code' => 'blocked',
'blocked' => 1,
];
$this->be($this->user());
$response = $this->post(route('admin.users.update', ['1']), $data);
$response->assertStatus(302);
$response->assertSessionHas('success');
}
}