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

220 lines
6.4 KiB
PHP
Raw Normal View History

2016-11-19 20:30:30 +01:00
<?php
2016-12-06 09:16:36 +01:00
/**
* PiggyBankControllerTest.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-18 17:54:11 +01:00
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
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:42.
2016-11-19 20:30:30 +01:00
*/
class PiggyBankControllerTest 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\PiggyBankController::add
2016-11-19 20:30:30 +01:00
*/
public function testAdd()
{
2016-12-18 17:54:11 +01:00
$this->be($this->user());
$this->call('get', route('piggy-banks.add', [1]));
$this->assertResponseStatus(200);
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\PiggyBankController::addMobile
2016-11-19 20:30:30 +01:00
*/
public function testAddMobile()
{
2016-12-18 17:54:11 +01:00
$this->be($this->user());
$this->call('get', route('piggy-banks.add-money-mobile', [1]));
$this->assertResponseStatus(200);
$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\PiggyBankController::create
2016-11-19 20:30:30 +01:00
*/
public function testCreate()
{
2016-12-18 17:54:11 +01:00
$this->be($this->user());
$this->call('get', route('piggy-banks.create'));
$this->assertResponseStatus(200);
$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\PiggyBankController::delete
2016-11-19 20:30:30 +01:00
*/
public function testDelete()
{
2016-12-18 17:54:11 +01:00
$this->be($this->user());
$this->call('get', route('piggy-banks.delete', [1]));
$this->assertResponseStatus(200);
$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\PiggyBankController::destroy
2016-11-19 20:30:30 +01:00
*/
public function testDestroy()
{
2016-12-18 17:54:11 +01:00
$repository = $this->mock(PiggyBankRepositoryInterface::class);
$repository->shouldReceive('destroy')->andReturn(true);
$this->session(['piggy-banks.delete.url' => 'http://localhost']);
$this->be($this->user());
$this->call('post', route('piggy-banks.destroy', [2]));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('index');
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\PiggyBankController::edit
2016-11-19 20:30:30 +01:00
*/
public function testEdit()
{
2016-12-18 17:54:11 +01:00
$this->be($this->user());
$this->call('get', route('piggy-banks.edit', [1]));
$this->assertResponseStatus(200);
$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\PiggyBankController::index
2016-11-19 20:30:30 +01:00
*/
public function testIndex()
{
2016-12-18 17:54:11 +01:00
$this->be($this->user());
$this->call('get', route('piggy-banks.index'));
$this->assertResponseStatus(200);
$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\PiggyBankController::order
2016-11-19 20:30:30 +01:00
*/
public function testOrder()
{
2016-12-18 17:54:11 +01:00
$this->be($this->user());
$this->call('post', route('piggy-banks.order', [1, 2]));
$this->assertResponseStatus(200);
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\PiggyBankController::postAdd
2016-11-19 20:30:30 +01:00
*/
public function testPostAdd()
{
2016-12-18 17:54:11 +01:00
$data = ['amount' => 1];
$this->be($this->user());
$this->call('post', route('piggy-banks.add', [1]), $data);
$this->assertResponseStatus(302);
$this->assertRedirectedToRoute('piggy-banks.index');
$this->assertSessionHas('success');
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\PiggyBankController::postRemove
2016-11-19 20:30:30 +01:00
*/
public function testPostRemove()
{
2016-12-18 17:54:11 +01:00
$data = ['amount' => 1];
$this->be($this->user());
$this->call('post', route('piggy-banks.remove', [1]), $data);
$this->assertResponseStatus(302);
$this->assertRedirectedToRoute('piggy-banks.index');
$this->assertSessionHas('success');
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\PiggyBankController::remove
2016-11-19 20:30:30 +01:00
*/
public function testRemove()
{
2016-12-18 17:54:11 +01:00
$this->be($this->user());
$this->call('get', route('piggy-banks.remove', [1]));
$this->assertResponseStatus(200);
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\PiggyBankController::removeMobile
2016-11-19 20:30:30 +01:00
*/
public function testRemoveMobile()
{
2016-12-18 17:54:11 +01:00
$this->be($this->user());
$this->call('get', route('piggy-banks.remove-money-mobile', [1]));
$this->assertResponseStatus(200);
$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\PiggyBankController::show
2016-11-19 20:30:30 +01:00
*/
public function testShow()
{
2016-12-18 17:54:11 +01:00
$this->be($this->user());
$this->call('get', route('piggy-banks.show', [1]));
$this->assertResponseStatus(200);
$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\PiggyBankController::store
2016-11-19 20:30:30 +01:00
*/
public function testStore()
{
2016-12-18 17:54:11 +01:00
$this->session(['piggy-banks.create.url' => 'http://localhost']);
$data = [
'name' => 'Piggy ' . rand(999, 10000),
'targetamount' => 100,
'account_id' => 2,
'amount_currency_id_targetamount' => 1,
];
$this->be($this->user());
$this->call('post', route('piggy-banks.store'), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('index');
2016-11-19 20:30:30 +01:00
}
/**
2016-12-07 19:53:41 +01:00
* @covers \FireflyIII\Http\Controllers\PiggyBankController::update
2016-11-19 20:30:30 +01:00
*/
public function testUpdate()
{
2016-12-18 17:54:11 +01:00
$this->session(['piggy-banks.edit.url' => 'http://localhost']);
$data = [
'name' => 'Updated Piggy ' . rand(999, 10000),
'targetamount' => 100,
'account_id' => 2,
'amount_currency_id_targetamount' => 1,
];
$this->be($this->user());
$this->call('post', route('piggy-banks.update', [3]), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('index');
2016-11-19 20:30:30 +01:00
}
2016-12-10 06:54:50 +01:00
2016-11-19 20:30:30 +01:00
}