-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#111. Add more coverage on Routes/BaseFormRequest
- Loading branch information
1 parent
adaeceb
commit 8454281
Showing
3 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace rjapitest\unit\blocks; | ||
|
||
use rjapi\blocks\ContentManager; | ||
use rjapi\blocks\Routes; | ||
use rjapi\blocks\RoutesTrait; | ||
use rjapi\RJApiGenerator; | ||
use rjapi\types\DirsInterface; | ||
use rjapi\types\RamlInterface; | ||
use rjapitest\unit\TestCase; | ||
use Symfony\Component\Yaml\Yaml; | ||
|
||
/** | ||
* Class ConfigTest | ||
* @package rjapitest\unit\blocks | ||
* @property Routes router | ||
*/ | ||
class RouterTest extends TestCase | ||
{ | ||
/** @var RJApiGenerator $gen */ | ||
private $gen; | ||
private $router; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$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 = 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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace rjapitest\unit\extensions; | ||
|
||
|
||
use Illuminate\Support\Facades\Request; | ||
use PHPUnit\Framework\Constraint\IsType; | ||
use rjapi\extension\BaseFormRequest; | ||
use rjapi\extension\CustomSql; | ||
use rjapitest\unit\TestCase; | ||
|
||
/** | ||
* Class CustomSqlTest | ||
* @package rjapitest\unit\extensions | ||
* | ||
* @property BaseFormRequest baseFormRequest | ||
*/ | ||
class BaseFormRequestTest extends TestCase | ||
{ | ||
private $baseFormRequest; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->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()); | ||
} | ||
} |