Skip to content

Commit

Permalink
Code coverage, updates
Browse files Browse the repository at this point in the history
  • Loading branch information
oligus committed Nov 22, 2017
1 parent be2b346 commit d8f81af
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 39 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
composer.phar
/vendor/
/.idea/

# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
/demo/client/node_modules
/tests/coverage/*
coverage.xml
20 changes: 10 additions & 10 deletions tests/e2e/GenresTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getDataSet()
public function testResourceNotFoundException()
{
Configure::getInstance()->setConfig('strict', true);
$_SERVER = ['REQUEST_URI' => '/notfound'];
$_SERVER['REQUEST_URI'] = '/notfound';

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
$jad = new Jad($mapper);
Expand All @@ -61,7 +61,7 @@ public function testResourceNotFoundException()

public function testFetchCollection()
{
$_SERVER = ['REQUEST_URI' => '/genres'];
$_SERVER['REQUEST_URI'] = '/genres';

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
$jad = new Jad($mapper);
Expand All @@ -74,7 +74,7 @@ public function testFetchCollection()

public function testLimit()
{
$_SERVER = ['REQUEST_URI' => '/genres'];
$_SERVER['REQUEST_URI'] = '/genres';

$_GET = ['page' => ['offset' => 0, 'limit' => 5]];

Expand All @@ -88,7 +88,7 @@ public function testLimit()

public function testOffset()
{
$_SERVER = ['REQUEST_URI' => '/genres'];
$_SERVER['REQUEST_URI'] = '/genres';
$_GET = ['page' => ['page' => 10, 'size' => 5]];

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
Expand All @@ -102,7 +102,7 @@ public function testOffset()

public function testSortAsc()
{
$_SERVER = ['REQUEST_URI' => '/genres'];
$_SERVER['REQUEST_URI'] = '/genres';
$_GET = ['page' => ['number' => 0, 'size' => 10], 'sort' => 'name',];

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
Expand All @@ -116,7 +116,7 @@ public function testSortAsc()

public function testSortDesc()
{
$_SERVER = ['REQUEST_URI' => '/genres'];
$_SERVER['REQUEST_URI'] = '/genres';
$_GET = ['page' => ['number' => 0, 'size' => 10], 'sort' => '-name',];

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
Expand All @@ -132,7 +132,7 @@ public function testCreate()
{
Configure::getInstance()->setConfig('testMode', true);

$_SERVER = ['REQUEST_URI' => '/genres'];
$_SERVER['REQUEST_URI'] = '/genres';
$_SERVER['REQUEST_METHOD'] = 'POST';

$input = new \stdClass();
Expand All @@ -155,7 +155,7 @@ public function testUpdate()
{
Configure::getInstance()->setConfig('testMode', true);

$_SERVER = ['REQUEST_URI' => '/genres/26'];
$_SERVER['REQUEST_URI'] = '/genres/26';
$_SERVER['REQUEST_METHOD'] = 'PATCH';

$input = new \stdClass();
Expand All @@ -177,7 +177,7 @@ public function testUpdate()

public function testDelete()
{
$_SERVER = ['REQUEST_URI' => '/genres/26'];
$_SERVER['REQUEST_URI'] = '/genres/26';
$_SERVER['REQUEST_METHOD'] = 'DELETE';

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
Expand All @@ -191,7 +191,7 @@ public function testDelete()
*/
public function testDeleteVerify()
{
$_SERVER = ['REQUEST_URI' => '/genres/26'];
$_SERVER['REQUEST_URI'] = '/genres/26';
$_SERVER['REQUEST_METHOD'] = 'GET';

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
Expand Down
8 changes: 3 additions & 5 deletions tests/e2e/PaginationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
use Jad\Database\Manager;
use Jad\Map\AnnotationsMapper;
use Jad\Jad;
use Jad\Configure;

use PHPUnit\DbUnit\TestCaseTrait;
use PHPUnit\DbUnit\DataSet\CsvDataSet;

Expand Down Expand Up @@ -46,7 +44,7 @@ public function getDataSet()

public function testSize()
{
$_SERVER = ['REQUEST_URI' => '/genres'];
$_SERVER['REQUEST_URI'] = '/genres';
$_GET = ['page' => ['page' => 1, 'size' => 5]];

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
Expand All @@ -60,7 +58,7 @@ public function testSize()

public function testNumber()
{
$_SERVER = ['REQUEST_URI' => '/genres'];
$_SERVER['REQUEST_URI'] = '/genres';
$_GET = ['page' => ['number' => 2, 'size' => 5]];

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
Expand All @@ -73,7 +71,7 @@ public function testNumber()

public function testLast()
{
$_SERVER = ['REQUEST_URI' => '/genres'];
$_SERVER['REQUEST_URI'] = '/genres';
$_GET = ['page' => ['number' => 9, 'size' => 3]];

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
Expand Down
18 changes: 9 additions & 9 deletions tests/e2e/PlaylistTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getDataSet()

public function testFetchCollection()
{
$_SERVER = ['REQUEST_URI' => '/playlists'];
$_SERVER['REQUEST_URI'] = '/playlists';

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
$jad = new Jad($mapper);
Expand All @@ -58,7 +58,7 @@ public function testFetchCollection()

public function testFetchCollectionFields()
{
$_SERVER = ['REQUEST_URI' => '/tracks'];
$_SERVER['REQUEST_URI'] = '/tracks';
$_GET = ['page' => ['offset' => 0, 'limit' => 5], 'fields' => [ 'tracks' => 'name']];

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
Expand All @@ -71,7 +71,7 @@ public function testFetchCollectionFields()

public function testGetTracks()
{
$_SERVER = ['REQUEST_URI' => '/tracks/15'];
$_SERVER['REQUEST_URI'] = '/tracks/15';

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
$jad = new Jad($mapper);
Expand All @@ -83,7 +83,7 @@ public function testGetTracks()

public function testGetRelationshipFull()
{
$_SERVER = ['REQUEST_URI' => '/tracks/15/playlists'];
$_SERVER['REQUEST_URI'] = '/tracks/15/playlists';

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
$jad = new Jad($mapper);
Expand All @@ -95,7 +95,7 @@ public function testGetRelationshipFull()

public function testGetRelationshipList()
{
$_SERVER = ['REQUEST_URI' => '/tracks/15/relationships/playlists'];
$_SERVER['REQUEST_URI'] = '/tracks/15/relationships/playlists';

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
$jad = new Jad($mapper);
Expand All @@ -108,7 +108,7 @@ public function testGetRelationshipList()
public function testCreateRelationship()
{
Configure::getInstance()->setConfig('testMode', true);
$_SERVER = ['REQUEST_URI' => '/playlists'];
$_SERVER['REQUEST_URI'] = '/playlists';
$_SERVER['REQUEST_METHOD'] = 'POST';

$input = new \stdClass();
Expand Down Expand Up @@ -140,7 +140,7 @@ public function testCreateRelationship()
*/
public function testCreateRelationshipVerify()
{
$_SERVER = ['REQUEST_URI' => '/playlists/4/relationships/tracks'];
$_SERVER['REQUEST_URI'] = '/playlists/4/relationships/tracks';
$_SERVER['REQUEST_METHOD'] = 'GET';

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
Expand All @@ -157,7 +157,7 @@ public function testCreateRelationshipVerify()
public function testUpdateAddRelationship()
{
Configure::getInstance()->setConfig('testMode', true);
$_SERVER = ['REQUEST_URI' => '/playlists/4'];
$_SERVER['REQUEST_URI'] = '/playlists/4';
$_SERVER['REQUEST_METHOD'] = 'PATCH';

$input = new \stdClass();
Expand All @@ -184,7 +184,7 @@ public function testUpdateAddRelationship()
*/
public function testUpdateAddRelationshipVerify()
{
$_SERVER = ['REQUEST_URI' => '/playlists/4/relationships/tracks'];
$_SERVER['REQUEST_URI'] = '/playlists/4/relationships/tracks';
$_SERVER['REQUEST_METHOD'] = 'GET';

$mapper = new AnnotationsMapper(Manager::getInstance()->getEm());
Expand Down
20 changes: 9 additions & 11 deletions tests/src/Request/JsonApiRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ public function testParameters()
]
];

$_SERVER = [
'REQUEST_URI' => '/api/jad/articles'
];
$_SERVER['REQUEST_URI'] = '/api/jad/articles';

$request = new JsonApiRequest();

Expand All @@ -28,12 +26,12 @@ public function testParameters()

public function testGetItems()
{
$_SERVER = ['REQUEST_URI' => '/api/jad/posts/2/moo'];
$_SERVER['REQUEST_URI'] = '/api/jad/posts/2/moo';
$request = new JsonApiRequest();
$request->setPathPrefix('api/jad');
$this->assertEquals($request->getItems(), ['posts', '2', 'moo']);

$_SERVER = ['REQUEST_URI' => '/api/v1/accounts/1'];
$_SERVER['REQUEST_URI'] = '/api/v1/accounts/1';
$request = new JsonApiRequest();
$request->setPathPrefix('/api/v1/jad');
$this->assertEquals($request->getItems(), ['api', 'v1', 'accounts', '1']);
Expand All @@ -48,31 +46,31 @@ public function testGetType()
// /articles/1/relationships/authors => same as above
// /articles/1/relationships/comments => get comments relationships

$_SERVER = ['REQUEST_URI' => '/api/jad/articles'];
$_SERVER['REQUEST_URI'] = '/api/jad/articles';
$request = new JsonApiRequest();
$request->setPathPrefix('api/jad');

$this->assertEquals($request->getResourceType(), 'articles');
$this->assertEquals($request->getId(), null);
$this->assertEquals($request->getRelationship(), null);

$_SERVER = ['REQUEST_URI' => '/api/jad/articles/1'];
$_SERVER['REQUEST_URI'] = '/api/jad/articles/1';
$request = new JsonApiRequest();
$request->setPathPrefix('api/jad');

$this->assertEquals($request->getResourceType(), 'articles');
$this->assertEquals($request->getId(), 1);
$this->assertEquals($request->getRelationship(), null);

$_SERVER = ['REQUEST_URI' => '/api/jad/articles/1/author'];
$_SERVER['REQUEST_URI'] = '/api/jad/articles/1/author';
$request = new JsonApiRequest();
$request->setPathPrefix('api/jad');

$this->assertEquals($request->getResourceType(), 'articles');
$this->assertEquals($request->getId(), 1);
$this->assertEquals($request->getRelationship(), ['view' => 'full', 'type' => 'author']);

$_SERVER = ['REQUEST_URI' => '/api/jad/articles/1/relationships/authors'];
$_SERVER['REQUEST_URI'] = '/api/jad/articles/1/relationships/authors';
$request = new JsonApiRequest();
$request->setPathPrefix('api/jad');

Expand All @@ -87,7 +85,7 @@ public function testGetType()
*/
public function testGetTypeException()
{
$_SERVER = ['REQUEST_URI' => '/api/jad/articles/1/relationships'];
$_SERVER['REQUEST_URI'] = '/api/jad/articles/1/relationships';
$request = new JsonApiRequest();
$request->setPathPrefix('api/jad');

Expand All @@ -98,7 +96,7 @@ public function testGetTypeException()

public function testIsCollection()
{
$_SERVER = ['REQUEST_URI' => '/api/jad/articles/1'];
$_SERVER['REQUEST_URI'] = '/api/jad/articles/1';
$request = new JsonApiRequest();
$request->setPathPrefix('api/jad');

Expand Down

0 comments on commit d8f81af

Please sign in to comment.