2017-02-16 11:09:37 -05:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
/**
|
|
|
|
* Hummingbird Anime List Client
|
|
|
|
*
|
2018-08-22 13:48:27 -04:00
|
|
|
* An API client for Kitsu to manage anime and manga watch lists
|
2017-02-16 11:09:37 -05:00
|
|
|
*
|
2018-10-01 11:35:51 -04:00
|
|
|
* PHP version 7.1
|
2017-02-16 11:09:37 -05:00
|
|
|
*
|
|
|
|
* @package HummingbirdAnimeClient
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2018-01-15 14:43:15 -05:00
|
|
|
* @copyright 2015 - 2018 Timothy J. Warren
|
2017-02-16 11:09:37 -05:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2018-10-01 11:35:51 -04:00
|
|
|
* @version 4.1
|
2017-03-07 20:53:58 -05:00
|
|
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
2017-02-16 11:09:37 -05:00
|
|
|
*/
|
2015-10-09 14:34:55 -04:00
|
|
|
|
2017-02-15 11:49:38 -05:00
|
|
|
namespace Aviat\AnimeClient\Tests;
|
|
|
|
|
2015-10-09 14:34:55 -04:00
|
|
|
use Aviat\AnimeClient\RoutingBase;
|
|
|
|
|
2017-02-15 16:40:18 -05:00
|
|
|
class RoutingBaseTest extends AnimeClientTestCase {
|
2017-02-22 15:08:29 -05:00
|
|
|
|
|
|
|
protected $routingBase;
|
2015-10-09 14:34:55 -04:00
|
|
|
|
|
|
|
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' => ['', ''],
|
2017-02-15 16:30:14 -05:00
|
|
|
'lastSegment' => NULL
|
2015-10-09 14:34:55 -04:00
|
|
|
],
|
|
|
|
'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'],
|
2017-02-15 16:30:14 -05:00
|
|
|
'lastSegment' => 'list'
|
2015-10-09 14:34:55 -04:00
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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:30:14 -05:00
|
|
|
$this->assertEquals($lastSegment, $this->routingBase->lastSegment(), "Last segment is invalid");
|
2015-10-09 14:34:55 -04:00
|
|
|
|
|
|
|
foreach($segments as $i => $value)
|
|
|
|
{
|
2017-02-15 16:30:14 -05:00
|
|
|
$this->assertEquals($value, $this->routingBase->getSegment($i), "Segment {$i} is invalid");
|
2015-10-09 14:34:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|