2015-10-09 14:34:55 -04:00
|
|
|
<?php
|
|
|
|
|
2017-02-15 11:49:38 -05:00
|
|
|
namespace Aviat\AnimeClient\Tests;
|
|
|
|
|
2015-10-09 14:34:55 -04:00
|
|
|
use Aviat\AnimeClient\RoutingBase;
|
|
|
|
|
|
|
|
class RoutingBaseTest extends AnimeClient_TestCase {
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
$this->routingBase = new RoutingBase($this->container);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dataSegments()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'empty_segment' => [
|
2017-02-15 11:57:29 -05:00
|
|
|
'requestUri' => ' // ',
|
2015-10-09 14:34:55 -04:00
|
|
|
'path' => '/',
|
|
|
|
'segments' => ['', ''],
|
|
|
|
'last_segment' => NULL
|
|
|
|
],
|
|
|
|
'three_segments' => [
|
2017-02-15 11:57:29 -05:00
|
|
|
'requestUri' => '/anime/watching/list ',
|
2015-10-09 14:34:55 -04:00
|
|
|
'path' => '/anime/watching/list',
|
|
|
|
'segments' => ['', 'anime', 'watching', 'list'],
|
|
|
|
'last_segment' => 'list'
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider dataSegments
|
|
|
|
*/
|
2017-02-15 16:11:52 -05:00
|
|
|
public function testSegments($requestUri, $path, $segments, $lastSegment)
|
2015-10-09 14:34:55 -04:00
|
|
|
{
|
|
|
|
$this->setSuperGlobals([
|
|
|
|
'_SERVER' => [
|
2017-02-15 11:57:29 -05:00
|
|
|
'REQUEST_URI' => $requestUri
|
2015-10-09 14:34:55 -04:00
|
|
|
]
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals($path, $this->routingBase->path(), "Path is invalid");
|
|
|
|
$this->assertEquals($segments, $this->routingBase->segments(), "Segments array is invalid");
|
2017-02-15 16:11:52 -05:00
|
|
|
$this->assertEquals($lastSegment, $this->routingBase->last_segment(), "Last segment is invalid");
|
2015-10-09 14:34:55 -04:00
|
|
|
|
|
|
|
foreach($segments as $i => $value)
|
|
|
|
{
|
|
|
|
$this->assertEquals($value, $this->routingBase->get_segment($i), "Segment {$i} is invalid");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|