Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<testsuite name="Rudra-Router">
<directory suffix=".php">tests</directory>
<exclude>tests/Stub</exclude>
<exclude>tests/RouterAnnotationTraitTest.php</exclude>
</testsuite>
</testsuites>
<source>
Expand Down
59 changes: 59 additions & 0 deletions tests/RouterAnnotationTraitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

declare(strict_types=1);

/**
* @author : Jagepard <jagepard@yandex.ru">
* @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"));
// }
}
Loading