{
- "name" : "axas/php-router",
- "description": "Simple PHP Router, supports REST and reverse routing.",
- "keywords" : [
+ "name" : "frostbane/php-router",
+ "description" : "Simple PHP Router, supports REST and reverse routing.",
+ "keywords" : [
"router",
"routing",
"rest"
],
- "homepage" : "https://github.com/dannyvankooten/PHP-Router",
- "license" : "MIT",
- "authors" : [
+ "homepage" : "https://github.com/dannyvankooten/PHP-Router",
+ "license" : "MIT",
+ "authors" : [
{
"name" : "Danny van Kooten",
"email" : "dannyvankooten@gmail.com",
"email": "malukenho@phpse.net"
}
],
- "require" : {
+ "require" : {
"php" : "^5.3.0|^7.0",
"fig/http-message-util": "^1.1"
},
- "require-dev": {
+ "require-dev" : {
"malukenho/docheader" : "^0.1.5",
"phpunit/phpunit" : "4.8.*",
"squizlabs/php_codesniffer": "2.*"
},
- "autoload" : {
+ "autoload" : {
"psr-4": {
"PHPRouter\\": "src/"
}
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "PHPRouter\\Test\\" : "tests/src/PHPRouterTest/",
+ "PHPRouter\\Test\\Fixtures\\": "tests/Fixtures/"
+ }
}
}
<?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
- backupGlobals="true"
+<phpunit backupGlobals="false"
backupStaticAttributes="false"
+ bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
- bootstrap="tests/Bootstrap.php">
-
+ processIsolation="false"
+ stopOnFailure="true">
<testsuites>
<testsuite name="PHP Router">
<directory>tests</directory>
<whitelist>
<directory>./</directory>
<exclude>
- <directory>./tests</directory>
+ <directory>./tests/Fixtures</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
<logging>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="true"/>
- <log type="coverage-clover" target="build/logs/clover.xml"/>
+ <log type="coverage-clover" target="logs/clover.xml"/>
</logging>
</phpunit>
+++ /dev/null
-<?php
-
-/**
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the MIT license.
- */
-
-error_reporting(E_ALL);
-if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
- date_default_timezone_set(@date_default_timezone_get());
-}
-
-require_once __DIR__ . '/../vendor/autoload.php';
-require __DIR__ . '/Fixtures/SomeController.php';
*/
public function testMatch($router, $path, $expected)
{
- self::assertEquals($expected, (bool)$router->match($path));
+ $result = $router->match($path);
+
+ $this->assertEquals($expected, $result);
}
public function testMatchWrongMethod()
{
$router = $this->getRouter();
- self::assertFalse($router->match('/users', 'POST'));
+ $this->assertFalse($router->match('/users', 'POST'));
}
public function testBasePathConfigIsSettedProperly()
$router = new Router(new RouteCollection);
$router->setBasePath('/webroot/');
- self::assertAttributeEquals('/webroot', 'basePath', $router);
+ $this->assertAttributeEquals('/webroot', 'basePath', $router);
}
public function testMatchRouterUsingBasePath()
{
$collection = new RouteCollection();
$collection->attach(new Route('/users/', array(
- '_controller' => 'PHPRouter\Test\SomeController::usersCreate',
+ '_controller' => '\PHPRouter\Test\Fixtures\SomeController::usersCreate',
'methods' => 'GET'
)));
foreach ($this->serverProvider() as $server) {
$_SERVER = $server;
- self::assertTrue((bool)$router->matchCurrentRequest());
+ $this->assertTrue((bool)$router->matchCurrentRequest());
}
}
$route = new Route(
'/page/:page_id',
array(
- '_controller' => 'PHPRouter\Test\SomeController::page',
+ '_controller' => '\PHPRouter\Test\Fixtures\SomeController::page',
'methods' => 'GET'
)
);
$collection->attachRoute($route);
$router = new Router($collection);
- self::assertEquals(
+ $this->assertEquals(
array(array('page_id' => 'MySuperPage')),
$router->match('/page/MySuperPage')->getParameters()
);
$route = new Route(
'/js/:filename.js',
array(
- '_controller' => 'PHPRouter\Test\SomeController::dynamicFilterUrlMatch',
+ '_controller' => '\PHPRouter\Test\Fixtures\SomeController::dynamicFilterUrlMatch',
'methods' => 'GET',
)
);
$collection->attachRoute($route);
$router = new Router($collection);
- self::assertEquals(
+ $this->assertEquals(
array(array('filename' => 'someJsFile')),
$router->match('/js/someJsFile.js')->getParameters()
);
- self::assertEquals(
+ $this->assertEquals(
array(array('filename' => 'someJsFile.min')),
$router->match('/js/someJsFile.min.js')->getParameters()
);
- self::assertEquals(
+ $this->assertEquals(
array(array('filename' => 'someJsFile.min.js')),
$router->match('/js/someJsFile.min.js.js')->getParameters()
);
{
$config = Config::loadFromFile(__DIR__ . '/../../Fixtures/router.yaml');
$router = Router::parseConfig($config);
- self::assertAttributeEquals($config['base_path'], 'basePath', $router);
+ $this->assertAttributeEquals($config['base_path'], 'basePath', $router);
}
public function testGenerate()
{
$router = $this->getRouter();
- self::assertSame('/users/', $router->generate('users'));
- self::assertSame('/user/123', $router->generate('user', array('id' => 123)));
+ $this->assertSame('/users/', $router->generate('users'));
+ $this->assertSame('/user/123', $router->generate('user', array('id' => 123)));
}
/**
public function testGenerateNotExistent()
{
$router = $this->getRouter();
- self::assertSame('/notExists/', $router->generate('notThisRoute'));
+ $this->assertSame('/notExists/', $router->generate('notThisRoute'));
}
/**
{
$collection = new RouteCollection();
$collection->attachRoute(new Route('/users/', array(
- '_controller' => 'PHPRouter\Test\SomeController::usersCreate',
+ '_controller' => '\PHPRouter\Test\Fixtures\SomeController::usersCreate',
'methods' => 'GET',
'name' => 'users'
)));
$collection->attachRoute(new Route('/user/:id', array(
- '_controller' => 'PHPRouter\Test\SomeController::user',
+ '_controller' => '\PHPRouter\Test\Fixtures\SomeController::user',
'methods' => 'GET',
'name' => 'user'
)));
$collection->attachRoute(new Route('/', array(
- '_controller' => 'PHPRouter\Test\SomeController::indexAction',
+ '_controller' => '\PHPRouter\Test\Fixtures\SomeController::indexAction',
'methods' => 'GET',
'name' => 'index'
)));