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

131 lines
3.8 KiB
PHP
Raw Normal View History

2016-01-19 23:20:09 -06:00
<?php
/**
* CurrencyControllerTest.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:28.
*/
class CurrencyControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::create
2016-02-04 00:30:48 -06:00
* @covers FireflyIII\Http\Controllers\CurrencyController::__construct
2016-01-19 23:20:09 -06:00
*/
public function testCreate()
{
2016-01-23 09:48:34 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/currency/create');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::defaultCurrency
*/
public function testDefaultCurrency()
{
2016-01-23 09:48:34 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/currency/default/2');
$this->assertResponseStatus(302);
2016-01-23 09:48:34 -06:00
$this->assertRedirectedToRoute('currency.index');
$this->assertSessionHas('success');
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::delete
*/
public function testDelete()
{
2016-01-23 09:48:34 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/currency/delete/2');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::destroy
*/
public function testDestroy()
{
2016-01-23 09:48:34 -06:00
$this->session(['currency.delete.url' => 'http://localhost/currency']);
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('POST', '/currency/destroy/3');
2016-01-23 09:48:34 -06:00
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('currency.index');
2016-01-24 11:11:57 -06:00
$this->assertResponseStatus(302);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::edit
*/
public function testEdit()
{
2016-01-23 09:48:34 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/currency/edit/2');
$this->assertResponseStatus(200);
2016-01-23 09:48:34 -06:00
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::index
*/
public function testIndex($range)
2016-01-19 23:20:09 -06:00
{
2016-01-23 09:48:34 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/currency');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::store
2016-02-04 00:30:48 -06:00
* @covers FireflyIII\Http\Requests\CurrencyFormRequest::authorize
* @covers FireflyIII\Http\Requests\CurrencyFormRequest::rules
* @covers FireflyIII\Http\Requests\CurrencyFormRequest::getCurrencyData
2016-01-19 23:20:09 -06:00
*/
public function testStore()
{
2016-01-23 09:48:34 -06:00
$this->be($this->user());
$this->session(['currency.create.url' => 'http://localhost/currency']);
$args = [
'name' => 'New Euro.',
'symbol' => 'Y',
'code' => 'IUY',
];
2016-01-24 11:11:57 -06:00
$this->call('POST', '/currency/store', $args);
$this->assertResponseStatus(302);
2016-01-23 09:48:34 -06:00
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('currency.index');
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::update
2016-02-04 00:30:48 -06:00
* @covers FireflyIII\Http\Requests\CurrencyFormRequest::authorize
* @covers FireflyIII\Http\Requests\CurrencyFormRequest::rules
* @covers FireflyIII\Http\Requests\CurrencyFormRequest::getCurrencyData
2016-01-19 23:20:09 -06:00
*/
public function testUpdate()
{
2016-01-23 09:48:34 -06:00
$this->session(['currency.edit.url' => 'http://localhost/currency']);
$args = [
'id' => 1,
'name' => 'New Euro.',
'symbol' => 'Y',
'code' => 'IUY',
];
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('POST', '/currency/update/1', $args);
$this->assertResponseStatus(302);
2016-01-23 09:48:34 -06:00
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('currency.index');
2016-01-19 23:20:09 -06:00
}
}