From 64b925e5d4ad9820ca19cc0676e7d149a2e77d76 Mon Sep 17 00:00:00 2001 From: Jagepard Date: Thu, 26 Jun 2025 17:52:16 +0300 Subject: [PATCH] add tests/RouterAnnotationTraitTest.php --- phpunit.xml | 1 + tests/RouterAnnotationTraitTest.php | 59 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 tests/RouterAnnotationTraitTest.php diff --git a/phpunit.xml b/phpunit.xml index dcf711ce..df697a00 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -16,6 +16,7 @@ tests tests/Stub + tests/RouterAnnotationTraitTest.php diff --git a/tests/RouterAnnotationTraitTest.php b/tests/RouterAnnotationTraitTest.php new file mode 100644 index 00000000..4ce86d45 --- /dev/null +++ b/tests/RouterAnnotationTraitTest.php @@ -0,0 +1,59 @@ + + * @license https://mit-license.org/ MIT + */ + +namespace Rudra\Router\Tests; + +use Rudra\Container\{Facades\Rudra,Interfaces\RudraInterface}; +use Rudra\Annotation\Annotation; +use Rudra\Router\Router as Rtr; +use Rudra\Router\RouterFacade as Router; +use PHPUnit\Framework\TestCase as PHPUnit_Framework_TestCase; + +class RouterAnnotationTraitTest extends PHPUnit_Framework_TestCase +{ + protected function setContainer() + { + Rudra::binding([RudraInterface::class => Rudra::run()]); + Rudra::services(["router" => [Rtr::class, "stub\\"]]); + Rudra::set([Annotation::class, Annotation::class]); + Router::setNamespace("Rudra\\Router\\Tests\\Stub\\"); + } + + public function testAnnotation() + { + $_SERVER["REQUEST_URI"] = "test/123"; + $_SERVER["REQUEST_METHOD"] = "GET"; + + $this->setContainer(); + Router::annotation("MainController", "actionIndex"); + $this->assertEquals("actionIndex", Rudra::config()->get("actionIndex")); + } + +// public function testAnnotationCollector() +// { +// $_SERVER["REQUEST_URI"] = "test/123"; +// $_SERVER["REQUEST_METHOD"] = "GET"; + +// $this->setContainer(); +// Router::annotationCollector([["MainController", "actionIndex"]]); + +// $this->assertEquals("actionIndex", Rudra::config()->get("actionIndex")); +// } + +// public function testAnnotationCollectorMultilevel() +// { +// $_SERVER["REQUEST_URI"] = "test/123"; +// $_SERVER["REQUEST_METHOD"] = "GET"; + +// $this->setContainer(); +// Router::annotationCollector(["blog" => ["MainController", "actionIndex"]]); + +// $this->assertEquals("actionIndex", Rudra::config()->get("actionIndex")); +// } +}