Skip to content

Commit

Permalink
#111. Add coverage on Jwt/Config/Controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkushman committed May 31, 2018
1 parent 9d44d6f commit c6d37fd
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 194 deletions.
300 changes: 150 additions & 150 deletions clover.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/blocks/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private function generateConfig()
}

/**
* @throws \rjapi\exception\DirectoryException
* @throws \rjapi\exceptions\DirectoryException
*/
public function createDirs()
{
Expand Down Expand Up @@ -241,7 +241,7 @@ private function setIncludedTypes(array $data)
}

/**
* @throws \rjapi\exception\DirectoryException
* @throws \rjapi\exceptions\DirectoryException
*/
private function setGenHistory()
{
Expand Down
1 change: 1 addition & 0 deletions src/types/ConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
24 changes: 19 additions & 5 deletions tests/unit/blocks/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

/**
Expand All @@ -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'));
}
Expand Down
39 changes: 4 additions & 35 deletions tests/unit/blocks/ControllersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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);
}

Expand Down
2 changes: 2 additions & 0 deletions tests/unit/blocks/EntitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/unit/helpers/JwtTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use rjapi\helpers\Jwt;
use rjapitest\unit\TestCase;


class JwtTest extends TestCase
{
public function setUp()
Expand Down

0 comments on commit c6d37fd

Please sign in to comment.