mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix test coverage. [skip ci]
This commit is contained in:
@@ -29,10 +29,10 @@ use FireflyIII\Helpers\FiscalHelperInterface;
|
||||
use FireflyIII\Http\Middleware\Binder;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Route;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class BinderTest
|
||||
@@ -539,8 +539,8 @@ class BinderTest extends TestCase
|
||||
|
||||
$helper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->atLeast()->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->atLeast()->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get('/_test/binder/20170917');
|
||||
@@ -556,21 +556,23 @@ class BinderTest extends TestCase
|
||||
{
|
||||
Route::middleware(Binder::class)->any(
|
||||
'/_test/binder/{date}', function (Carbon $date) {
|
||||
Log::debug(sprintf('Received in function: "%s"', $date->format('Y-m-d')));
|
||||
|
||||
return 'date: ' . $date->format('Y-m-d');
|
||||
}
|
||||
);
|
||||
$date = new Carbon;
|
||||
$date->endOfMonth();
|
||||
$testDate = clone $date;
|
||||
|
||||
// mock fiscal helper:
|
||||
$helper = $this->mock(FiscalHelperInterface::class);
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
||||
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->atLeast()->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->atLeast()->once();
|
||||
$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'));
|
||||
$response->assertSee('date: ' . $testDate->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -586,16 +588,17 @@ class BinderTest extends TestCase
|
||||
);
|
||||
$date = new Carbon;
|
||||
$date->startOfMonth();
|
||||
$testDate = clone $date;
|
||||
|
||||
// mock fiscal helper:
|
||||
$helper = $this->mock(FiscalHelperInterface::class);
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->atLeast()->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->atLeast()->once();
|
||||
|
||||
$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'));
|
||||
$response->assertSee('date: ' . $testDate->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -611,16 +614,17 @@ class BinderTest extends TestCase
|
||||
);
|
||||
$date = new Carbon;
|
||||
$date->endOfYear();
|
||||
$testDate = clone $date;
|
||||
|
||||
// mock fiscal helper:
|
||||
$helper = $this->mock(FiscalHelperInterface::class);
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->atLeast()->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->atLeast()->once();
|
||||
|
||||
$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'));
|
||||
$response->assertSee('date: ' . $testDate->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -631,6 +635,8 @@ class BinderTest extends TestCase
|
||||
{
|
||||
$date = new Carbon;
|
||||
$date->startOfYear();
|
||||
$testDate = clone $date;
|
||||
|
||||
Route::middleware(Binder::class)->any(
|
||||
'/_test/binder/{date}', function (Carbon $date) {
|
||||
return 'date: ' . $date->format('Y-m-d');
|
||||
@@ -639,13 +645,13 @@ class BinderTest extends TestCase
|
||||
|
||||
// mock fiscal helper:
|
||||
$helper = $this->mock(FiscalHelperInterface::class);
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->atLeast()->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->atLeast()->once();
|
||||
|
||||
$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'));
|
||||
$response->assertSee('date: ' . $testDate->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -662,16 +668,17 @@ class BinderTest extends TestCase
|
||||
|
||||
$date = new Carbon;
|
||||
$date->endOfYear();
|
||||
$testDate = clone $date;
|
||||
|
||||
// mock fiscal helper:
|
||||
$helper = $this->mock(FiscalHelperInterface::class);
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($testDate)->atLeast()->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->atLeast()->once();
|
||||
|
||||
$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'));
|
||||
$response->assertSee('date: ' . $testDate->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -688,16 +695,17 @@ class BinderTest extends TestCase
|
||||
|
||||
$date = new Carbon;
|
||||
$date->startOfYear();
|
||||
$testDate = clone $date;
|
||||
|
||||
// mock fiscal helper:
|
||||
$helper = $this->mock(FiscalHelperInterface::class);
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($testDate)->atLeast()->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->atLeast()->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'));
|
||||
$response->assertSee('date: ' . $testDate->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -714,8 +722,8 @@ class BinderTest extends TestCase
|
||||
$date = new Carbon;
|
||||
// mock fiscal helper:
|
||||
$helper = $this->mock(FiscalHelperInterface::class);
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->atLeast()->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->atLeast()->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get('/_test/binder/fakedate');
|
||||
|
Reference in New Issue
Block a user