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

180 lines
5.0 KiB
PHP
Raw Normal View History

2016-01-19 23:20:09 -06:00
<?php
/**
* JsonControllerTest.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.
*/
2016-01-24 09:25:03 -06:00
use Illuminate\Support\Collection;
2016-01-19 23:20:09 -06:00
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28.
*/
class JsonControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\JsonController::action
2016-02-04 00:30:48 -06:00
* @covers FireflyIII\Http\Controllers\JsonController::__construct
2016-01-19 23:20:09 -06:00
*/
public function testAction()
{
2016-01-24 09:25:03 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/json/action');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\JsonController::boxBillsPaid
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testBoxBillsPaid($range)
2016-01-19 23:20:09 -06:00
{
2016-01-24 09:25:03 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/json/box/bills-paid');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\JsonController::boxBillsUnpaid
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testBoxBillsUnpaid($range)
2016-01-19 23:20:09 -06:00
{
2016-01-24 09:25:03 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/json/box/bills-unpaid');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\JsonController::boxIn
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testBoxIn($range)
2016-01-19 23:20:09 -06:00
{
2016-01-24 09:25:03 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/json/box/in');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\JsonController::boxOut
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testBoxOut($range)
2016-01-19 23:20:09 -06:00
{
2016-01-24 09:25:03 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/json/box/out');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\JsonController::categories
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testCategories($range)
2016-01-19 23:20:09 -06:00
{
2016-01-24 09:25:03 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/json/categories');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::endTour
*/
public function testEndTour()
{
2016-01-24 09:25:03 -06:00
$this->be($this->user());
$response = $this->call('POST', '/json/end-tour');
2016-01-24 11:11:57 -06:00
$this->assertResponseStatus(200);
2016-01-24 09:25:03 -06:00
$this->assertEquals('"true"', $response->content());
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::expenseAccounts
*/
public function testExpenseAccounts()
{
2016-01-24 09:25:03 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/json/expense-accounts');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::revenueAccounts
*/
public function testRevenueAccounts()
{
2016-01-24 09:25:03 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/json/revenue-accounts');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::tags
*/
public function testTags()
{
2016-01-24 09:25:03 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/json/tags');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::tour
*/
public function testTour()
{
2016-01-24 09:25:03 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/json/tour');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\JsonController::transactionJournals
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testTransactionJournals($range)
2016-01-19 23:20:09 -06:00
{
2016-01-24 09:25:03 -06:00
$type = factory(FireflyIII\Models\TransactionType::class)->make();
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
$repository->shouldReceive('getTransactionType')->with('deposit')->once()->andReturn($type);
$repository->shouldReceive('getJournalsOfType')->with($type)->once()->andReturn(new Collection);
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/json/transaction-journals/deposit');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::trigger
*/
public function testTrigger()
{
2016-01-24 09:25:03 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/json/trigger');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
}