Skip to content

Commit de0f74e

Browse files
carusogabrielthilanga
authored andcommitted
Improving tests (dingo#1495)
* Update to Mockery 1 * Support PHPUnit 6 * Use ::class pseudo-constants
1 parent 4675eaa commit de0f74e

26 files changed

+72
-72
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
"illuminate/log": "^5.1",
3131
"illuminate/pagination": "^5.1",
3232
"laravel/lumen-framework": "^5.1",
33-
"mockery/mockery": "~0.9",
34-
"phpunit/phpunit": "^4.8 || ^5.0",
33+
"mockery/mockery": "~1.0",
34+
"phpunit/phpunit": "^4.8.35 || ^5.4.3 || ^6.5",
3535
"squizlabs/php_codesniffer": "~2.0",
3636
"tymon/jwt-auth": "1.0.*"
3737
},
@@ -69,4 +69,4 @@
6969
},
7070
"minimum-stability": "dev",
7171
"prefer-stable": true
72-
}
72+
}

tests/Auth/AuthTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
use Dingo\Api\Http\Request;
88
use Dingo\Api\Routing\Route;
99
use Dingo\Api\Routing\Router;
10-
use PHPUnit_Framework_TestCase;
10+
use PHPUnit\Framework\TestCase;
1111
use Illuminate\Container\Container;
1212
use Dingo\Api\Contract\Auth\Provider;
1313
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
1414
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
1515

16-
class AuthTest extends PHPUnit_Framework_TestCase
16+
class AuthTest extends TestCase
1717
{
1818
public function setUp()
1919
{

tests/Auth/Provider/AuthorizationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
use Mockery as m;
66
use Dingo\Api\Routing\Route;
77
use Illuminate\Http\Request;
8-
use PHPUnit_Framework_TestCase;
8+
use PHPUnit\Framework\TestCase;
99
use Dingo\Api\Tests\Stubs\AuthorizationProviderStub;
1010

11-
class AuthorizationTest extends PHPUnit_Framework_TestCase
11+
class AuthorizationTest extends TestCase
1212
{
1313
public function tearDown()
1414
{

tests/Auth/Provider/BasicTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
use Mockery as m;
66
use Illuminate\Http\Request;
77
use Illuminate\Http\Response;
8-
use PHPUnit_Framework_TestCase;
8+
use PHPUnit\Framework\TestCase;
99
use Dingo\Api\Auth\Provider\Basic;
1010

11-
class BasicTest extends PHPUnit_Framework_TestCase
11+
class BasicTest extends TestCase
1212
{
1313
protected $auth;
1414
protected $provider;

tests/Auth/Provider/JWTTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
use Mockery as m;
66
use Illuminate\Http\Request;
7-
use PHPUnit_Framework_TestCase;
7+
use PHPUnit\Framework\TestCase;
88
use Dingo\Api\Auth\Provider\JWT;
99
use Tymon\JWTAuth\Exceptions\JWTException;
1010

11-
class JWTTest extends PHPUnit_Framework_TestCase
11+
class JWTTest extends TestCase
1212
{
1313
protected $auth;
1414
protected $provider;

tests/DispatcherTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Dingo\Api\Dispatcher;
99
use Illuminate\Http\Request;
1010
use Dingo\Api\Routing\Router;
11-
use PHPUnit_Framework_TestCase;
11+
use PHPUnit\Framework\TestCase;
1212
use Dingo\Api\Tests\Stubs\UserStub;
1313
use Illuminate\Container\Container;
1414
use Illuminate\Filesystem\Filesystem;
@@ -21,7 +21,7 @@
2121
use Dingo\Api\Transformer\Factory as TransformerFactory;
2222
use Illuminate\Support\Facades\Request as RequestFacade;
2323

24-
class DispatcherTest extends PHPUnit_Framework_TestCase
24+
class DispatcherTest extends TestCase
2525
{
2626
protected $container;
2727

@@ -154,7 +154,7 @@ public function testInternalExceptionContainsResponseObject()
154154
try {
155155
$this->dispatcher->get('test');
156156
} catch (InternalHttpException $exception) {
157-
$this->assertInstanceOf('Illuminate\Http\Response', $exception->getResponse());
157+
$this->assertInstanceOf(\Illuminate\Http\Response::class, $exception->getResponse());
158158
$this->assertSame('test', $exception->getResponse()->getContent());
159159
}
160160
}
@@ -381,7 +381,7 @@ public function testRedirectResponseThrowsException()
381381
});
382382

383383
$response = $this->dispatcher->get('redirect');
384-
$this->assertInstanceOf('Illuminate\Http\RedirectResponse', $response);
384+
$this->assertInstanceOf(\Illuminate\Http\RedirectResponse::class, $response);
385385
$this->assertSame('redirect-test', $response->getTargetUrl());
386386
}
387387

tests/Exception/HandlerTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
use Mockery as m;
66
use RuntimeException;
77
use Illuminate\Http\Response;
8-
use PHPUnit_Framework_TestCase;
8+
use PHPUnit\Framework\TestCase;
99
use Dingo\Api\Exception\Handler;
1010
use Illuminate\Http\JsonResponse;
1111
use Illuminate\Http\RedirectResponse;
1212
use Dingo\Api\Http\Request as ApiRequest;
1313
use Dingo\Api\Exception\ResourceException;
1414
use Symfony\Component\HttpKernel\Exception\HttpException;
1515

16-
class HandlerTest extends PHPUnit_Framework_TestCase
16+
class HandlerTest extends TestCase
1717
{
1818
protected $parentHandler;
1919
protected $exceptionHandler;
@@ -67,7 +67,7 @@ public function testExceptionHandlerHandlesExceptionAndCreatesNewResponse()
6767

6868
$response = $this->exceptionHandler->handle($exception);
6969

70-
$this->assertInstanceOf('Illuminate\Http\Response', $response);
70+
$this->assertInstanceOf(Response::class, $response);
7171
$this->assertSame('foo', $response->getContent());
7272
$this->assertSame(404, $response->getStatusCode());
7373
}
@@ -82,7 +82,7 @@ public function testExceptionHandlerHandlesExceptionWithRedirectResponse()
8282

8383
$response = $this->exceptionHandler->handle($exception);
8484

85-
$this->assertInstanceOf('Illuminate\Http\RedirectResponse', $response);
85+
$this->assertInstanceOf(RedirectResponse::class, $response);
8686
$this->assertSame('foo', $response->getTargetUrl());
8787
$this->assertSame(302, $response->getStatusCode());
8888
}
@@ -97,7 +97,7 @@ public function testExceptionHandlerHandlesExceptionWithJsonResponse()
9797

9898
$response = $this->exceptionHandler->handle($exception);
9999

100-
$this->assertInstanceOf('Illuminate\Http\JsonResponse', $response);
100+
$this->assertInstanceOf(JsonResponse::class, $response);
101101
$this->assertSame('{"foo":"bar"}', $response->getContent());
102102
$this->assertSame(404, $response->getStatusCode());
103103
}
@@ -108,7 +108,7 @@ public function testExceptionHandlerReturnsGenericWhenNoMatchingHandler()
108108

109109
$response = $this->exceptionHandler->handle($exception);
110110

111-
$this->assertInstanceOf('Illuminate\Http\Response', $response);
111+
$this->assertInstanceOf(Response::class, $response);
112112
$this->assertSame('{"message":"bar","status_code":404}', $response->getContent());
113113
$this->assertSame(404, $response->getStatusCode());
114114
}
@@ -129,7 +129,7 @@ public function testUsingMultidimensionalArrayForGenericResponse()
129129

