From 822f9669f51f48dcc553c6f7113bca79a19c824f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimondas=20Rimkevi=C4=8Dius?= Date: Tue, 2 Apr 2024 06:26:20 +0300 Subject: [PATCH 1/5] sunrise/http-router bumped up to v3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 40e1817..44f9f8d 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "require": { "imponeer/smarty-extensions-contracts": "^3.0", "php": "^7.3 || ^8.0", - "sunrise/http-router": "^2" + "sunrise/http-router": "^3" }, "license": "MIT", "authors": [ From a60a03789307b5af3a49668c10d22f69dba8c0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimondas=20Rimkevi=C4=8Dius?= Date: Tue, 2 Apr 2024 06:29:50 +0300 Subject: [PATCH 2/5] on-pull-request with php 8.x only --- .github/workflows/on-pull-request.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/on-pull-request.yml b/.github/workflows/on-pull-request.yml index 13c2f3e..e993f15 100644 --- a/.github/workflows/on-pull-request.yml +++ b/.github/workflows/on-pull-request.yml @@ -13,11 +13,10 @@ jobs: max-parallel: 3 matrix: php: - - 7.3 - - 7.4 - 8.0 - 8.1 - 8.2 + - 8.3 name: Test - php:${{ matrix.php }}; composer:${{ matrix.composer }} steps: - name: Checkout From 35f9dbc9ad21d6c522ecb78e8db3c4e8266f3d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimondas=20Rimkevi=C4=8Dius?= Date: Tue, 2 Apr 2024 06:31:52 +0300 Subject: [PATCH 3/5] "minimum-stability": "beta", --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 44f9f8d..356230c 100644 --- a/composer.json +++ b/composer.json @@ -4,10 +4,11 @@ "type": "library", "require": { "imponeer/smarty-extensions-contracts": "^3.0", - "php": "^7.3 || ^8.0", + "php": "^8.1", "sunrise/http-router": "^3" }, "license": "MIT", + "minimum-stability": "beta", "authors": [ { "name": "Raimondas Rimkevičius (aka MekDrop)", From d2e7519f1398d248e88ef17df026263afcb17ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimondas=20Rimkevi=C4=8Dius?= Date: Tue, 2 Apr 2024 06:32:21 +0300 Subject: [PATCH 4/5] testing with 8.0 removed; min php 8.1 --- .github/workflows/on-pull-request.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/on-pull-request.yml b/.github/workflows/on-pull-request.yml index e993f15..5ef21bf 100644 --- a/.github/workflows/on-pull-request.yml +++ b/.github/workflows/on-pull-request.yml @@ -13,7 +13,6 @@ jobs: max-parallel: 3 matrix: php: - - 8.0 - 8.1 - 8.2 - 8.3 From 0aed75584f159849fb7c7fe5e152847b389ecf46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimondas=20Rimkevi=C4=8Dius?= Date: Tue, 2 Apr 2024 06:54:37 +0300 Subject: [PATCH 5/5] Fixed passing tests --- src/UrlFunction.php | 2 +- tests/UrlFunctionTest.php | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/UrlFunction.php b/src/UrlFunction.php index 6796cc4..b8ea920 100644 --- a/src/UrlFunction.php +++ b/src/UrlFunction.php @@ -55,6 +55,6 @@ public function execute($params, Smarty_Internal_Template $template) throw new SmartyException('name not set for url function'); } - return $this->router->generateUri($params['name'], $attributes); + return $this->router->buildRoute($params['name'], $attributes); } } \ No newline at end of file diff --git a/tests/UrlFunctionTest.php b/tests/UrlFunctionTest.php index 0139a0f..722806a 100644 --- a/tests/UrlFunctionTest.php +++ b/tests/UrlFunctionTest.php @@ -2,10 +2,9 @@ use Imponeer\Smarty\Extensions\SunriseHTTPRouter\UrlFunction; use PHPUnit\Framework\TestCase; -use Sunrise\Http\Router\Exception\MissingAttributeValueException; -use Sunrise\Http\Router\Exception\RouteNotFoundException; +use Sunrise\Http\Router\Exception\InvalidRouteBuildingValueException; +use Sunrise\Http\Router\Exception\NoRouteFoundException; use Sunrise\Http\Router\Route; -use Sunrise\Http\Router\RouteCollector; use Sunrise\Http\Router\Router; class UrlFunctionTest extends TestCase @@ -21,17 +20,18 @@ class UrlFunctionTest extends TestCase protected function setUp(): void { - $collector = new RouteCollector(); - $collector->get("home", "/", function ($request) { - return "test"; - }); - $collector->get("test", "/test/{a}", function ($request) { - return "test 2"; - }); - - $router = new Router(); + $router = new Sunrise\Http\Router\Router(); $router->addRoute( - ...$collector->getCollection()->all() + new Route("home", "/", function ($request) { + return "test"; + }, [ + "GET" + ]), + new Route("test", "/test/{a}", function ($request) { + return "test 2"; + }, [ + "GET" + ]), ); $this->plugin = new UrlFunction($router); @@ -63,7 +63,7 @@ public function testInvokingWithCorrectAttributes() { public function testInvokingWithIncorrectAttributes() { $src = urlencode('{url name="test" attributes=["b" => "x"]}'); - $this->expectException(MissingAttributeValueException::class); + $this->expectException(InvalidRouteBuildingValueException::class); $this->smarty->fetch('eval:urlencode:'.$src); } @@ -76,7 +76,7 @@ public function testInvokingWithoutAttributes() { public function testInvokingWithInvalidRouteName() { $src = urlencode('{url name="home2"}'); - $this->expectException(RouteNotFoundException::class); + $this->expectException(NoRouteFoundException::class); $this->smarty->fetch('eval:urlencode:'.$src); }