-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRouterParamsTest.php
58 lines (45 loc) · 1.28 KB
/
RouterParamsTest.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
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
declare(strict_types=1);
namespace Qubus\Tests\Routing;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;
use Qubus\Routing\Route\RouteParams;
class RouterParamsTest extends TestCase
{
/** @test */
public function canGetParamByKey()
{
$params = new RouteParams(['key' => 'value']);
Assert::assertSame('value', $params->key);
}
/** @test */
public function canIterateAllKeysAndValues()
{
$params = new RouteParams([
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3',
]);
$keys = [];
$values = [];
foreach ($params as $key => $value) {
$keys[] = $key;
$values[] = $value;
}
Assert::assertSame(['key1', 'key2', 'key3'], $keys);
Assert::assertSame(['value1', 'value2', 'value3'], $values);
}
/** @test */
public function returnNullWhenaKeyIsNotFound()
{
$params = new RouteParams(['key' => 'value']);
Assert::assertNull($params->invalid);
}
/** @test */
public function canGetParamsAsArray()
{
$data = ['key1' => 'value1', 'key2' => 'value2'];
$params = new RouteParams($data);
Assert::assertSame($data, $params->toArray());
}
}