Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade PHPUnit #66

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: php
php:
- 7.0
- 7.2
- 7.3

install:
- composer self-update
- composer install --no-interaction --dev
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"homepage": "https://nohponex.gr"
}],
"require": {
"php": ">=7",
"php": "^7.2 | ^8.0.0",
"phramework/phramework": "1.*",
"ext-json": "*",
"phramework/util": "^0.0.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "*",
"phpunit/phpunit": "5.*",
"squizlabs/php_codesniffer": "^3.5.3",
"phpunit/phpunit": "^8.4.3",
"apigen/apigen": "^4.1",
"satooshi/php-coveralls": "^2.0.0",
"codacy/coverage": "^1.0"
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-html" target="build/coverage" />
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
Expand Down
61 changes: 0 additions & 61 deletions tests/src/ControllerTest.php

This file was deleted.

31 changes: 12 additions & 19 deletions tests/src/Controllers/DELETETest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
namespace Phramework\JSONAPI\Controller;

use \Phramework\Phramework;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass \Phramework\JSONAPI\Controller\DELETE
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
* @author Xenofon Spafaridis <nohponex@gmail.com>
*/
class DELETETest extends \PHPUnit_Framework_TestCase
class DELETETest extends TestCase
{
/**
* @var Phramework
Expand All @@ -36,14 +37,6 @@ class DELETETest extends \PHPUnit_Framework_TestCase
*/
protected $parameters;

/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
}

protected function prepare()
{
$_SERVER['REQUEST_URI'] = '/article/1';
Expand All @@ -70,7 +63,7 @@ function (
/**
* @covers ::handleDELETE
*/
public function testDELETESuccess()
public function testDELETESuccess(): void
{
$this->prepare();

Expand All @@ -80,15 +73,15 @@ public function testDELETESuccess()
$params = $this->parameters;
return;

$this->assertInternalType('object', $params);
$this->assertIsObject($params);

$this->assertObjectHasAttribute('links', $params);
$this->assertObjectHasAttribute('data', $params);

$this->assertInternalType('object', $params->data);
$this->assertIsObject($params->data);
$this->assertObjectHasAttribute('id', $params->data);

$this->assertInternalType('string', $params->data->id);
$this->assertIsString($params->data->id);

$id = $params->data->id;

Expand All @@ -97,7 +90,7 @@ public function testDELETESuccess()

$article = \Phramework\JSONAPI\APP\Models\Article::getById($id);

$this->assertInternalType('object', $article);
$this->assertIsObject($article);

$this->assertObjectHasAttribute('attributes', $article);
$this->assertObjectHasAttribute('relationships', $article);
Expand All @@ -107,7 +100,7 @@ public function testDELETESuccess()
$this->assertObjectHasAttribute('creator', $relationships);
$this->assertObjectHasAttribute('tag', $relationships);

$this->assertInternalType('object', $relationships->creator->data);
$this->assertIsObject($relationships->creator->data);
$this->assertInternalType('array', $relationships->tag->data);

$this->assertEquals('1', $relationships->creator->data->id);
Expand All @@ -120,7 +113,7 @@ public function testDELETESuccess()
* Cause a not found exception, at to TYPE_TO_ONE relationship
* @covers \Phramework\JSONAPI\Controller\DELETE::handleDELETE
*/
public function testDELETEFailureToOne()
public function testDELETEFailureToOne(): void
{
$this->prepare();

Expand All @@ -132,7 +125,7 @@ public function testDELETEFailureToOne()
//Access parameters written by invoked phramework's viewer
$params = $this->parameters;

$this->assertInternalType('object', $params);
$this->assertIsObject($params);
$this->assertObjectHasAttribute('errors', $params);

$this->assertSame(
Expand All @@ -146,7 +139,7 @@ public function testDELETEFailureToOne()
* Cause a not found exception, at to TYPE_TO_MANY relationship
* @covers \Phramework\JSONAPI\Controller\DELETE::handleDELETE
*/
public function testDELETEFailureToMany()
public function testDELETEFailureToMany(): void
{
return;
$this->prepare();
Expand All @@ -159,7 +152,7 @@ public function testDELETEFailureToMany()
//Access parameters written by invoked phramework's viewer
$params = $this->parameters;

$this->assertInternalType('object', $params);
$this->assertIsObject($params);
$this->assertObjectHasAttribute('errors', $params);

$this->assertSame(
Expand Down
31 changes: 12 additions & 19 deletions tests/src/Controllers/GETByIdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
namespace Phramework\JSONAPI\Controller;

use \Phramework\Phramework;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass \Phramework\JSONAPI\Controller\GETById
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
* @author Xenofon Spafaridis <nohponex@gmail.com>
*/
class GETByIdTest extends \PHPUnit_Framework_TestCase
class GETByIdTest extends TestCase
{
/**
* @var Phramework
Expand All @@ -36,15 +37,7 @@ class GETByIdTest extends \PHPUnit_Framework_TestCase
*/
protected $parameters;

/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
}

protected function prepare()
protected function prepare(): void
{
$_SERVER['REQUEST_URI'] = 'article/1';
$_SERVER['REQUEST_METHOD'] = Phramework::METHOD_GET;
Expand All @@ -71,7 +64,7 @@ function (
/**
* @covers ::handleGETById
*/
public function testGETByIdSuccess()
public function testGETByIdSuccess(): void
{
$this->prepare();

Expand All @@ -81,12 +74,12 @@ public function testGETByIdSuccess()
$params = $this->parameters;


$this->assertInternalType('object', $params);
$this->assertIsObject($params);

$this->assertObjectHasAttribute('links', $params);
$this->assertObjectHasAttribute('data', $params);

$this->assertInternalType('object', $params->data);
$this->assertIsObject($params->data);
$this->assertObjectHasAttribute('id', $params->data);

return;
Expand All @@ -100,7 +93,7 @@ public function testGETByIdSuccess()

$article = \Phramework\JSONAPI\APP\Models\Article::getById($id);

$this->assertInternalType('object', $article);
$this->assertIsObject($article);

$this->assertObjectHasAttribute('attributes', $article);
$this->assertObjectHasAttribute('relationships', $article);
Expand All @@ -110,7 +103,7 @@ public function testGETByIdSuccess()
$this->assertObjectHasAttribute('creator', $relationships);
$this->assertObjectHasAttribute('tag', $relationships);

$this->assertInternalType('object', $relationships->creator->data);
$this->assertIsObject($relationships->creator->data);
$this->assertInternalType('array', $relationships->tag->data);

$this->assertEquals('1', $relationships->creator->data->id);
Expand All @@ -122,7 +115,7 @@ public function testGETByIdSuccess()
/**
* @covers \Phramework\JSONAPI\Controller\DELETE::handleDELETE
*/
public function testDELETEFailureNotFound()
public function testDELETEFailureNotFound(): void
{
$this->prepare();

Expand All @@ -134,7 +127,7 @@ public function testDELETEFailureNotFound()
//Access parameters returned by invoked phramework's viewer
$params = $this->parameters;

$this->assertInternalType('object', $params);
$this->assertIsObject($params);
$this->assertObjectHasAttribute('errors', $params);

$this->assertSame(
Expand All @@ -147,7 +140,7 @@ public function testDELETEFailureNotFound()
/**
* @covers \Phramework\JSONAPI\Controller\DELETE::handleDELETE
*/
public function testHandleFailure()
public function testHandleFailure(): void
{
$this->prepare();

Expand All @@ -158,7 +151,7 @@ public function testHandleFailure()
//Access parameters returned by invoked phramework's viewer
$params = $this->parameters;

$this->assertInternalType('object', $params);
$this->assertIsObject($params);
$this->assertObjectHasAttribute('errors', $params);

$this->assertSame(
Expand Down
21 changes: 3 additions & 18 deletions tests/src/Controllers/GETTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@

use Phramework\JSONAPI\APP\Bootstrap;
use \Phramework\Phramework;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass \Phramework\JSONAPI\Controller\GET
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
* @author Xenofon Spafaridis <nohponex@gmail.com>
*/
class GETTest extends \PHPUnit_Framework_TestCase
class GETTest extends TestCase
{
/**
* @var Phramework
Expand All @@ -36,15 +37,6 @@ class GETTest extends \PHPUnit_Framework_TestCase
*/
protected $parameters;

/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
* @todo update base
*/
protected function setUp()
{
}

protected function prepare()
{
$_SERVER['REQUEST_URI'] = '/article/';
Expand All @@ -69,18 +61,11 @@ function (
);
}

/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}

/**
* @covers Phramework\JSONAPI\Controller\GET::handleGET
*/
public function testHandleGet()
public function testHandleGet(): void
{
$this->prepare();

Expand Down
Loading