2017-12-25 01:45:23 -06:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* BinderTest.php
|
|
|
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
|
|
|
*
|
|
|
|
* This file is part of Firefly III.
|
|
|
|
*
|
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2017-12-25 08:30:50 -06:00
|
|
|
namespace Tests\Unit\Middleware;
|
2017-12-25 01:45:23 -06:00
|
|
|
|
|
|
|
|
2017-12-25 08:30:50 -06:00
|
|
|
use Carbon\Carbon;
|
|
|
|
use FireflyIII\Helpers\FiscalHelperInterface;
|
2018-02-10 02:22:04 -06:00
|
|
|
use FireflyIII\Http\Middleware\Binder;
|
2017-12-25 08:30:50 -06:00
|
|
|
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
2017-12-25 02:44:46 -06:00
|
|
|
use Illuminate\Support\Collection;
|
2017-12-25 01:45:23 -06:00
|
|
|
use Route;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class BinderTest
|
|
|
|
* Per object: works, not existing, not logged in + existing
|
|
|
|
*/
|
2018-02-10 02:22:04 -06:00
|
|
|
class BinderTest extends TestCase
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Account::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testAccount(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{account}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2017-12-25 02:44:46 -06:00
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 02:44:46 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\AccountList::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testAccountList(): void
|
2017-12-25 02:44:46 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 02:44:46 -06:00
|
|
|
'/_test/binder/{accountList}', function (Collection $accounts) {
|
|
|
|
return 'count: ' . $accounts->count();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1,2');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
$response->assertSee('count: 2');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 02:44:46 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\AccountList::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testAccountListEmpty(): void
|
2017-12-25 02:44:46 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 02:44:46 -06:00
|
|
|
'/_test/binder/{accountList}', function (Collection $accounts) {
|
|
|
|
return 'count: ' . $accounts->count();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 02:44:46 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\AccountList::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testAccountListInvalid(): void
|
2017-12-25 02:44:46 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 02:44:46 -06:00
|
|
|
'/_test/binder/{accountList}', function (Collection $accounts) {
|
|
|
|
return 'count: ' . $accounts->count();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0,1,2');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
$response->assertSee('count: 2');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 02:44:46 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\AccountList::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testAccountListNotLoggedIn(): void
|
2017-12-25 02:44:46 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 02:44:46 -06:00
|
|
|
'/_test/binder/{accountList}', function (Collection $accounts) {
|
|
|
|
return 'count: ' . $accounts->count();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$response = $this->get('/_test/binder/1,2');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2017-12-25 01:45:23 -06:00
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Account::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testAccountNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{account}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Account::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testAccountNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{account}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Attachment::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testAttachment(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{attachment}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Attachment::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testAttachmentNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{attachment}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Attachment::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testAttachmentNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{attachment}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Bill::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testBill(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{bill}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Bill::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testBillNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{bill}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Bill::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testBillNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{bill}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Budget::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testBudget(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{budget}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\BudgetLimit::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testBudgetLimit(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2018-01-10 13:07:47 -06:00
|
|
|
'/_test/binder/{budgetLimit}', function () {
|
2017-12-25 01:45:23 -06:00
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\BudgetLimit::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testBudgetLimitNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2018-01-10 13:07:47 -06:00
|
|
|
'/_test/binder/{budgetLimit}', function () {
|
2017-12-25 01:45:23 -06:00
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\BudgetLimit::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testBudgetLimitNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2018-01-10 13:07:47 -06:00
|
|
|
'/_test/binder/{budgetLimit}', function () {
|
2017-12-25 01:45:23 -06:00
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2017-12-25 08:30:50 -06:00
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\BudgetList::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testBudgetList(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{budgetList}', function (Collection $budgets) {
|
|
|
|
return 'count: ' . $budgets->count();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0,1,2');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
$response->assertSee('count: 3');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\BudgetList::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testBudgetListInvalid(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{budgetList}', function (Collection $budgets) {
|
|
|
|
return 'count: ' . $budgets->count();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/-1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2017-12-25 01:45:23 -06:00
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Budget::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testBudgetNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{budget}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Budget::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testBudgetNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{budget}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Category::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testCategory(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{category}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2017-12-25 08:30:50 -06:00
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\CategoryList::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testCategoryList(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{categoryList}', function (Collection $categories) {
|
|
|
|
return 'count: ' . $categories->count();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0,1,2');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
$response->assertSee('count: 3');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\CategoryList::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testCategoryListInvalid(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{categoryList}', function (Collection $categories) {
|
|
|
|
return 'count: ' . $categories->count();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/-1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2017-12-25 01:45:23 -06:00
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Category::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testCategoryNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{category}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Category::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testCategoryNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{category}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2017-12-25 02:00:09 -06:00
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 02:00:09 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\CurrencyCode::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testCurrencyCode(): void
|
2017-12-25 02:00:09 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 02:00:09 -06:00
|
|
|
'/_test/binder/{fromCurrencyCode}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/USD');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 02:00:09 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\CurrencyCode::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testCurrencyCodeNotFound(): void
|
2017-12-25 02:00:09 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 02:00:09 -06:00
|
|
|
'/_test/binder/{fromCurrencyCode}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/ABC');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 02:00:09 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\CurrencyCode::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testCurrencyCodeNotLoggedIn(): void
|
2017-12-25 02:00:09 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 02:00:09 -06:00
|
|
|
'/_test/binder/{fromCurrencyCode}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/EUR');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2017-12-25 08:30:50 -06:00
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\Date::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testDate(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{date}', function (Carbon $date) {
|
|
|
|
return 'date: ' . $date->format('Y-m-d');
|
|
|
|
}
|
|
|
|
);
|
2018-07-28 05:10:25 -05:00
|
|
|
|
|
|
|
// mock fiscal helper:
|
2018-08-06 12:14:30 -05:00
|
|
|
$date = new Carbon;
|
2018-07-28 05:10:25 -05:00
|
|
|
$helper = $this->mock(FiscalHelperInterface::class);
|
|
|
|
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
|
|
|
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
|
|
|
|
2017-12-25 08:30:50 -06:00
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/20170917');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
$response->assertSee('date: 2017-09-17');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\Date::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testDateCurrentMonthEnd(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{date}', function (Carbon $date) {
|
|
|
|
return 'date: ' . $date->format('Y-m-d');
|
|
|
|
}
|
|
|
|
);
|
2018-07-28 05:10:25 -05:00
|
|
|
$date = new Carbon;
|
|
|
|
$date->endOfMonth();
|
|
|
|
|
|
|
|
// mock fiscal helper:
|
|
|
|
$helper = $this->mock(FiscalHelperInterface::class);
|
|
|
|
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
|
|
|
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
|
|
|
|
2017-12-25 08:30:50 -06:00
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/currentMonthEnd');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
$response->assertSee('date: ' . $date->format('Y-m-d'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\Date::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testDateCurrentMonthStart(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{date}', function (Carbon $date) {
|
|
|
|
return 'date: ' . $date->format('Y-m-d');
|
|
|
|
}
|
|
|
|
);
|
2018-07-28 05:10:25 -05:00
|
|
|
$date = new Carbon;
|
|
|
|
$date->startOfMonth();
|
|
|
|
|
|
|
|
// mock fiscal helper:
|
|
|
|
$helper = $this->mock(FiscalHelperInterface::class);
|
|
|
|
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
|
|
|
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
|
|
|
|
2017-12-25 08:30:50 -06:00
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/currentMonthStart');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
$response->assertSee('date: ' . $date->format('Y-m-d'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\Date::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testDateCurrentYearEnd(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{date}', function (Carbon $date) {
|
|
|
|
return 'date: ' . $date->format('Y-m-d');
|
|
|
|
}
|
|
|
|
);
|
2018-07-28 05:10:25 -05:00
|
|
|
$date = new Carbon;
|
|
|
|
$date->endOfYear();
|
|
|
|
|
|
|
|
// mock fiscal helper:
|
|
|
|
$helper = $this->mock(FiscalHelperInterface::class);
|
|
|
|
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
|
|
|
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
|
|
|
|
2017-12-25 08:30:50 -06:00
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/currentYearEnd');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
$response->assertSee('date: ' . $date->format('Y-m-d'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\Date::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testDateCurrentYearStart(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-07-28 05:10:25 -05:00
|
|
|
$date = new Carbon;
|
|
|
|
$date->startOfYear();
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{date}', function (Carbon $date) {
|
|
|
|
return 'date: ' . $date->format('Y-m-d');
|
|
|
|
}
|
|
|
|
);
|
2018-07-28 05:10:25 -05:00
|
|
|
|
|
|
|
// mock fiscal helper:
|
|
|
|
$helper = $this->mock(FiscalHelperInterface::class);
|
|
|
|
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
|
|
|
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
|
|
|
|
2017-12-25 08:30:50 -06:00
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/currentYearStart');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
$response->assertSee('date: ' . $date->format('Y-m-d'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\Date::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testDateFiscalYearEnd(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{date}', function (Carbon $date) {
|
|
|
|
return 'date: ' . $date->format('Y-m-d');
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$date = new Carbon;
|
|
|
|
$date->endOfYear();
|
|
|
|
|
|
|
|
// mock fiscal helper:
|
|
|
|
$helper = $this->mock(FiscalHelperInterface::class);
|
|
|
|
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
2018-07-28 05:10:25 -05:00
|
|
|
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
2017-12-25 08:30:50 -06:00
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/currentFiscalYearEnd');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
$response->assertSee('date: ' . $date->format('Y-m-d'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\Date::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testDateFiscalYearStart(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{date}', function (Carbon $date) {
|
|
|
|
return 'date: ' . $date->format('Y-m-d');
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$date = new Carbon;
|
|
|
|
$date->startOfYear();
|
|
|
|
|
|
|
|
// mock fiscal helper:
|
|
|
|
$helper = $this->mock(FiscalHelperInterface::class);
|
2018-07-28 05:10:25 -05:00
|
|
|
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
2017-12-25 08:30:50 -06:00
|
|
|
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/currentFiscalYearStart');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
$response->assertSee('date: ' . $date->format('Y-m-d'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\Date::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testDateInvalid(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{date}', function (Carbon $date) {
|
|
|
|
return 'date: ' . $date->format('Y-m-d');
|
|
|
|
}
|
|
|
|
);
|
2018-07-28 05:10:25 -05:00
|
|
|
$date = new Carbon;
|
|
|
|
// mock fiscal helper:
|
|
|
|
$helper = $this->mock(FiscalHelperInterface::class);
|
|
|
|
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
|
|
|
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
|
|
|
|
2017-12-25 08:30:50 -06:00
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/fakedate');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2017-12-25 01:45:23 -06:00
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\ExportJob::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testExportJob(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{exportJob}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/testExport');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\ExportJob::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testExportJobNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{exportJob}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\ExportJob::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testExportJobNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{exportJob}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/testExport');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\ImportJob::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testImportJob(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{importJob}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/testImport');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\ImportJob::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testImportJobNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{importJob}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2017-12-25 02:00:09 -06:00
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
2017-12-25 01:45:23 -06:00
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\ImportJob::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testImportJobNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{importJob}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2017-12-25 02:00:09 -06:00
|
|
|
$response = $this->get('/_test/binder/testImport');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
2017-12-25 01:45:23 -06:00
|
|
|
|
2017-12-25 08:30:50 -06:00
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\JournalList::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testJournalList(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{journalList}', function (Collection $journals) {
|
|
|
|
return 'count: ' . $journals->count();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1,2');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
$response->assertSee('count: 2');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\JournalList::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testJournalListEmpty(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{journalList}', function (Collection $journals) {
|
|
|
|
return 'count: ' . $journals->count();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/-1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2017-12-25 01:45:23 -06:00
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\LinkType::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testLinkType(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{linkType}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\LinkType::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testLinkTypeNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{linkType}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\LinkType::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testLinkTypeNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{linkType}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\PiggyBank::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testPiggyBank(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{piggyBank}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\PiggyBank::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testPiggyBankNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{piggyBank}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\PiggyBank::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testPiggyBankNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{piggyBank}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Rule::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testRule(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{rule}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\RuleGroup::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testRuleGroup(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{ruleGroup}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\RuleGroup::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testRuleGroupNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{ruleGroup}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\RuleGroup::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testRuleGroupNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{ruleGroup}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Rule::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testRuleNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{rule}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Rule::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testRuleNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{rule}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\TransactionJournal::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTJ(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{tj}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\TransactionJournal::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTJNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{tj}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\TransactionJournal::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTJNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{tj}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Tag::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTag(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{tag}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\TagList::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTagList(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-28 13:18:47 -06:00
|
|
|
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
|
|
|
$tagRepos->shouldReceive('setUser');
|
2018-03-02 10:07:32 -06:00
|
|
|
$tags = $this->user()->tags()->whereIn('id', [1, 2])->get(['tags.*']);
|
2018-02-28 13:18:47 -06:00
|
|
|
$tagRepos->shouldReceive('get')->once()->andReturn($tags);
|
|
|
|
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{tagList}', function (Collection $tags) {
|
|
|
|
return 'count: ' . $tags->count();
|
|
|
|
}
|
|
|
|
);
|
2018-02-28 13:18:47 -06:00
|
|
|
|
2018-04-02 07:17:11 -05:00
|
|
|
$names = implode(',', $tags->pluck('tag')->toArray());
|
2017-12-25 08:30:50 -06:00
|
|
|
|
2018-02-28 13:18:47 -06:00
|
|
|
|
2017-12-25 08:30:50 -06:00
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/' . $names);
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
$response->assertSee('count: 2');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 08:30:50 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\TagList::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTagListEmpty(): void
|
2017-12-25 08:30:50 -06:00
|
|
|
{
|
2018-02-28 13:18:47 -06:00
|
|
|
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
|
|
|
$tagRepos->shouldReceive('setUser');
|
|
|
|
$tagRepos->shouldReceive('get')->once()->andReturn(new Collection());
|
|
|
|
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 08:30:50 -06:00
|
|
|
'/_test/binder/{tagList}', function (Collection $tags) {
|
|
|
|
return 'count: ' . $tags->count();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/noblaexista');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Tag::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTagNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{tag}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\Tag::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTagNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{tag}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\TransactionCurrency::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTransactionCurrency(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{currency}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\TransactionCurrency::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTransactionCurrencyNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{currency}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\TransactionCurrency::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTransactionCurrencyNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{currency}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\TransactionJournalLink::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTransactionJournalLink(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{journalLink}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\TransactionJournalLink::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTransactionJournalLinkNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{journalLink}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/0');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\TransactionJournalLink::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTransactionJournalLinkNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 01:45:23 -06:00
|
|
|
'/_test/binder/{journalLink}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/1');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\TransactionType::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTransactionType(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2018-01-10 13:07:47 -06:00
|
|
|
'/_test/binder/{transactionType}', function () {
|
2017-12-25 01:45:23 -06:00
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/withdrawal');
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\TransactionType::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTransactionTypeNotFound(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2018-01-10 13:07:47 -06:00
|
|
|
'/_test/binder/{transactionType}', function () {
|
2017-12-25 01:45:23 -06:00
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/unknown');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 01:45:23 -06:00
|
|
|
* @covers \FireflyIII\Models\TransactionType::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testTransactionTypeNotLoggedIn(): void
|
2017-12-25 01:45:23 -06:00
|
|
|
{
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2018-01-10 13:07:47 -06:00
|
|
|
'/_test/binder/{transactionType}', function () {
|
2017-12-25 01:45:23 -06:00
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$response = $this->get('/_test/binder/withdrawal');
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2017-12-25 02:44:46 -06:00
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 02:44:46 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\UnfinishedJournal::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testUnfinishedJournal(): void
|
2017-12-25 02:44:46 -06:00
|
|
|
{
|
|
|
|
$journal = $this->user()->transactionJournals()->where('completed', 0)->first();
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 02:44:46 -06:00
|
|
|
'/_test/binder/{unfinishedJournal}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get('/_test/binder/' . $journal->id);
|
|
|
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 02:44:46 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\UnfinishedJournal::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testUnfinishedJournalFinished(): void
|
2017-12-25 02:44:46 -06:00
|
|
|
{
|
|
|
|
$journal = $this->user()->transactionJournals()->where('completed', 1)->first();
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 02:44:46 -06:00
|
|
|
'/_test/binder/{unfinishedJournal}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$response = $this->get('/_test/binder/' . $journal->id);
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-04 23:47:35 -05:00
|
|
|
* @covers \FireflyIII\Http\Middleware\Binder
|
2017-12-25 02:44:46 -06:00
|
|
|
* @covers \FireflyIII\Support\Binder\UnfinishedJournal::routeBinder
|
|
|
|
*/
|
2018-05-04 23:47:35 -05:00
|
|
|
public function testUnfinishedJournalNotLoggedIn(): void
|
2017-12-25 02:44:46 -06:00
|
|
|
{
|
|
|
|
$journal = $this->user()->transactionJournals()->where('completed', 0)->first();
|
2018-02-10 02:22:04 -06:00
|
|
|
Route::middleware(Binder::class)->any(
|
2017-12-25 02:44:46 -06:00
|
|
|
'/_test/binder/{unfinishedJournal}', function () {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$response = $this->get('/_test/binder/' . $journal->id);
|
|
|
|
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2017-12-25 01:45:23 -06:00
|
|
|
|
2018-03-04 08:14:29 -06:00
|
|
|
}
|