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

139 lines
3.9 KiB
PHP
Raw Normal View History

2016-11-19 20:30:30 +01:00
<?php
2016-12-06 09:16:36 +01:00
/**
* CurrencyControllerTest.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.
*/
2016-12-11 16:25:46 +01:00
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
2016-11-19 20:30:30 +01:00
/**
2016-12-10 06:54:50 +01:00
* Generated by PHPUnit_SkeletonGenerator on 2016-12-10 at 05:51:41.
2016-11-19 20:30:30 +01:00
*/
class CurrencyControllerTest extends TestCase
{
2016-11-20 07:24:18 +01:00
2016-11-19 20:30:30 +01:00
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
2016-11-20 08:30:25 +01:00
parent::setUp();
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\CurrencyController::create
2016-11-19 20:30:30 +01:00
*/
public function testCreate()
{
2016-12-11 16:02:15 +01:00
$this->be($this->user());
$this->call('GET', route('currencies.create'));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\CurrencyController::defaultCurrency
2016-11-19 20:30:30 +01:00
*/
public function testDefaultCurrency()
{
2016-12-11 16:25:46 +01:00
$this->be($this->user());
$this->call('GET', route('currencies.default', [1]));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\CurrencyController::delete
2016-11-19 20:30:30 +01:00
*/
public function testDelete()
{
2016-12-11 16:02:15 +01:00
$this->be($this->user());
$this->call('GET', route('currencies.delete', [2]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\CurrencyController::destroy
2016-11-19 20:30:30 +01:00
*/
public function testDestroy()
{
2016-12-11 16:25:46 +01:00
$this->session(['currencies.delete.url' => 'http://localhost']);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$repository->shouldReceive('canDeleteCurrency')->andReturn(true);
$repository->shouldReceive('destroy')->andReturn(true);
$this->be($this->user());
$this->call('post', route('currencies.destroy', [1]));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\CurrencyController::edit
2016-11-19 20:30:30 +01:00
*/
public function testEdit()
{
2016-12-11 16:02:15 +01:00
$this->be($this->user());
$this->call('GET', route('currencies.edit', [2]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\CurrencyController::index
2016-11-19 20:30:30 +01:00
*/
public function testIndex()
{
2016-12-11 16:02:15 +01:00
$this->be($this->user());
$this->call('GET', route('currencies.index'));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\CurrencyController::store
2016-11-19 20:30:30 +01:00
*/
public function testStore()
{
2016-12-11 16:25:46 +01:00
$this->session(['currencies.create.url' => 'http://localhost']);
$data = [
'name' => 'XX',
'code' => 'XXX',
'symbol' => 'x',
];
$this->be($this->user());
$this->call('post', route('currencies.store'), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\CurrencyController::update
2016-11-19 20:30:30 +01:00
*/
public function testUpdate()
{
2016-12-11 16:25:46 +01:00
$this->session(['currencies.edit.url' => 'http://localhost']);
$data = [
'name' => 'XA',
'code' => 'XAX',
'symbol' => 'a',
];
$this->be($this->user());
$this->call('post', route('currencies.update', [2]), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
2016-11-19 20:30:30 +01:00
}
}