Skip to content

Commit ff048ee

Browse files
authored
Merge pull request #454 from ukfast/rbibby-patch-1
Update tests to run on PHP 8.1, 8.0 and 7.0
2 parents 09e3126 + 75afbcb commit ff048ee

10 files changed

+40
-72
lines changed

.github/workflows/run-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
php: [7.4, 7.3, 7.2, 7.1, 5.6]
17+
php: [8.1, 8.0, 7.4, 7.3, 7.2, 7.1, 7.0, 5.6]
1818

1919
name: PHP${{ matrix.php }} - ubuntu-latest
2020

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
}
2424
},
2525
"require-dev": {
26-
"phpunit/phpunit": "^5.7",
26+
"phpunit/phpunit": ">=5.7",
2727
"squizlabs/php_codesniffer": "3.*",
2828
"fzaninotto/faker": "^1.4"
2929
}

tests/Account/CreditTest.php

+3-18
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Tests\Account;
44

5-
use Faker\Factory as Faker;
65
use GuzzleHttp\Client;
76
use GuzzleHttp\Handler\MockHandler;
87
use GuzzleHttp\HandlerStack;
@@ -12,20 +11,6 @@
1211

1312
class CreditTest extends TestCase
1413
{
15-
/**
16-
* Faker data provider
17-
*
18-
* @var \Faker\Generator
19-
*/
20-
protected $faker;
21-
22-
protected function setUp()
23-
{
24-
parent::setUp();
25-
26-
$this->faker = Faker::create();
27-
}
28-
2914
/**
3015
* @test
3116
*/
@@ -34,9 +19,9 @@ public function getPage()
3419
$apiResponse = [
3520
'data' => [
3621
[
37-
'type' => $this->faker->word,
38-
'total' => $this->faker->numberBetween(10),
39-
'remaining' => $this->faker->randomDigitNotNull,
22+
'type' => 'Credit',
23+
'total' => 9,
24+
'remaining' => 5,
4025
]
4126
],
4227
'meta' => [

tests/Billing/PaymentCardClientTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public function get_payment_cards_by_id()
5656
$this->assertEquals(12, $paymentCard->issueNumber);
5757
$this->assertTrue(true, $paymentCard->primaryCard);
5858

59-
$this->assertInternalType('int', $paymentCard->id);
60-
$this->assertInternalType('int', $paymentCard->issueNumber);
59+
$this->assertTrue(is_int($paymentCard->id));
60+
$this->assertTrue(is_int($paymentCard->issueNumber));
6161
}
6262

6363
/**

tests/DDoSX/DomainVerificationTest.php

+7-18
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,18 @@
66
use GuzzleHttp\Handler\MockHandler;
77
use GuzzleHttp\HandlerStack;
88
use GuzzleHttp\Psr7\Response;
9-
use Faker\Factory as Faker;
109
use PHPUnit\Framework\TestCase;
1110
use UKFast\SDK\DDoSX\DomainVerificationClient;
1211
use UKFast\SDK\Exception\ValidationException;
1312

1413
class DomainVerificationTest extends TestCase
1514
{
16-
protected $faker;
17-
18-
protected function setUp()
19-
{
20-
parent::setUp();
21-
22-
$this->faker = Faker::create();
23-
}
24-
25-
2615
/**
2716
* @test
2817
*/
2918
public function verify_domain_via_dns()
3019
{
31-
$domainName = $this->faker->domainName;
20+
$domainName = 'example.com';
3221
$mock = new MockHandler([
3322
new Response(200),
3423
new Response(422, [], json_encode([
@@ -47,15 +36,15 @@ public function verify_domain_via_dns()
4736
$this->assertTrue($client->verifyByDns($domainName));
4837

4938
$this->expectException(ValidationException::class);
50-
$client->verifyByDns($this->faker->domainName);
39+
$client->verifyByDns('example.com');
5140
}
5241

5342
/**
5443
* @test
5544
*/
5645
public function verify_domain_via_file_upload()
5746
{
58-
$domainName = $this->faker->domainName;
47+
$domainName = 'example.com';
5948
$mock = new MockHandler([
6049
new Response(200),
6150
new Response(422, [], json_encode([
@@ -74,16 +63,16 @@ public function verify_domain_via_file_upload()
7463
$this->assertTrue($client->verifyByDns($domainName));
7564

7665
$this->expectException(ValidationException::class);
77-
$client->verifyByDns($this->faker->domainName);
66+
$client->verifyByDns('example.com');
7867
}
7968

8069
/**
8170
* @test
8271
*/
8372
public function download_verification_file()
8473
{
85-
$filename = $this->faker->word . '.txt';
86-
$verificationString = $this->faker->word . PHP_EOL . $this->faker->word;
74+
$filename = 'test.txt';
75+
$verificationString = 'test1' . PHP_EOL . 'test2';
8776
$contentType = 'text/plain; charset=UTF-8';
8877

8978
$mock = new MockHandler([
@@ -96,7 +85,7 @@ public function download_verification_file()
9685
$guzzle = new Client(['handler' => HandlerStack::create($mock)]);
9786
$client = new DomainVerificationClient($guzzle);
9887

99-
$verificationFile = $client->getVerificationFile($this->faker->domainName);
88+
$verificationFile = $client->getVerificationFile('example.com');
10089

10190
$this->assertEquals($filename, $verificationFile->getName());
10291
$this->assertEquals($verificationString, $verificationFile->getStream()->getContents());

tests/DDoSX/SslClientTest.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ class SslClientTest extends TestCase
2121
*/
2222
protected $faker;
2323

24-
protected function setUp()
24+
protected function setFaker()
2525
{
26-
parent::setUp();
27-
2826
$this->faker = Faker::create();
2927
}
3028

@@ -42,6 +40,8 @@ public function can_get_from_ddosx_client()
4240
*/
4341
public function constructs_from_response()
4442
{
43+
$this->setFaker();
44+
4545
$response = [
4646
'id' => $this->faker->uuid,
4747
'ukfast_ssl_id' => $this->faker->randomDigit,
@@ -72,6 +72,8 @@ public function constructs_from_response()
7272
*/
7373
public function gets_ssl_page()
7474
{
75+
$this->setFaker();
76+
7577
$mockHandler = new MockHandler([
7678
new Response(200, [], json_encode([
7779
'data' => [
@@ -129,6 +131,8 @@ public function gets_ssl_page()
129131
*/
130132
public function gets_ssl_by_id()
131133
{
134+
$this->setFaker();
135+
132136
$uuid = $this->faker->uuid;
133137
$mockHandler = new MockHandler([
134138
new Response(200, [], json_encode([
@@ -157,6 +161,8 @@ public function gets_ssl_by_id()
157161
*/
158162
public function creates_and_gets_ssl_correctly()
159163
{
164+
$this->setFaker();
165+
160166
$apiData = [
161167
'id' => $this->faker->uuid,
162168
'ukfast_ssl_id' => $this->faker->randomDigit,

tests/EntityTest.php

+5-18
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,11 @@
22

33
namespace Tests;
44

5-
use Faker\Factory as Faker;
65
use PHPUnit\Framework\TestCase;
76
use UKFast\SDK\Entity;
87

98
class EntityTest extends TestCase
109
{
11-
/**
12-
* @var \Faker\Generator
13-
*/
14-
protected $faker;
15-
16-
protected function setUp()
17-
{
18-
$this->faker = Faker::create();
19-
20-
parent::setUp();
21-
}
22-
2310
/**
2411
* @test
2512
*/
@@ -104,10 +91,10 @@ public function to_array_still_returns_properties_that_arent_present_in_map()
10491
public function can_find_if_array_access_property_exists()
10592
{
10693
$contact = new Contact([
107-
'id' => $this->faker->randomDigitNotNull,
94+
'id' => 123,
10895
]);
10996

110-
$this->assertFalse($contact->offsetExists($this->faker->randomDigitNotNull));
97+
$this->assertFalse($contact->offsetExists(123));
11198
$this->assertTrue($contact->offsetExists('id'));
11299
}
113100

@@ -116,7 +103,7 @@ public function can_find_if_array_access_property_exists()
116103
*/
117104
public function can_get_array_access_property()
118105
{
119-
$id = $this->faker->randomDigitNotNull;
106+
$id = 321;
120107

121108
$contact = new Contact([
122109
'id' => $id,
@@ -130,7 +117,7 @@ public function can_get_array_access_property()
130117
*/
131118
public function can_set_array_access_property()
132119
{
133-
$id = $this->faker->randomDigitNotNull;
120+
$id = 123;
134121

135122
$contact = new Contact();
136123
$contact['id'] = $id;
@@ -144,7 +131,7 @@ public function can_set_array_access_property()
144131
public function can_unset_array_access_property()
145132
{
146133
$contact = new Contact([
147-
'id' => $this->faker->randomDigitNotNull,
134+
'id' => 123,
148135
]);
149136

150137
unset($contact['id']);

tests/SafeDns/RecordClientTest.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ class RecordClientTest extends TestCase
2121
*/
2222
protected $faker;
2323

24-
protected function setUp()
24+
protected function setFaker()
2525
{
26-
parent::setUp();
27-
2826
$this->faker = Faker::create();
2927
}
3028

@@ -42,6 +40,8 @@ public function can_get_from_safedns_client()
4240
*/
4341
public function constructs_from_response()
4442
{
43+
$this->setFaker();
44+
4545
$response = [
4646
'id' => $this->faker->uuid,
4747
'name' => $this->faker->domainName,
@@ -74,6 +74,8 @@ public function constructs_from_response()
7474
*/
7575
public function creates_and_gets_ssl_correctly()
7676
{
77+
$this->setFaker();
78+
7779
$domainName = $this->faker->domainName;
7880
$apiData = [
7981
'id' => $this->faker->uuid,

tests/Ssl/SslCertificateTest.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ class SslCertificateTest extends TestCase
1919
*/
2020
protected $faker;
2121

22-
protected function setUp()
22+
protected function setFaker()
2323
{
24-
parent::setUp();
25-
2624
$this->faker = Faker::create();
2725
}
2826

@@ -32,6 +30,8 @@ protected function setUp()
3230
*/
3331
public function constructs_from_response()
3432
{
33+
$this->setFaker();
34+
3535
$validDays = $this->faker->numberBetween(1, 825);
3636

3737
$response = [
@@ -72,6 +72,8 @@ public function constructs_from_response()
7272
*/
7373
public function gets_certificates_page()
7474
{
75+
$this->setFaker();
76+
7577
$validDaysOne = $this->faker->numberBetween(1, 825);
7678
$validDaysTwo = $this->faker->numberBetween(1, 825);
7779

@@ -140,6 +142,8 @@ public function gets_certificates_page()
140142
*/
141143
public function gets_certificate_by_id()
142144
{
145+
$this->setFaker();
146+
143147
$validDays = $this->faker->numberBetween(1, 825);
144148

145149
$mockHandler = new MockHandler([

tests/Ssl/SslValidationTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ class SslValidationTest extends TestCase
6666
-----END RSA PRIVATE KEY-----
6767
SSLKEY;
6868

69-
protected function setUp()
70-
{
71-
parent::setUp();
72-
}
73-
7469
/**
7570
* Tests ValidationResult entity class from valid response
7671
*/

0 commit comments

Comments
 (0)