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

160 lines
4.8 KiB
PHP
Raw Normal View History

2016-01-19 23:20:09 -06:00
<?php
/**
* BillControllerTest.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 BillControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\BillController::create
2016-02-04 00:30:48 -06:00
* @covers FireflyIII\Http\Controllers\BillController::__construct
2016-01-19 23:20:09 -06:00
*/
public function testCreate()
{
2016-01-20 08:27:53 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/bills/create');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\BillController::delete
*/
public function testDelete()
{
2016-01-20 08:27:53 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/bills/delete/1');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\BillController::destroy
*/
public function testDestroy()
{
2016-01-20 08:27:53 -06:00
$this->session(['bills.delete.url' => 'http://localhost']);
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('POST', '/bills/destroy/2');
2016-01-20 08:27:53 -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\BillController::edit
*/
public function testEdit()
{
2016-01-20 08:27:53 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/bills/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\BillController::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 08:27:53 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/bills');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\BillController::rescan
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testRescan($range)
2016-01-19 23:20:09 -06:00
{
2016-01-20 08:27:53 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/bills/rescan/1');
2016-01-20 08:27:53 -06:00
$this->assertSessionHas('success');
2016-01-24 11:11:57 -06:00
$this->assertResponseStatus(302);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\BillController::show
* @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 08:27:53 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/bills/show/1');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\BillController::store
2016-02-04 00:30:48 -06:00
* @covers FireflyIII\Http\Requests\BillFormRequest::authorize
* @covers FireflyIII\Http\Requests\BillFormRequest::getBillData
* @covers FireflyIII\Http\Requests\BillFormRequest::rules
2016-01-19 23:20:09 -06:00
*/
public function testStore()
{
2016-01-20 08:27:53 -06:00
$this->session(['bills.create.url' => 'http://localhost']);
$args = [
'name' => 'Some test',
'match' => 'words',
'amount_min' => 10,
'amount_max' => 100,
'amount_currency_id_amount_min' => 1,
'amount_currency_id_amount_max' => 1,
'date' => '20160101',
'repeat_freq' => 'monthly',
'skip' => 0,
];
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('POST', '/bills/store', $args);
2016-01-20 08:27:53 -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\BillController::update
2016-02-04 00:30:48 -06:00
* @covers FireflyIII\Http\Requests\BillFormRequest::authorize
* @covers FireflyIII\Http\Requests\BillFormRequest::getBillData
* @covers FireflyIII\Http\Requests\BillFormRequest::rules
2016-01-19 23:20:09 -06:00
*/
public function testUpdate()
{
2016-01-20 08:27:53 -06:00
$this->session(['bills.edit.url' => 'http://localhost']);
$args = [
'id' => 1,
'name' => 'Some test',
'match' => 'words',
'amount_min' => 10,
'amount_max' => 100,
'amount_currency_id_amount_min' => 1,
'amount_currency_id_amount_max' => 1,
'date' => '20160101',
'repeat_freq' => 'monthly',
'skip' => 0,
];
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('POST', '/bills/update/1', $args);
2016-01-20 08:27:53 -06:00
$this->assertSessionHas('success');
2016-01-24 11:11:57 -06:00
$this->assertResponseStatus(302);
2016-01-19 23:20:09 -06:00
}
}