diff --git a/clover.xml b/clover.xml index e336ad5..7d4d849 100644 --- a/clover.xml +++ b/clover.xml @@ -1,6 +1,6 @@ - - + + @@ -16,7 +16,7 @@ - + @@ -40,103 +40,103 @@ - + - - - - - - + + + + + + - + - - - - - - - - + + + + + + + + - + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - + - + @@ -145,59 +145,59 @@ - - - - - - - - + + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - - + + @@ -205,11 +205,11 @@ - + - + @@ -269,12 +269,12 @@ - - - - - - + + + + + + @@ -285,13 +285,13 @@ - - - - - - - + + + + + + + @@ -361,8 +361,8 @@ - - + + @@ -379,7 +379,7 @@ - + @@ -2616,8 +2616,8 @@ - - + + @@ -2844,14 +2844,14 @@ - - - - - - - - + + + + + + + + @@ -2980,6 +2980,6 @@ - + diff --git a/src/blocks/FileManager.php b/src/blocks/FileManager.php index b2a1cc5..5507b67 100644 --- a/src/blocks/FileManager.php +++ b/src/blocks/FileManager.php @@ -3,7 +3,7 @@ namespace rjapi\blocks; use Illuminate\Console\Command; -use rjapi\exception\DirectoryException; +use rjapi\exceptions\DirectoryException; use rjapi\helpers\ConfigHelper; use rjapi\RJApiGenerator; use rjapi\types\ConsoleInterface; diff --git a/src/controllers/BaseCommand.php b/src/controllers/BaseCommand.php index 9c4b7e8..2572547 100644 --- a/src/controllers/BaseCommand.php +++ b/src/controllers/BaseCommand.php @@ -156,7 +156,7 @@ private function generateConfig() } /** - * @throws \rjapi\exception\DirectoryException + * @throws \rjapi\exceptions\DirectoryException */ public function createDirs() { @@ -241,7 +241,7 @@ private function setIncludedTypes(array $data) } /** - * @throws \rjapi\exception\DirectoryException + * @throws \rjapi\exceptions\DirectoryException */ private function setGenHistory() { diff --git a/src/types/ConfigInterface.php b/src/types/ConfigInterface.php index 6b85ab8..0cb3a4b 100644 --- a/src/types/ConfigInterface.php +++ b/src/types/ConfigInterface.php @@ -41,6 +41,7 @@ interface ConfigInterface public const CACHE_METHOD = 'setCacheOptions'; public const JWT_METHOD = 'setJwtOptions'; + // todo: make this prop set via config for tests to run normally public const DEFAULT_ACTIVATE = 30; public const DEFAULT_EXPIRES = 3600; diff --git a/tests/unit/blocks/ConfigTest.php b/tests/unit/blocks/ConfigTest.php index 404cc4b..014f70b 100644 --- a/tests/unit/blocks/ConfigTest.php +++ b/tests/unit/blocks/ConfigTest.php @@ -2,11 +2,12 @@ namespace rjapitest\unit\blocks; use rjapi\blocks\Config; -use rjapi\blocks\ContentManager; use rjapi\RJApiGenerator; use rjapi\types\ConfigInterface; use rjapi\types\DirsInterface; +use rjapi\types\RamlInterface; use rjapitest\unit\TestCase; +use Symfony\Component\Yaml\Yaml; /** * Class ConfigTest @@ -22,10 +23,22 @@ class ConfigTest extends TestCase public function setUp() { parent::setUp(); - $this->gen = new RJApiGenerator(); - $this->gen->modulesDir = DirsInterface::MODULES_DIR; - $this->gen->version = 'V2'; - $this->config = new Config($this->gen); + $this->gen = new RJApiGenerator(); + $this->gen->modulesDir = DirsInterface::MODULES_DIR; + $this->gen->controllersDir = DirsInterface::CONTROLLERS_DIR; + $this->gen->httpDir = DirsInterface::HTTP_DIR; + $this->gen->version = 'V2'; + $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->config = new Config($this->gen); } /** @@ -34,6 +47,7 @@ public function setUp() public function it_creates_config() { $this->assertInstanceOf(ConfigInterface::class, $this->config); + // todo: mock ConfigInterface::DEFAULT_ACTIVATE for jwt to run without failing $this->config->create(); $this->assertTrue(file_exists($this->gen->formatConfigPath() . 'config.php')); } diff --git a/tests/unit/blocks/ControllersTest.php b/tests/unit/blocks/ControllersTest.php index 2ea425d..9b1bdb0 100644 --- a/tests/unit/blocks/ControllersTest.php +++ b/tests/unit/blocks/ControllersTest.php @@ -9,7 +9,9 @@ use rjapi\RJApiGenerator; use rjapi\types\ControllersInterface; use rjapi\types\DirsInterface; +use rjapi\types\RamlInterface; use rjapitest\unit\TestCase; +use Symfony\Component\Yaml\Yaml; class ControllersTest extends TestCase { @@ -25,41 +27,8 @@ public function setUp() $gen->modulesDir = DirsInterface::MODULES_DIR; $gen->controllersDir = DirsInterface::CONTROLLERS_DIR; $gen->httpDir = DirsInterface::HTTP_DIR; - $gen->types = [ - 'SID' => [ - 'type' => 'string', - 'required' => true, - 'maxLength' => 128, - ], - 'ArticleAttributes' => [ - 'description' => 'Article attributes description', - 'type' => 'object', - 'properties' => [ - 'title' => [ - 'required' => true, - 'type' => 'string', - 'minLength' => 16, - 'maxLength' => 256, - 'facets' => [ - 'index' => [ - 'idx_title' => 'index' - ] - ] - ] - ] - ], - 'Article' => [ - 'type' => 'object', - 'properties' => [ - 'type' => 'Type', - 'id' => 'SID', - 'attributes' => 'ArticleAttributes', - 'relationships' => [ - 'type' => 'TagRelationships[] | TopicRelationships', - ] - ] - ] - ]; + $ramlData = Yaml::parse(file_get_contents(__DIR__ . '/../../functional/raml/articles.raml')); + $gen->types = $ramlData[RamlInterface::RAML_KEY_TYPES]; $this->controller = new Controllers($gen); } diff --git a/tests/unit/blocks/EntitiesTest.php b/tests/unit/blocks/EntitiesTest.php index 35035e7..18badae 100644 --- a/tests/unit/blocks/EntitiesTest.php +++ b/tests/unit/blocks/EntitiesTest.php @@ -8,8 +8,10 @@ use rjapi\blocks\Middleware; use rjapi\RJApiGenerator; use rjapi\types\DirsInterface; +use rjapi\types\RamlInterface; use rjapitest\unit\TestCase; use rjapi\blocks\Entities; +use Symfony\Component\Yaml\Yaml; /** * Class EntitiesTest diff --git a/tests/unit/helpers/JwtTest.php b/tests/unit/helpers/JwtTest.php index af8b867..98bcba1 100644 --- a/tests/unit/helpers/JwtTest.php +++ b/tests/unit/helpers/JwtTest.php @@ -7,7 +7,6 @@ use rjapi\helpers\Jwt; use rjapitest\unit\TestCase; - class JwtTest extends TestCase { public function setUp()