mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 18:54:58 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			220 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			220 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * 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.
 | |
|  */
 | |
| use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
 | |
| 
 | |
| 
 | |
| /**
 | |
|  * Generated by PHPUnit_SkeletonGenerator on 2016-12-10 at 05:51:42.
 | |
|  */
 | |
| class PiggyBankControllerTest extends TestCase
 | |
| {
 | |
| 
 | |
| 
 | |
|     /**
 | |
|      * Sets up the fixture, for example, opens a network connection.
 | |
|      * This method is called before a test is executed.
 | |
|      */
 | |
|     public function setUp()
 | |
|     {
 | |
|         parent::setUp();
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::add
 | |
|      */
 | |
|     public function testAdd()
 | |
|     {
 | |
|         $this->be($this->user());
 | |
|         $this->call('get', route('piggy-banks.add', [1]));
 | |
|         $this->assertResponseStatus(200);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::addMobile
 | |
|      */
 | |
|     public function testAddMobile()
 | |
|     {
 | |
|         $this->be($this->user());
 | |
|         $this->call('get', route('piggy-banks.add-money-mobile', [1]));
 | |
|         $this->assertResponseStatus(200);
 | |
|         $this->see('<ol class="breadcrumb">');
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::create
 | |
|      */
 | |
|     public function testCreate()
 | |
|     {
 | |
|         $this->be($this->user());
 | |
|         $this->call('get', route('piggy-banks.create'));
 | |
|         $this->assertResponseStatus(200);
 | |
|         $this->see('<ol class="breadcrumb">');
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::delete
 | |
|      */
 | |
|     public function testDelete()
 | |
|     {
 | |
|         $this->be($this->user());
 | |
|         $this->call('get', route('piggy-banks.delete', [1]));
 | |
|         $this->assertResponseStatus(200);
 | |
|         $this->see('<ol class="breadcrumb">');
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::destroy
 | |
|      */
 | |
|     public function testDestroy()
 | |
|     {
 | |
|         $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');
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::edit
 | |
|      */
 | |
|     public function testEdit()
 | |
|     {
 | |
|         $this->be($this->user());
 | |
|         $this->call('get', route('piggy-banks.edit', [1]));
 | |
|         $this->assertResponseStatus(200);
 | |
|         $this->see('<ol class="breadcrumb">');
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::index
 | |
|      */
 | |
|     public function testIndex()
 | |
|     {
 | |
|         $this->be($this->user());
 | |
|         $this->call('get', route('piggy-banks.index'));
 | |
|         $this->assertResponseStatus(200);
 | |
|         $this->see('<ol class="breadcrumb">');
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::order
 | |
|      */
 | |
|     public function testOrder()
 | |
|     {
 | |
|         $this->be($this->user());
 | |
|         $this->call('post', route('piggy-banks.order', [1, 2]));
 | |
|         $this->assertResponseStatus(200);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::postAdd
 | |
|      */
 | |
|     public function testPostAdd()
 | |
|     {
 | |
|         $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');
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::postRemove
 | |
|      */
 | |
|     public function testPostRemove()
 | |
|     {
 | |
|         $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');
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::remove
 | |
|      */
 | |
|     public function testRemove()
 | |
|     {
 | |
|         $this->be($this->user());
 | |
|         $this->call('get', route('piggy-banks.remove', [1]));
 | |
|         $this->assertResponseStatus(200);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::removeMobile
 | |
|      */
 | |
|     public function testRemoveMobile()
 | |
|     {
 | |
|         $this->be($this->user());
 | |
|         $this->call('get', route('piggy-banks.remove-money-mobile', [1]));
 | |
|         $this->assertResponseStatus(200);
 | |
|         $this->see('<ol class="breadcrumb">');
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::show
 | |
|      */
 | |
|     public function testShow()
 | |
|     {
 | |
|         $this->be($this->user());
 | |
|         $this->call('get', route('piggy-banks.show', [1]));
 | |
|         $this->assertResponseStatus(200);
 | |
|         $this->see('<ol class="breadcrumb">');
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::store
 | |
|      */
 | |
|     public function testStore()
 | |
|     {
 | |
|         $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');
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @covers \FireflyIII\Http\Controllers\PiggyBankController::update
 | |
|      */
 | |
|     public function testUpdate()
 | |
|     {
 | |
|         $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');
 | |
|     }
 | |
| 
 | |
| }
 |