130130
$response = $this->exceptionHandler->handle($exception);
131131

132-
$this->assertInstanceOf('Illuminate\Http\Response', $response);
132+
$this->assertInstanceOf(Response::class, $response);
133133
$this->assertSame('{"error":{"message":"bar","status_code":404}}', $response->getContent());
134134
$this->assertSame(404, $response->getStatusCode());
135135
}
@@ -150,7 +150,7 @@ public function testResourceExceptionErrorsAreIncludedInResponse()
150150

151151
$response = $this->exceptionHandler->handle($exception);
152152

153-
$this->assertInstanceOf('Illuminate\Http\Response', $response);
153+
$this->assertInstanceOf(Response::class, $response);
154154
$this->assertSame('{"message":"bar","errors":{"foo":["bar"]},"code":10,"status_code":422}', $response->getContent());
155155
$this->assertSame(422, $response->getStatusCode());
156156
}
@@ -174,7 +174,7 @@ public function testHttpExceptionsWithNoMessageUseStatusCodeMessage()
174174

175175
$response = $this->exceptionHandler->handle($exception);
176176

177-
$this->assertInstanceOf('Illuminate\Http\Response', $response);
177+
$this->assertInstanceOf(Response::class, $response);
178178
$this->assertSame('{"message":"404 Not Found","status_code":404}', $response->getContent());
179179
$this->assertSame(404, $response->getStatusCode());
180180
}

tests/Http/Middleware/AuthTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
use Dingo\Api\Http\Request;
88
use Dingo\Api\Routing\Route;
99
use Dingo\Api\Routing\Router;
10-
use PHPUnit_Framework_TestCase;
10+
use PHPUnit\Framework\TestCase;
1111
use Illuminate\Container\Container;
1212
use Dingo\Api\Tests\Stubs\RoutingAdapterStub;
1313
use Illuminate\Routing\Route as IlluminateRoute;
1414
use Dingo\Api\Http\Middleware\Auth as AuthMiddleware;
1515
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
1616

17-
class AuthTest extends PHPUnit_Framework_TestCase
17+
class AuthTest extends TestCase
1818
{
1919
protected $container;
2020
protected $adapter;

tests/Http/Middleware/RateLimitTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Dingo\Api\Http\Response;
88
use Dingo\Api\Routing\Route;
99
use Dingo\Api\Routing\Router;
10-
use PHPUnit_Framework_TestCase;
10+
use PHPUnit\Framework\TestCase;
1111
use Illuminate\Cache\CacheManager;
1212
use Dingo\Api\Http\InternalRequest;
1313
use Illuminate\Container\Container;
@@ -17,7 +17,7 @@
1717
use Dingo\Api\Exception\RateLimitExceededException;
1818
use Symfony\Component\HttpKernel\Exception\HttpException;
1919

20-
class RateLimitTest extends PHPUnit_Framework_TestCase
20+
class RateLimitTest extends TestCase
2121
{
2222
protected $container;
2323
protected $router;

tests/Http/Middleware/RequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Dingo\Api\Http\Request;
77
use Dingo\Api\Routing\Router;
88
use Dingo\Api\Http\Validation;
9-
use PHPUnit_Framework_TestCase;
9+
use PHPUnit\Framework\TestCase;
1010
use Dingo\Api\Exception\Handler;
1111
use Dingo\Api\Http\RequestValidator;
1212
use Dingo\Api\Http\Validation\Accept;
@@ -19,7 +19,7 @@
1919
use Dingo\Api\Contract\Http\Request as RequestContract;
2020
use Dingo\Api\Http\Middleware\Request as RequestMiddleware;
2121

22-
class RequestTest extends PHPUnit_Framework_TestCase
22+
class RequestTest extends TestCase
2323
{
2424
protected $app;
2525
protected $router;

0 commit comments

Comments
 (0)