generated from spatie/package-skeleton-laravel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from robertdrakedennis/master
Feature: Domain attribute
- Loading branch information
Showing
7 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Spatie\RouteAttributes\Attributes; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_CLASS)] | ||
class Domain implements RouteAttribute | ||
{ | ||
public function __construct( | ||
public string $domain | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Spatie\RouteAttributes\Tests\AttributeTests; | ||
|
||
use Spatie\RouteAttributes\Tests\TestCase; | ||
use Spatie\RouteAttributes\Tests\TestClasses\Controllers\DomainTestController; | ||
|
||
class DomainAttributeTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_can_apply_a_domain_on_the_url_of_every_method() | ||
{ | ||
$this->routeRegistrar->registerClass(DomainTestController::class); | ||
|
||
$this | ||
->assertRegisteredRoutesCount(2) | ||
->assertRouteRegistered( | ||
DomainTestController::class, | ||
controllerMethod: 'myGetMethod', | ||
uri: 'my-get-method', | ||
domain: 'my-subdomain.localhost' | ||
) | ||
->assertRouteRegistered( | ||
DomainTestController::class, | ||
controllerMethod: 'myPostMethod', | ||
httpMethod: 'post', | ||
uri: 'my-post-method', | ||
domain: 'my-subdomain.localhost' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Spatie\RouteAttributes\Tests\TestClasses\Controllers; | ||
|
||
use Spatie\RouteAttributes\Attributes\Domain; | ||
use Spatie\RouteAttributes\Attributes\Get; | ||
use Spatie\RouteAttributes\Attributes\Post; | ||
|
||
#[Domain('my-subdomain.localhost')] | ||
class DomainTestController | ||
{ | ||
#[Get('my-get-method')] | ||
public function myGetMethod() | ||
{ | ||
} | ||
|
||
#[Post('my-post-method')] | ||
public function myPostMethod() | ||
{ | ||
} | ||
} |