Skip to content

Commit

Permalink
#121. Change badges to api-generator + codecov + fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkushman committed Dec 2, 2018
1 parent de23d57 commit c556727
Show file tree
Hide file tree
Showing 7 changed files with 1,204 additions and 844 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PHP-code generator (based on OAS) for Laravel framework, with complete support o

[![Build Status](https://scrutinizer-ci.com/g/RJAPI/api-generator/badges/build.png?b=master)](https://scrutinizer-ci.com/g/RJAPI/api-generator/build-status/master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/RJAPI/api-generator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/RJAPI/api-generator/?branch=master)
[![Code Intelligence Status](https://scrutinizer-ci.com/g/RJAPI/api-generator/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)
[![codecov](https://codecov.io/gh/RJAPI/api-generator/branch/master/graph/badge.svg)](https://codecov.io/gh/RJAPI/api-generator)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

Expand Down
2,013 changes: 1,186 additions & 827 deletions clover.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/_data/ArticleFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class ArticleFixture
public static function createAndGet() : Article
{
$article = new Article();
$article->id = '124ea1e595ed11225727e7730d653669';
$article->id = uniqid();
$article->title = 'Foo bar Foo bar Foo bar Foo bar';
$article->description = 'The quick brovn fox jumped ower the lazy dogg';
$article->url = 'http://example.com/articles_feed_123';
$article->url = 'http://example.com/articles_feed' . uniqid();
$article->topic_id = 1;
$article->rate = 5.0;
$article->status = 'draft';
Expand Down
14 changes: 7 additions & 7 deletions tests/functional/RJApiGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class RJApiGeneratorTest extends \Codeception\Test\Unit
{
const MODULES_DIR = './Modules/';
public const MODULES_DIR = './Modules/';

/**
* @var \FunctionalTester
Expand Down Expand Up @@ -70,7 +70,7 @@ public function testControllers()
public function testMiddleware()
{
// base model
$formIn = new \Modules\V1\Http\Middleware\ArticleMiddleware();
$formIn = new \Modules\V2\Http\Requests\ArticleFormRequest();
$this->assertInstanceOf(FormRequest::class, $formIn);
$this->assertNotEmpty($formIn->rules());
$this->assertArraySubset([
Expand All @@ -91,7 +91,7 @@ public function testMiddleware()
], $formIn->relations());

// related
$formIn = new \Modules\V1\Http\Middleware\TagMiddleware();
$formIn = new \Modules\V2\Http\Requests\TagFormRequest();
$this->assertInstanceOf(FormRequest::class, $formIn);
$this->assertNotEmpty($formIn->rules());
$this->assertArraySubset([
Expand All @@ -102,7 +102,7 @@ public function testMiddleware()
"article",
], $formIn->relations());

$formIn = new \Modules\V1\Http\Middleware\TopicMiddleware();
$formIn = new \Modules\V2\Http\Requests\TopicFormRequest();
$this->assertInstanceOf(FormRequest::class, $formIn);
$this->assertNotEmpty($formIn->rules());
$this->assertArraySubset([
Expand All @@ -119,20 +119,20 @@ public function testMiddleware()
*/
public function testEntities()
{
$article = new \Modules\V1\Entities\Article();
$article = new \Modules\V2\Entities\Article();
$this->assertObjectHasAttribute('primaryKey', $article);
$this->assertObjectHasAttribute('table', $article);
$this->assertObjectHasAttribute('timestamps', $article);
$this->assertTrue(method_exists($article, 'tag'), 'Class Article doesn`t have method tag');
$this->assertTrue(method_exists($article, 'topic'), 'Class Article doesn`t have method topic');

$tag = new \Modules\V1\Entities\Tag();
$tag = new \Modules\V2\Entities\Tag();
$this->assertObjectHasAttribute('primaryKey', $tag);
$this->assertObjectHasAttribute('table', $tag);
$this->assertObjectHasAttribute('timestamps', $tag);
$this->assertTrue(method_exists($tag, 'article'), 'Class Tag doesn`t have method article');

$topic = new \Modules\V1\Entities\Topic();
$topic = new \Modules\V2\Entities\Topic();
$this->assertObjectHasAttribute('primaryKey', $topic);
$this->assertObjectHasAttribute('table', $topic);
$this->assertObjectHasAttribute('timestamps', $topic);
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/blocks/EntitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace rjapitest\unit\blocks;

use Modules\V2\Entities\Article;
use Modules\V2\Http\Middleware\ArticleTestMiddleware;
use Modules\V2\Http\Requests\ArticleFormRequest;
use rjapi\blocks\FormRequestModel;
use rjapi\blocks\FormRequest;
use rjapi\ApiGenerator;
Expand Down Expand Up @@ -61,9 +61,9 @@ public function setUp()
public function it_creates_middleware_and_entity()
{
// create Middleware for further entities to run
$this->middleware->createEntity(self::DIR_OUTPUT, 'Middleware');
require_once __DIR__ . '/../../_output/ArticleMiddleware.php';
$articleMiddleware = new \Modules\V2\Http\Middleware\ArticleMiddleware();
$this->middleware->createEntity(self::DIR_OUTPUT, 'FormRequest');
require_once __DIR__ . '/../../_output/ArticleFormRequest.php';
$articleMiddleware = new \Modules\V2\Http\Requests\ArticleFormRequest();
$this->assertNull($articleMiddleware->id);
$this->assertNull($articleMiddleware->title);
$this->assertTrue($articleMiddleware->authorize());
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/helpers/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use League\Fractal\Resource\Collection;
use League\Fractal\Resource\Item;
use Modules\V2\Entities\Article;
use Modules\V2\Http\Middleware\ArticleMiddleware;
use Modules\V2\Http\Requests\ArticleFormRequest;
use PHPUnit\Framework\Constraint\IsType;
use PHPUnit_Framework_MockObject_MockObject;
use rjapi\extension\BaseFormRequest;
Expand All @@ -31,7 +31,7 @@ public function setUp()
{
parent::setUp();
$this->baseModel = new Article();
$this->baseFormRequest = new ArticleMiddleware();
$this->baseFormRequest = new ArticleFormRequest();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/transformers/DefaultTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use League\Fractal\Resource\Item;
use League\Fractal\TransformerAbstract;
use Modules\V2\Entities\Article;
use Modules\V2\Http\Middleware\ArticleMiddleware;
use Modules\V2\Http\Requests\ArticleFormRequest;
use PHPUnit\Framework\Constraint\IsType;
use rjapi\extension\BaseModel;
use rjapi\transformers\DefaultTransformer;
Expand All @@ -25,7 +25,7 @@ class DefaultTransformerTest extends TestCase
public function setUp()
{
parent::setUp();
$middleware = new ArticleMiddleware();
$middleware = new ArticleFormRequest();
$this->transformer = new DefaultTransformer($middleware);
}

Expand Down

0 comments on commit c556727

Please sign in to comment.