mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Currency code test.
This commit is contained in:
parent
56ae279c96
commit
5cb948d0f3
@ -38,9 +38,11 @@ class CurrencyCode implements BinderInterface
|
||||
*/
|
||||
public static function routeBinder($value, $route)
|
||||
{
|
||||
$currency = TransactionCurrency::where('code', $value)->first();
|
||||
if (null !== $currency) {
|
||||
return $currency;
|
||||
if (auth()->check()) {
|
||||
$currency = TransactionCurrency::where('code', $value)->first();
|
||||
if (null !== $currency) {
|
||||
return $currency;
|
||||
}
|
||||
}
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
|
@ -373,6 +373,62 @@ class BinderTest extends TestCase
|
||||
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::handle
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::__construct
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::performBinding
|
||||
* @covers \FireflyIII\Support\Binder\CurrencyCode::routeBinder
|
||||
*/
|
||||
public function testCurrencyCode()
|
||||
{
|
||||
Route::middleware(Binder::class)->any(
|
||||
'/_test/binder/{fromCurrencyCode}', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get('/_test/binder/USD');
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::handle
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::__construct
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::performBinding
|
||||
* @covers \FireflyIII\Support\Binder\CurrencyCode::routeBinder
|
||||
*/
|
||||
public function testCurrencyCodeNotFound()
|
||||
{
|
||||
Route::middleware(Binder::class)->any(
|
||||
'/_test/binder/{fromCurrencyCode}', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get('/_test/binder/ABC');
|
||||
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::handle
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::__construct
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::performBinding
|
||||
* @covers \FireflyIII\Support\Binder\CurrencyCode::routeBinder
|
||||
*/
|
||||
public function testCurrencyCodeNotLoggedIn()
|
||||
{
|
||||
Route::middleware(Binder::class)->any(
|
||||
'/_test/binder/{fromCurrencyCode}', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
|
||||
$response = $this->get('/_test/binder/EUR');
|
||||
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::handle
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::__construct
|
||||
@ -448,6 +504,24 @@ class BinderTest extends TestCase
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::handle
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::__construct
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::performBinding
|
||||
* @covers \FireflyIII\Models\ImportJob::routeBinder
|
||||
*/
|
||||
public function testImportJobBadStatus()
|
||||
{
|
||||
Route::middleware(Binder::class)->any(
|
||||
'/_test/binder/{importJob}', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
$this->be($this->user());
|
||||
$response = $this->get('/_test/binder/bad-status');
|
||||
$this->assertEquals(Response::HTTP_INTERNAL_SERVER_ERROR, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::handle
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::__construct
|
||||
@ -485,27 +559,6 @@ class BinderTest extends TestCase
|
||||
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::handle
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::__construct
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::performBinding
|
||||
* @covers \FireflyIII\Models\ImportJob::routeBinder
|
||||
*/
|
||||
public function testImportJobBadStatus()
|
||||
{
|
||||
Route::middleware(Binder::class)->any(
|
||||
'/_test/binder/{importJob}', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
$this->be($this->user());
|
||||
$response = $this->get('/_test/binder/bad-status');
|
||||
$this->assertEquals(Response::HTTP_INTERNAL_SERVER_ERROR, $response->getStatusCode());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::handle
|
||||
* @covers \FireflyIII\Http\Middleware\Binder::__construct
|
||||
@ -1010,7 +1063,5 @@ class BinderTest extends TestCase
|
||||
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user