Files
firefly-iii/tests/acceptance/Controllers/AttachmentControllerTest.php
James Cole dc28ba42ef More tests
2016-12-11 13:28:13 +01:00

117 lines
3.3 KiB
PHP

<?php
/**
* AttachmentControllerTest.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.
*/
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-12-10 at 05:51:38.
*/
class AttachmentControllerTest 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();
}
/**
* @covers \FireflyIII\Http\Controllers\AttachmentController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', route('attachments.delete', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\AttachmentController::destroy
*/
public function testDestroy()
{
$this->session(['attachments.delete.url' => 'http://localhost']);
$repository = $this->mock(AttachmentRepositoryInterface::class);
$repository->shouldReceive('destroy')->andReturn(true);
$this->be($this->user());
$this->call('post', route('attachments.destroy', [1]));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\AttachmentController::download
*/
public function testDownload()
{
$this->be($this->user());
$this->call('GET', route('attachments.download', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('This is attachment number one.');
}
/**
* @covers \FireflyIII\Http\Controllers\AttachmentController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', route('attachments.edit', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\AttachmentController::preview
*/
public function testPreview()
{
$this->be($this->user());
$this->call('GET', route('attachments.preview', [1]));
$this->assertResponseStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\AttachmentController::update
*/
public function testUpdate()
{
$this->session(['attachments.edit.url' => 'http://localhost']);
$data = [
'title' => 'Some updated title ' . rand(1000, 9999),
'notes' => '',
'description' => '',
];
$this->be($this->user());
$this->call('post', route('attachments.update', [1]), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
// view should be updated
$this->be($this->user());
$this->call('GET', route('attachments.edit', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
$this->see($data['title']);
}
}