/
RouterIndexTest.php
57 lines (49 loc) · 1.53 KB
/
RouterIndexTest.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
<?php
/*
* This file is part of Chevere.
*
* (c) Rodolfo Berrios <rodolfo@chevere.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
/*
* This file is part of Chevere.
*
* (c) Rodolfo Berrios <rodolfo@chevere.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chevere\Tests\Router\Properties;
use BadMethodCallException;
use Chevere\Components\Regex\Regex;
use Chevere\Components\Route\PathUri;
use Chevere\Components\Router\RouterIndex;
use Chevere\Components\Router\RouterNamed;
use Chevere\Components\Router\RouterRegex;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
final class RouterIndexTest extends TestCase
{
public function testConstruct(): void
{
$pathUri = new PathUri('/path');
$routerIndex = new RouterIndex();
$this->assertSame([], $routerIndex->toArray());
$this->assertFalse($routerIndex->has($pathUri));
$this->expectException(BadMethodCallException::class);
$routerIndex->get($pathUri);
}
public function testWithAdded(): void
{
$patUri = new PathUri('/path');
$id = 0;
$routerIndex = (new RouterIndex())
->withAdded($patUri, $id, 'some-group', 'some-name');
$this->assertTrue($routerIndex->has($patUri));
$this->assertIsArray($routerIndex->get($patUri));
}
}