diff --git a/src/blocks/Routes.php b/src/blocks/Routes.php index c129da2..e484d6a 100644 --- a/src/blocks/Routes.php +++ b/src/blocks/Routes.php @@ -30,7 +30,7 @@ public function setCodeState($generator) $this->generator = $generator; } - public function create() + public function create() : void { $this->setRoutes(); $isCreated = false; @@ -53,7 +53,7 @@ public function create() } } - private function setRoutes() + private function setRoutes() : void { $this->setTag(); $this->setComment(DefaultInterface::ROUTES_START, 0); diff --git a/tests/unit/blocks/RouterTest.php b/tests/unit/blocks/RouterTest.php new file mode 100644 index 0000000..c5ba64d --- /dev/null +++ b/tests/unit/blocks/RouterTest.php @@ -0,0 +1,58 @@ +gen = new RJApiGenerator(); + $this->gen->modulesDir = DirsInterface::MODULES_DIR; + $this->gen->controllersDir = DirsInterface::CONTROLLERS_DIR; + $this->gen->httpDir = DirsInterface::HTTP_DIR; + $this->gen->version = self::MODULE_NAME; + $ramlData = Yaml::parse(file_get_contents(__DIR__ . '/../../functional/raml/articles.raml')); + $this->gen->types = $ramlData[RamlInterface::RAML_KEY_TYPES]; + $this->gen->objectProps = [ + 'type' => 'Type', + 'id' => 'ID', + 'attributes' => 'ArticleAttributes', + 'relationships' => [ + 'type' => 'TagRelationships[] | TopicRelationships', + ] + ]; + $this->router = new Routes($this->gen); + $this->router->setCodeState($this->gen); + } + + /** + * @test + */ + public function it_creates_routes() + { + $this->router->create(); + $this->assertArraySubset([ + ContentManager::class => ContentManager::class, + RoutesTrait::class => RoutesTrait::class, + ], class_uses($this->router)); + } +} \ No newline at end of file diff --git a/tests/unit/extension/BaseFormRequestTest.php b/tests/unit/extension/BaseFormRequestTest.php new file mode 100644 index 0000000..763fdcb --- /dev/null +++ b/tests/unit/extension/BaseFormRequestTest.php @@ -0,0 +1,53 @@ +baseFormRequest = new BaseFormRequest(); + } + + /** + * @test + */ + public function it_handles_request() + { + $this->assertInstanceOf(Request::class, $this->baseFormRequest->handle(new Request(), function($request) { + return $request; + })); + } + + /** + * @test + */ + public function it_gets_query() + { + $this->assertInternalType(IsType::TYPE_ARRAY, $this->baseFormRequest->rules()); + } + + /** + * @test + */ + public function it_get_bindings() + { + $this->assertInternalType(IsTYpe::TYPE_ARRAY, $this->baseFormRequest->relations()); + } +} \ No newline at end of file