Skip to content

Commit a5e3cef

Browse files
authored
test: test enhancements (#120)
- Upgrade the PHPUnit version. - Use the class-based PHPUnit namespace for the latest PHPUnit version. - Add the `phpunit.xml.dist` in `test` folder.
1 parent cd727b9 commit a5e3cef

File tree

6 files changed

+27
-8
lines changed

6 files changed

+27
-8
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"ext-mbstring": "*"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^5.7",
25+
"phpunit/phpunit": "^5.7 || ^6.5",
2626
"sebastian/version": "^1.0.6",
2727
"squizlabs/php_codesniffer": "~2.0",
2828
"friendsofphp/php-cs-fixer": "^2.16"

test/phpunit.xml.dist

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit colors="true" bootstrap="../vendor/autoload.php">
3+
<testsuites>
4+
<testsuite name="All">
5+
<directory>.</directory>
6+
</testsuite>
7+
</testsuites>
8+
<filter>
9+
<whitelist processUncoveredFilesFromWhitelist="true">
10+
<directory suffix=".php">../lib</directory>
11+
</whitelist>
12+
</filter>
13+
</phpunit>

test/unit/ClientTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
namespace SendGrid\Test;
44

5+
use PHPUnit\Framework\TestCase;
56
use SendGrid\Client;
67
use SendGrid\Exception\InvalidRequest;
78

8-
class ClientTest extends \PHPUnit_Framework_TestCase
9+
class ClientTest extends TestCase
910
{
1011
/** @var MockClient */
1112
private $client;

test/unit/FilesExistTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace SendGrid\Test;
44

5-
class FilesExistTest extends \PHPUnit_Framework_TestCase
5+
use PHPUnit\Framework\TestCase;
6+
7+
class FilesExistTest extends TestCase
68
{
79
public function testFileArePresentInRepo()
810
{

test/unit/LicenceYearTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace SendGrid\Test;
44

5-
class LicenceYearTest extends \PHPUnit_Framework_TestCase
5+
use PHPUnit\Framework\TestCase;
6+
7+
class LicenceYearTest extends TestCase
68
{
79
public function testConstructor()
810
{

test/unit/ResponseTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
namespace SendGrid\Test;
44

55
use SendGrid\Response;
6+
use PHPUnit\Framework\TestCase;
67

7-
class ResponseTest extends \PHPUnit_Framework_TestCase
8+
class ResponseTest extends TestCase
89
{
910
public function testConstructor()
1011
{
1112
$response = new Response();
12-
13+
1314
$this->assertAttributeEquals(200, 'statusCode', $response);
1415
$this->assertAttributeEquals('', 'body', $response);
1516
$this->assertAttributeEquals([], 'headers', $response);
@@ -41,11 +42,11 @@ public function testHeaders()
4142

4243
$this->assertEquals(['Content-Type: text/html'], $response->headers());
4344
}
44-
45+
4546
public function testAssociativeHeaders()
4647
{
4748
$response = new Response(null, null, ['Content-Type: text/html', 'HTTP/1.1 200 OK']);
48-
49+
4950
$this->assertEquals(['Content-Type' => 'text/html', 'Status' => 'HTTP/1.1 200 OK'], $response->headers(true));
5051
}
5152
}

0 commit comments

Comments
 (0)