Repository navigation
Expand file tree
/
Copy pathMappingAnnotationTest.php
More file actions
65 lines (57 loc) · 1.8 KB
/
Copy pathMappingAnnotationTest.php
File metadata and controls
65 lines (57 loc) · 1.8 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace HyperfTest\HttpServer;
use Hyperf\HttpServer\Annotation\RequestMapping;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;
/**
* @internal
* @coversNothing
*/
#[CoversNothing]
class MappingAnnotationTest extends TestCase
{
public function testRequestMapping()
{
$mapping = new RequestMapping();
// Assert default methods
$this->assertSame(['GET', 'POST'], $mapping->methods);
$this->assertNull($mapping->path);
// Normal case
$mapping = new RequestMapping(
$path = '/foo',
'get,post,put',
['id' => $id = uniqid()]
);
$this->assertSame(['GET', 'POST', 'PUT'], $mapping->methods);
$this->assertSame($path, $mapping->path);
$this->assertSame($id, $mapping->options['id']);
// The methods have space
$mapping = new RequestMapping($path, 'get, post, put');
$this->assertSame(['GET', 'POST', 'PUT'], $mapping->methods);
$this->assertSame($path, $mapping->path);
}
public function testRequestMappingWithArrayMethods()
{
$mapping = new RequestMapping(
$path = '/foo',
['GET', 'POST ', 'put']
);
$this->assertSame(['GET', 'POST', 'PUT'], $mapping->methods);
$this->assertSame($path, $mapping->path);
}
public function testRequestMappingBindMainProperty()
{
$mapping = new RequestMapping('/foo');
$this->assertSame(['GET', 'POST'], $mapping->methods);
$this->assertSame('/foo', $mapping->path);
}
}