|
14 | 14 | use Illuminate\Container\Attributes\CurrentUser;
|
15 | 15 | use Illuminate\Container\Attributes\Database;
|
16 | 16 | use Illuminate\Container\Attributes\Log;
|
| 17 | +use Illuminate\Container\Attributes\RouteParameter; |
17 | 18 | use Illuminate\Container\Attributes\Storage;
|
18 | 19 | use Illuminate\Container\Attributes\Tag;
|
19 | 20 | use Illuminate\Container\Container;
|
|
24 | 25 | use Illuminate\Contracts\Filesystem\Filesystem;
|
25 | 26 | use Illuminate\Database\Connection;
|
26 | 27 | use Illuminate\Database\DatabaseManager;
|
| 28 | +use Illuminate\Database\Eloquent\Model; |
27 | 29 | use Illuminate\Filesystem\FilesystemManager;
|
| 30 | +use Illuminate\Http\Request; |
28 | 31 | use Illuminate\Log\LogManager;
|
29 | 32 | use Mockery as m;
|
30 | 33 | use PHPUnit\Framework\TestCase;
|
@@ -197,6 +200,20 @@ public function testLogAttribute()
|
197 | 200 | $container->make(LogTest::class);
|
198 | 201 | }
|
199 | 202 |
|
| 203 | + public function testRouteParameterAttribute() |
| 204 | + { |
| 205 | + $container = new Container; |
| 206 | + $container->singleton('request', function () { |
| 207 | + $request = m::mock(Request::class); |
| 208 | + $request->shouldReceive('route')->with('foo')->andReturn(m::mock(Model::class)); |
| 209 | + $request->shouldReceive('route')->with('bar')->andReturn('bar'); |
| 210 | + |
| 211 | + return $request; |
| 212 | + }); |
| 213 | + |
| 214 | + $container->make(RouteParameterTest::class); |
| 215 | + } |
| 216 | + |
200 | 217 | public function testStorageAttribute()
|
201 | 218 | {
|
202 | 219 | $container = new Container;
|
@@ -428,6 +445,13 @@ public function __construct(#[Log('foo')] LoggerInterface $foo, #[Log('bar')] Lo
|
428 | 445 | }
|
429 | 446 | }
|
430 | 447 |
|
| 448 | +final class RouteParameterTest |
| 449 | +{ |
| 450 | + public function __construct(#[RouteParameter('foo')] Model $foo, #[RouteParameter('bar')] string $bar) |
| 451 | + { |
| 452 | + } |
| 453 | +} |
| 454 | + |
431 | 455 | final class StorageTest
|
432 | 456 | {
|
433 | 457 | public function __construct(#[Storage('foo')] Filesystem $foo, #[Storage('bar')] Filesystem $bar)
|
|
0 commit comments