-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathOriginTest.php
45 lines (43 loc) · 1.57 KB
/
OriginTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/*
* This file is part of Aplus Framework Routing Library.
*
* (c) Natan Felles <natanfelles@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tests\Routing\Attributes;
use Attribute;
use Framework\Routing\Attributes\Origin;
use PHPUnit\Framework\TestCase;
use ReflectionObject;
use Tests\Routing\Support\UsersRouteActionsResource;
final class OriginTest extends TestCase
{
public function testAttributes() : void
{
$reflection = new ReflectionObject(new UsersRouteActionsResource());
$attributes = $reflection->getAttributes();
$origin = $attributes[0];
self::assertSame(Origin::class, $origin->getName());
self::assertSame(['http://domain.com'], $origin->getArguments());
self::assertSame(Attribute::TARGET_CLASS, $origin->getTarget());
self::assertTrue($origin->isRepeated());
/**
* @var Origin $instance
*/
$instance = $origin->newInstance();
self::assertSame('http://domain.com', $instance->getOrigin());
$origin = $attributes[1];
self::assertSame(Origin::class, $origin->getName());
self::assertSame(['http://api.domain.xyz'], $origin->getArguments());
self::assertSame(Attribute::TARGET_CLASS, $origin->getTarget());
self::assertTrue($origin->isRepeated());
/**
* @var Origin $instance
*/
$instance = $origin->newInstance();
self::assertSame('http://api.domain.xyz', $instance->getOrigin());
}
}