firefly-iii/tests/acceptance/Controllers/CategoryControllerTest.php

157 lines
4.4 KiB
PHP
Raw Normal View History

2016-01-19 23:20:09 -06:00
<?php
/**
* CategoryControllerTest.php
* Copyright (C) 2016 Sander Dorigo
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:27.
*/
class CategoryControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\CategoryController::create
2016-02-04 00:30:48 -06:00
* @covers FireflyIII\Http\Controllers\CategoryController::__construct
2016-01-19 23:20:09 -06:00
*/
public function testCreate()
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/categories/create');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::delete
*/
public function testDelete()
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/categories/delete/1');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::destroy
*/
public function testDestroy()
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->session(['categories.delete.url' => 'http://localhost']);
2016-01-24 11:11:57 -06:00
$this->call('POST', '/categories/destroy/2');
2016-01-20 09:15:23 -06:00
$this->assertSessionHas('success');
2016-01-24 11:11:57 -06:00
$this->assertResponseStatus(302);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::edit
*/
public function testEdit()
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/categories/edit/1');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\CategoryController::index
* @dataProvider dateRangeProvider
*
2016-02-05 08:41:40 -06:00
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testIndex($range)
2016-01-19 23:20:09 -06:00
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/categories');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\CategoryController::noCategory
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testNoCategory($range)
2016-01-19 23:20:09 -06:00
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/categories/list/noCategory');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\CategoryController::show
* @covers FireflyIII\Http\Controllers\Controller::getSumOfRange
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testShow($range)
2016-01-19 23:20:09 -06:00
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/categories/show/1');
$this->assertResponseStatus(200);
2016-01-20 09:15:23 -06:00
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\CategoryController::showWithDate
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testShowWithDate($range)
2016-01-19 23:20:09 -06:00
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/categories/show/1/20150101');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::store
2016-02-04 00:30:48 -06:00
* @covers FireflyIII\Http\Requests\CategoryFormRequest::authorize
* @covers FireflyIII\Http\Requests\CategoryFormRequest::rules
2016-01-19 23:20:09 -06:00
*/
public function testStore()
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->session(['categories.create.url' => 'http://localhost']);
$args = [
2016-02-04 00:30:48 -06:00
'name' => 'Some kind of test cat.',
2016-01-20 09:15:23 -06:00
];
2016-01-24 11:11:57 -06:00
$this->call('POST', '/categories/store', $args);
$this->assertResponseStatus(302);
2016-01-20 09:15:23 -06:00
$this->assertSessionHas('success');
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::update
2016-02-04 00:30:48 -06:00
* @covers FireflyIII\Http\Requests\CategoryFormRequest::authorize
* @covers FireflyIII\Http\Requests\CategoryFormRequest::rules
2016-01-19 23:20:09 -06:00
*/
public function testUpdate()
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->session(['categories.edit.url' => 'http://localhost']);
$args = [
2016-02-04 00:30:48 -06:00
'name' => 'Some kind of test category.',
'id' => 1,
2016-01-20 09:15:23 -06:00
];
2016-01-24 11:11:57 -06:00
$this->call('POST', '/categories/update/1', $args);
$this->assertResponseStatus(302);
2016-01-20 09:15:23 -06:00
$this->assertSessionHas('success');
2016-01-19 23:20:09 -06:00
}
}