From 55ffe59faf6593528897b5754526742f586f138d Mon Sep 17 00:00:00 2001 From: Raed Yakoubi Date: Sat, 7 Mar 2020 15:54:31 +0100 Subject: [PATCH 1/4] Add default callback functionality --- src/CallbackRegistrar.php | 55 +++++++++++- src/Callbacks.php | 10 +++ src/Http/Middleware/GeoMiddleware.php | 3 +- src/Http/Middleware/GeoRoutesMiddleware.php | 6 +- tests/Unit/CallbackRegistrarTest.php | 96 +++++++++++++++------ tests/Unit/GeoMiddlewareTest.php | 22 ++++- tests/Unit/GeoRoutesMiddlewareTest.php | 35 ++++++-- 7 files changed, 184 insertions(+), 43 deletions(-) diff --git a/src/CallbackRegistrar.php b/src/CallbackRegistrar.php index dca70db..e6ac361 100644 --- a/src/CallbackRegistrar.php +++ b/src/CallbackRegistrar.php @@ -3,9 +3,10 @@ namespace LaraCrafts\GeoRoutes; use Exception; -use Illuminate\Support\Str; use ReflectionClass; use ReflectionMethod; +use Illuminate\Support\Str; +use InvalidArgumentException; class CallbackRegistrar { @@ -16,6 +17,13 @@ class CallbackRegistrar */ protected $proxies; + /** + * The default callback and its arguments. + * + * @var array + */ + protected $default = [[Callbacks::class, 'unauthorized'], []]; + /** * Create a new CallbacksRegistrar instance. */ @@ -141,4 +149,49 @@ public function hasProxy(string $proxy) { return array_key_exists($proxy, $this->proxies); } + + /** + * Set the default callback and its arguments. + * + * @param string|callable $callback + * @param mixed ...$arguments + * + * @return void + */ + public function setDefault($callback, ...$arguments) + { + if (is_callable($callback)) { + return $this->default = [$callback, $arguments]; + } + + if (is_string($callback)) { + return $this->default = [$this->callback($callback), $arguments]; + } + + throw new InvalidArgumentException(sprintf( + "%s expects parameter 1 to be string or callable %s given", + __FUNCTION__, + gettype($callback) + )); + } + + /** + * Get the default callback callable and its arguments. + * + * @return array + */ + public function getDefault() + { + return $this->default; + } + + /** + * Invoke the default callback. + * + * @return mixed + */ + public function invokeDefaultCallback() + { + return call_user_func_array(...$this->default); + } } diff --git a/src/Callbacks.php b/src/Callbacks.php index bde8076..9aec3a1 100644 --- a/src/Callbacks.php +++ b/src/Callbacks.php @@ -6,6 +6,16 @@ class Callbacks { + /** + * Return a HTTP 401 Unauthorized response. + * + * @throws \Symfony\Component\HttpKernel\Exception\HttpException + */ + public static function unauthorized() + { + throw new HttpException(401); + } + /** * Return a HTTP 404 Not Found response. * diff --git a/src/Http/Middleware/GeoMiddleware.php b/src/Http/Middleware/GeoMiddleware.php index 64cf5bc..bc01d6c 100644 --- a/src/Http/Middleware/GeoMiddleware.php +++ b/src/Http/Middleware/GeoMiddleware.php @@ -5,6 +5,7 @@ use Closure; use Illuminate\Http\Request; use LaraCrafts\GeoRoutes\DeterminesGeoAccess; +use LaraCrafts\GeoRoutes\Support\Facades\CallbackRegistrar; class GeoMiddleware { @@ -24,7 +25,7 @@ public function handle(Request $request, Closure $next) $strategy = config()->get('geo-routes.global.strategy'); if (!$this->shouldHaveAccess($countries, $strategy)) { - abort(401); + return CallbackRegistrar::invokeDefaultCallback(); } return $next($request); diff --git a/src/Http/Middleware/GeoRoutesMiddleware.php b/src/Http/Middleware/GeoRoutesMiddleware.php index 1e14d43..f56309e 100644 --- a/src/Http/Middleware/GeoRoutesMiddleware.php +++ b/src/Http/Middleware/GeoRoutesMiddleware.php @@ -7,6 +7,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; use LaraCrafts\GeoRoutes\DeterminesGeoAccess; +use LaraCrafts\GeoRoutes\Support\Facades\CallbackRegistrar; class GeoRoutesMiddleware { @@ -25,8 +26,7 @@ public function handle(Request $request, Closure $next) $route = $request->route(); if (!$route) { - #TODO: Invoke the default callback. - return abort(401); + return CallbackRegistrar::invokeDefaultCallback(); } $constraint = $route->getAction('geo') ?? []; @@ -49,6 +49,6 @@ public function handle(Request $request, Closure $next) return call_user_func_array($callback[0], $callback[1]); } - return abort(401); + return CallbackRegistrar::invokeDefaultCallback(); } } diff --git a/tests/Unit/CallbackRegistrarTest.php b/tests/Unit/CallbackRegistrarTest.php index f1385c7..d3f01f6 100644 --- a/tests/Unit/CallbackRegistrarTest.php +++ b/tests/Unit/CallbackRegistrarTest.php @@ -3,11 +3,12 @@ namespace LaraCrafts\GeoRoutes\Tests\Unit; use Closure; -use LaraCrafts\GeoRoutes\CallbackRegistrar; -use LaraCrafts\GeoRoutes\Tests\TestCase; use Mockery; -use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use ReflectionClass; +use InvalidArgumentException; +use LaraCrafts\GeoRoutes\Tests\TestCase; +use LaraCrafts\GeoRoutes\CallbackRegistrar; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; class CallbackRegistrarTest extends TestCase { @@ -22,9 +23,14 @@ class CallbackRegistrarTest extends TestCase /** @var \Illuminate\Routing\Router */ protected $router; + /** @var \LaraCrafts\GeoRoutes\CallbackRegistrar|\Mockery\MockInterface */ + protected $registrar; + public function setUp(): void { parent::setUp(); + + $this->registrar = new CallbackRegistrar; } public function tearDown(): void @@ -39,10 +45,9 @@ public function testIfCallbacksFetchesTheProxiesList() 'bar' => '\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::bar', ]; - $registrar = new CallbackRegistrar; - $registrar->loadCallbacks($callbacks); + $this->registrar->loadCallbacks($callbacks); - $proxies = $registrar->callbacks(); + $proxies = $this->registrar->callbacks(); foreach ($callbacks as $key => $callback) { $this->assertArrayHasKey('or' . ucfirst($key), $proxies); @@ -57,11 +62,11 @@ public function testIfCallbacksInvokesLoadCallbacksWhenArrayArgIsPresent() 'bar' => '\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::bar', ]; - $registrar = Mockery::mock(CallbackRegistrar::class)->makePartial(); + $this->registrar = Mockery::mock(CallbackRegistrar::class)->makePartial(); - $registrar->shouldReceive('loadCallbacks')->with($callbacks)->once(); + $this->registrar->shouldReceive('loadCallbacks')->with($callbacks)->once(); - $registrar->callbacks($callbacks); + $this->registrar->callbacks($callbacks); } public function testIfParseCallbacksLoadsCallbacksFromClass() @@ -71,11 +76,9 @@ public function testIfParseCallbacksLoadsCallbacksFromClass() 'orBar' => '\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::bar', ]; - $registrar = new CallbackRegistrar; + $this->registrar->parseCallbacks(\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::class); - $registrar->parseCallbacks(\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::class); - - $proxies = $registrar->callbacks(); + $proxies = $this->registrar->callbacks(); foreach ($expected as $proxy => $callable) { $this->assertArrayHasKey($proxy, $proxies); @@ -85,41 +88,78 @@ public function testIfParseCallbacksLoadsCallbacksFromClass() public function testIfCallbackReturnsCallable() { - $registrar = new CallbackRegistrar; - $registrar->loadCallbacks(['foo' => '\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo']); + $this->registrar->loadCallbacks(['foo' => '\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo']); - $this->assertEquals('\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo', $registrar->callback('foo')); - $this->assertEquals('\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo', $registrar->callback('orFoo')); + $this->assertEquals('\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo', $this->registrar->callback('foo')); + $this->assertEquals('\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo', $this->registrar->callback('orFoo')); } public function testIfHasCallbackReturnsTrueIfCallbackExists() { - $registrar = new CallbackRegistrar; - $registrar->loadCallbacks(['foo' => '\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo']); + $this->registrar->loadCallbacks(['foo' => '\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo']); - $this->assertTrue($registrar->hasCallback('foo')); + $this->assertTrue($this->registrar->hasCallback('foo')); } public function testIfHasCallbackReturnsFalseIfCallbackDoesNotExist() { - $registrar = new CallbackRegistrar; - - $this->assertFalse($registrar->hasCallback('foo')); + $this->assertFalse($this->registrar->hasCallback('foo')); } public function testIfHasProxyReturnsTrueIfProxyExists() { - $registrar = new CallbackRegistrar; - $registrar->loadCallbacks(['foo' => '\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo']); + $this->registrar->loadCallbacks(['foo' => '\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo']); - $this->assertTrue($registrar->hasProxy('orFoo')); + $this->assertTrue($this->registrar->hasProxy('orFoo')); } public function testIfHasProxyReturnsFalseIfProxyDoesNotExist() { - $registrar = new CallbackRegistrar; + $this->assertFalse($this->registrar->hasProxy('orFoo')); + } + + public function testIfSetDefaultInvokesCallbackIfArgIsString() + { + $this->registrar = Mockery::mock(CallbackRegistrar::class)->makePartial(); + $this->registrar->loadCallbacks(['foo' => '\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo']); + + $this->registrar->shouldReceive('callback')->with('foo')->once(); + + $this->registrar->setDefault('foo'); + } + + public function testIfSetDefaultSetsDefaultPropertyValueIfArgIsCallable() + { + $this->registrar->setDefault('\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo', 'arg1'); + + $default = $this->getProperty($this->registrar, 'default')->getValue($this->registrar); + + $this->assertEquals(['\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo', ['arg1']], $default); + } + + public function testIfSetDefaultThrowsExceptionIfArgIsInvalid() + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('setDefault expects parameter 1 to be string or callable integer given'); + + $this->registrar->setDefault(321314); + } + + public function testIfGetDefaultReturnsDefaultCallbackArray() + { + $this->registrar->setDefault('\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo', 'arg1'); + + $this->assertEquals( + ['\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo', ['arg1']], + $this->registrar->getDefault() + ); + } + + public function testIfInvokeDefaultCallbackExecutesDefault() + { + $this->registrar->setDefault('\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo'); - $this->assertFalse($registrar->hasProxy('orFoo')); + $this->assertEquals('foo', $this->registrar->invokeDefaultCallback()); } /** diff --git a/tests/Unit/GeoMiddlewareTest.php b/tests/Unit/GeoMiddlewareTest.php index 8c9f6f8..88b414a 100644 --- a/tests/Unit/GeoMiddlewareTest.php +++ b/tests/Unit/GeoMiddlewareTest.php @@ -2,10 +2,12 @@ namespace LaraCrafts\GeoRoutes\Tests\Unit; -use Illuminate\Contracts\Http\Kernel; +use Mockery; use Illuminate\Http\Request; +use Illuminate\Contracts\Http\Kernel; use LaraCrafts\GeoRoutes\Tests\TestCase; -use Mockery; +use LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks; +use LaraCrafts\GeoRoutes\Support\Facades\CallbackRegistrar; class GeoMiddlewareTest extends TestCase { @@ -58,4 +60,20 @@ public function testIfAllowedCountryIsLetThrough() $response = $this->kernel->handle($this->request); $this->assertEquals(200, $response->getStatusCode()); } + + public function testIfMiddlewareExecutesDefaultCallback() + { + $callbacks = Mockery::mock(Callbacks::class); + $callbacks->shouldReceive('foo')->once()->with('bar')->andReturn('foo'); + + CallbackRegistrar::setDefault([$callbacks, 'foo'], 'bar'); + + $this->location->shouldReceive('get') + ->once() + ->andReturn((object)['countryCode' => 'ch']); + + $response = $this->kernel->handle($this->request); + + $this->assertEquals('foo', $response); + } } diff --git a/tests/Unit/GeoRoutesMiddlewareTest.php b/tests/Unit/GeoRoutesMiddlewareTest.php index 4586fc5..b2a385c 100644 --- a/tests/Unit/GeoRoutesMiddlewareTest.php +++ b/tests/Unit/GeoRoutesMiddlewareTest.php @@ -2,12 +2,14 @@ namespace LaraCrafts\GeoRoutes\Tests\Unit; +use Mockery; use Illuminate\Http\Request; use Illuminate\Routing\Route; -use LaraCrafts\GeoRoutes\Http\Middleware\GeoRoutesMiddleware; use LaraCrafts\GeoRoutes\Tests\TestCase; -use Mockery; +use LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks; use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; +use LaraCrafts\GeoRoutes\Support\Facades\CallbackRegistrar; +use LaraCrafts\GeoRoutes\Http\Middleware\GeoRoutesMiddleware; class GeoRoutesMiddlewareTest extends TestCase { @@ -78,23 +80,23 @@ public function middlewareAllowsAccess() /** @test */ public function middlewareExecutesCallback() { - $mockClass = Mockery::mock('alias:mockClass'); - $mockClass->shouldReceive('callback') + $callbacks = Mockery::mock(Callbacks::class); + $callbacks->shouldReceive('foo') ->once() ->with('arg') - ->andReturn('MockCallback'); + ->andReturn('foo'); $this->location->shouldReceive('get') ->once() ->andReturn((object)['countryCode' => 'ca']); - $callback = ['mockClass::callback', ['arg']]; + $callback = [[$callbacks, 'foo'], ['arg']]; $this->setGeoConstraint('allow', 'us', $callback); $output = $this->middleware->handle($this->request, $this->next); - $this->assertEquals('MockCallback', $output); + $this->assertEquals('foo', $output); } /** @test */ @@ -112,7 +114,24 @@ public function middlewareThrowsExceptionIfTheGeoAttributeIsInvalid() ->once() ->andReturn([]); - $output = $this->middleware->handle($this->request, $this->next); + $this->middleware->handle($this->request, $this->next); + } + + /** @test */ + public function middlewareExecutesDefaultCallbackIfNoCallbackIsFound() + { + $callbacks = Mockery::mock(Callbacks::class); + $callbacks->shouldReceive('foo')->once()->with('bar'); + + CallbackRegistrar::setDefault([$callbacks, 'foo'], 'bar'); + + $this->location->shouldReceive('get') + ->once() + ->andReturn((object)['countryCode' => 'ca']); + + $this->setGeoConstraint('deny', 'ca'); + + $this->middleware->handle($this->request, $this->next); } /** From 5d35a4c72d8c12a91ba7fadcdaab30a900528937 Mon Sep 17 00:00:00 2001 From: Raed Yak Date: Sat, 7 Mar 2020 14:56:26 +0000 Subject: [PATCH 2/4] Apply fixes from StyleCI --- src/CallbackRegistrar.php | 6 +++--- tests/Unit/CallbackRegistrarTest.php | 6 +++--- tests/Unit/GeoMiddlewareTest.php | 8 ++++---- tests/Unit/GeoRoutesMiddlewareTest.php | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/CallbackRegistrar.php b/src/CallbackRegistrar.php index e6ac361..7f09a79 100644 --- a/src/CallbackRegistrar.php +++ b/src/CallbackRegistrar.php @@ -3,10 +3,10 @@ namespace LaraCrafts\GeoRoutes; use Exception; -use ReflectionClass; -use ReflectionMethod; use Illuminate\Support\Str; use InvalidArgumentException; +use ReflectionClass; +use ReflectionMethod; class CallbackRegistrar { @@ -19,7 +19,7 @@ class CallbackRegistrar /** * The default callback and its arguments. - * + * * @var array */ protected $default = [[Callbacks::class, 'unauthorized'], []]; diff --git a/tests/Unit/CallbackRegistrarTest.php b/tests/Unit/CallbackRegistrarTest.php index d3f01f6..24d2699 100644 --- a/tests/Unit/CallbackRegistrarTest.php +++ b/tests/Unit/CallbackRegistrarTest.php @@ -3,12 +3,12 @@ namespace LaraCrafts\GeoRoutes\Tests\Unit; use Closure; -use Mockery; -use ReflectionClass; use InvalidArgumentException; -use LaraCrafts\GeoRoutes\Tests\TestCase; use LaraCrafts\GeoRoutes\CallbackRegistrar; +use LaraCrafts\GeoRoutes\Tests\TestCase; +use Mockery; use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; +use ReflectionClass; class CallbackRegistrarTest extends TestCase { diff --git a/tests/Unit/GeoMiddlewareTest.php b/tests/Unit/GeoMiddlewareTest.php index 88b414a..3f5a17e 100644 --- a/tests/Unit/GeoMiddlewareTest.php +++ b/tests/Unit/GeoMiddlewareTest.php @@ -2,12 +2,12 @@ namespace LaraCrafts\GeoRoutes\Tests\Unit; -use Mockery; -use Illuminate\Http\Request; use Illuminate\Contracts\Http\Kernel; -use LaraCrafts\GeoRoutes\Tests\TestCase; -use LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks; +use Illuminate\Http\Request; use LaraCrafts\GeoRoutes\Support\Facades\CallbackRegistrar; +use LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks; +use LaraCrafts\GeoRoutes\Tests\TestCase; +use Mockery; class GeoMiddlewareTest extends TestCase { diff --git a/tests/Unit/GeoRoutesMiddlewareTest.php b/tests/Unit/GeoRoutesMiddlewareTest.php index b2a385c..6a33c21 100644 --- a/tests/Unit/GeoRoutesMiddlewareTest.php +++ b/tests/Unit/GeoRoutesMiddlewareTest.php @@ -2,14 +2,14 @@ namespace LaraCrafts\GeoRoutes\Tests\Unit; -use Mockery; use Illuminate\Http\Request; use Illuminate\Routing\Route; -use LaraCrafts\GeoRoutes\Tests\TestCase; +use LaraCrafts\GeoRoutes\Http\Middleware\GeoRoutesMiddleware; +use LaraCrafts\GeoRoutes\Support\Facades\CallbackRegistrar; use LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks; +use LaraCrafts\GeoRoutes\Tests\TestCase; +use Mockery; use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; -use LaraCrafts\GeoRoutes\Support\Facades\CallbackRegistrar; -use LaraCrafts\GeoRoutes\Http\Middleware\GeoRoutesMiddleware; class GeoRoutesMiddlewareTest extends TestCase { From 8feeeb635663b993c2c2e6b4c42082ace7cdc1a1 Mon Sep 17 00:00:00 2001 From: Raed Yakoubi Date: Sat, 7 Mar 2020 16:04:02 +0100 Subject: [PATCH 3/4] Document new methods in the CallbackRegistrar Facade --- src/Support/Facades/CallbackRegistrar.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Support/Facades/CallbackRegistrar.php b/src/Support/Facades/CallbackRegistrar.php index bee83f8..bf57e3b 100644 --- a/src/Support/Facades/CallbackRegistrar.php +++ b/src/Support/Facades/CallbackRegistrar.php @@ -12,6 +12,9 @@ * @method static mixed callback(string $name, callable $callable = null) * @method static boolean hasCallback(string $name) * @method static boolean hasProxy(string $proxy) + * @method static void setDefault(string|callable $callback, ...$arguments) + * @method static array getDefault() + * @method static mixed invokeDefaultCallback() * * @see \LaraCrafts\GeoRoutes\CallbackRegistrar */ From 84e64366696503ce4623568c3fea998f62c037bb Mon Sep 17 00:00:00 2001 From: Raed Yakoubi Date: Thu, 19 Mar 2020 08:45:54 +0100 Subject: [PATCH 4/4] Rename invokeDefaultCallback to invokeDefault --- src/CallbackRegistrar.php | 2 +- src/Http/Middleware/GeoMiddleware.php | 2 +- src/Http/Middleware/GeoRoutesMiddleware.php | 4 ++-- src/Support/Facades/CallbackRegistrar.php | 2 +- tests/Unit/CallbackRegistrarTest.php | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/CallbackRegistrar.php b/src/CallbackRegistrar.php index 7f09a79..35c0964 100644 --- a/src/CallbackRegistrar.php +++ b/src/CallbackRegistrar.php @@ -190,7 +190,7 @@ public function getDefault() * * @return mixed */ - public function invokeDefaultCallback() + public function invokeDefault() { return call_user_func_array(...$this->default); } diff --git a/src/Http/Middleware/GeoMiddleware.php b/src/Http/Middleware/GeoMiddleware.php index bc01d6c..df49a23 100644 --- a/src/Http/Middleware/GeoMiddleware.php +++ b/src/Http/Middleware/GeoMiddleware.php @@ -25,7 +25,7 @@ public function handle(Request $request, Closure $next) $strategy = config()->get('geo-routes.global.strategy'); if (!$this->shouldHaveAccess($countries, $strategy)) { - return CallbackRegistrar::invokeDefaultCallback(); + return CallbackRegistrar::invokeDefault(); } return $next($request); diff --git a/src/Http/Middleware/GeoRoutesMiddleware.php b/src/Http/Middleware/GeoRoutesMiddleware.php index f56309e..d199307 100644 --- a/src/Http/Middleware/GeoRoutesMiddleware.php +++ b/src/Http/Middleware/GeoRoutesMiddleware.php @@ -26,7 +26,7 @@ public function handle(Request $request, Closure $next) $route = $request->route(); if (!$route) { - return CallbackRegistrar::invokeDefaultCallback(); + return CallbackRegistrar::invokeDefault(); } $constraint = $route->getAction('geo') ?? []; @@ -49,6 +49,6 @@ public function handle(Request $request, Closure $next) return call_user_func_array($callback[0], $callback[1]); } - return CallbackRegistrar::invokeDefaultCallback(); + return CallbackRegistrar::invokeDefault(); } } diff --git a/src/Support/Facades/CallbackRegistrar.php b/src/Support/Facades/CallbackRegistrar.php index bf57e3b..810bf6d 100644 --- a/src/Support/Facades/CallbackRegistrar.php +++ b/src/Support/Facades/CallbackRegistrar.php @@ -14,7 +14,7 @@ * @method static boolean hasProxy(string $proxy) * @method static void setDefault(string|callable $callback, ...$arguments) * @method static array getDefault() - * @method static mixed invokeDefaultCallback() + * @method static mixed invokeDefault() * * @see \LaraCrafts\GeoRoutes\CallbackRegistrar */ diff --git a/tests/Unit/CallbackRegistrarTest.php b/tests/Unit/CallbackRegistrarTest.php index 24d2699..6650f79 100644 --- a/tests/Unit/CallbackRegistrarTest.php +++ b/tests/Unit/CallbackRegistrarTest.php @@ -155,11 +155,11 @@ public function testIfGetDefaultReturnsDefaultCallbackArray() ); } - public function testIfInvokeDefaultCallbackExecutesDefault() + public function testIfInvokeDefaultExecutesDefault() { $this->registrar->setDefault('\LaraCrafts\GeoRoutes\Tests\Mocks\Callbacks::foo'); - $this->assertEquals('foo', $this->registrar->invokeDefaultCallback()); + $this->assertEquals('foo', $this->registrar->invokeDefault()); } /**