Skip to content
This repository has been archived by the owner on Nov 8, 2020. It is now read-only.

Commit

Permalink
Ini to newer version
Browse files Browse the repository at this point in the history
  • Loading branch information
klapuch committed Apr 22, 2017
1 parent 6d4ae2a commit b925ab2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Core/HttpRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
final class HttpRoutes implements Routes {
private $ini;

public function __construct(Ini\Ini $ini) {
public function __construct(Ini\Source $ini) {
$this->ini = $ini;
}

Expand Down
34 changes: 17 additions & 17 deletions Tests/Unit/HttpRoutes.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require __DIR__ . '/../bootstrap.php';
final class HttpRoutes extends Tester\TestCase {
public function testExactMatch() {
[$destination, $source] = ['Foo/default', '/foo'];
$routes = new Routing\HttpRoutes(new Ini\Fake([$destination => $source]));
$routes = new Routing\HttpRoutes(new Ini\FakeSource([$destination => $source]));
$uri = new Uri\FakeUri(null, $source);
Assert::equal(
new Routing\HttpRoute($source, $destination, $uri),
Expand All @@ -29,13 +29,13 @@ final class HttpRoutes extends Tester\TestCase {
* @throws \UnexpectedValueException HTTP route does not exist
*/
public function testStrictTypeMatching() {
$list = new Ini\Fake(['Foo/default' => true]);
$list = new Ini\FakeSource(['Foo/default' => true]);
(new Routing\HttpRoutes($list))->match(new Uri\FakeUri(null, '/foo'));
}

public function testStringMatchOnNumber() {
[$destination, $source] = ['5', '/foo'];
$routes = new Routing\HttpRoutes(new Ini\Fake([$destination => $source]));
$routes = new Routing\HttpRoutes(new Ini\FakeSource([$destination => $source]));
$uri = new Uri\FakeUri(null, $source);
Assert::equal(
new Routing\HttpRoute($source, $destination, $uri),
Expand All @@ -45,7 +45,7 @@ final class HttpRoutes extends Tester\TestCase {

public function testAllowingFalseyMatch() {
[$destination, $source] = ['0', '/foo'];
$routes = new Routing\HttpRoutes(new Ini\Fake([$destination => $source]));
$routes = new Routing\HttpRoutes(new Ini\FakeSource([$destination => $source]));
$uri = new Uri\FakeUri(null, $source);
Assert::equal(
new Routing\HttpRoute($source, $destination, $uri),
Expand All @@ -57,11 +57,11 @@ final class HttpRoutes extends Tester\TestCase {
* @throws \UnexpectedValueException HTTP route does not exist
*/
public function testThrowingOnNoMatch() {
(new Routing\HttpRoutes(new Ini\Fake([])))->match(new Uri\FakeUri(null, ''));
(new Routing\HttpRoutes(new Ini\FakeSource([])))->match(new Uri\FakeUri(null, ''));
}

public function testCaseInsensitiveMatch() {
$ini = new Ini\Fake(['Foo/default' => '/foo', 'Bar/default' => '/BaR']);
$ini = new Ini\FakeSource(['Foo/default' => '/foo', 'Bar/default' => '/BaR']);
$routes = new Routing\HttpRoutes($ini);
$fooUri = new Uri\FakeUri(null, '/foo');
$barUri = new Uri\FakeUri(null, '/BaR');
Expand All @@ -76,7 +76,7 @@ final class HttpRoutes extends Tester\TestCase {
}

public function testMultibyteCaseInsensitiveMatch() {
$ini = new Ini\Fake(['Foo/default' => '/foó', 'Bar/default' => '/BaŘ']);
$ini = new Ini\FakeSource(['Foo/default' => '/foó', 'Bar/default' => '/BaŘ']);
$routes = new Routing\HttpRoutes($ini);
$fooUri = new Uri\FakeUri(null, '/foó');
$barUri = new Uri\FakeUri(null, '/BaŘ');
Expand All @@ -92,7 +92,7 @@ final class HttpRoutes extends Tester\TestCase {

public function testMultiplePossibilitiesWithFirstMatch() {
[$destination, $source] = ['Foo/default', '/foo'];
$ini = new Ini\Fake([$destination => $source, 'Bar/default' => $source]);
$ini = new Ini\FakeSource([$destination => $source, 'Bar/default' => $source]);
$routes = new Routing\HttpRoutes($ini);
$uri = new Uri\FakeUri(null, $source);
Assert::equal(
Expand All @@ -103,7 +103,7 @@ final class HttpRoutes extends Tester\TestCase {

public function testMatchWithSinglePlaceholder() {
[$destination, $source] = ['Foo/default', '/books/{id}'];
$ini = new Ini\Fake([$destination => $source]);
$ini = new Ini\FakeSource([$destination => $source]);
$routes = new Routing\HttpRoutes($ini);
$uri = new Uri\FakeUri(null, '/books/1');
Assert::equal(
Expand All @@ -117,7 +117,7 @@ final class HttpRoutes extends Tester\TestCase {
*/
public function testThrowingOnPlaceholderAsNestedParameter() {
[$destination, $source] = ['Foo/default', '/books/{id}'];
$ini = new Ini\Fake([$destination => $source]);
$ini = new Ini\FakeSource([$destination => $source]);
$routes = new Routing\HttpRoutes($ini);
$routes->match(new Uri\FakeUri(null, '/books/foo/bar'));
}
Expand All @@ -127,7 +127,7 @@ final class HttpRoutes extends Tester\TestCase {
*/
public function testThrowingOnSomePlaceholderMatch() {
[$destination, $source] = ['Foo/default', '/books/{id}'];
$ini = new Ini\Fake([$destination => $source]);
$ini = new Ini\FakeSource([$destination => $source]);
$routes = new Routing\HttpRoutes($ini);
$routes->match(new Uri\FakeUri(null, 'blabla/books/foo'));
}
Expand All @@ -137,14 +137,14 @@ final class HttpRoutes extends Tester\TestCase {
*/
public function testThrowingOnDirectPlaceholderParameter() {
[$destination, $source] = ['Foo/default', '/books/{id}'];
$ini = new Ini\Fake([$destination => $source]);
$ini = new Ini\FakeSource([$destination => $source]);
$routes = new Routing\HttpRoutes($ini);
$routes->match(new Uri\FakeUri(null, $source));
}

public function testMatchMultipleDifferentPlaceholders() {
[$destination, $source] = ['Foo/default', '/books/{id}/foo/{key}'];
$ini = new Ini\Fake([$destination => $source]);
$ini = new Ini\FakeSource([$destination => $source]);
$routes = new Routing\HttpRoutes($ini);
$uri = new Uri\FakeUri(null, '/books/1/foo/nwm');
Assert::equal(
Expand All @@ -155,7 +155,7 @@ final class HttpRoutes extends Tester\TestCase {

public function testMatchMultipleDifferentPlaceholdersInRow() {
[$destination, $source] = ['Foo/default', '/books/{id}/{key}'];
$ini = new Ini\Fake([$destination => $source]);
$ini = new Ini\FakeSource([$destination => $source]);
$routes = new Routing\HttpRoutes($ini);
$uri = new Uri\FakeUri(null, '/books/1/nwm');
Assert::equal(
Expand All @@ -166,7 +166,7 @@ final class HttpRoutes extends Tester\TestCase {

public function testMatchMultipleSamePlaceholdersInRow() {
[$destination, $source] = ['Foo/default', '/books/{id}/{id}'];
$ini = new Ini\Fake([$destination => $source]);
$ini = new Ini\FakeSource([$destination => $source]);
$routes = new Routing\HttpRoutes($ini);
$uri = new Uri\FakeUri(null, '/books/1/5');
Assert::equal(
Expand All @@ -177,7 +177,7 @@ final class HttpRoutes extends Tester\TestCase {

public function testMatchWithRegex() {
[$destination, $source] = ['Foo/default', '/books/{id \d}/{key \w+}'];
$ini = new Ini\Fake([$destination => $source]);
$ini = new Ini\FakeSource([$destination => $source]);
$routes = new Routing\HttpRoutes($ini);
$uri = new Uri\FakeUri(null, '/books/1/bar');
Assert::equal(
Expand All @@ -191,7 +191,7 @@ final class HttpRoutes extends Tester\TestCase {
*/
public function testThrowingOnNoRegexMatch() {
[$destination, $source] = ['Foo/default', '/books/{id \d}'];
$ini = new Ini\Fake([$destination => $source]);
$ini = new Ini\FakeSource([$destination => $source]);
$routes = new Routing\HttpRoutes($ini);
$routes->match(new Uri\FakeUri(null, '/books/10'));
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"php": ">=7.1",
"klapuch/ini": "^1.0",
"klapuch/ini": "^2.0",
"klapuch/uri": "^2.0"
},
"require-dev": {
Expand Down

0 comments on commit b925ab2

Please sign in to comment.