Skip to content

Commit 32ef974

Browse files
committed
tests: refactor & fix test cases to work with phpunit 11
1 parent 5040a6f commit 32ef974

File tree

11 files changed

+109
-87
lines changed

11 files changed

+109
-87
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
2+
/.phpunit.cache
23
/vendor
34
composer.lock

phpunit.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4+
backupGlobals="false"
5+
cacheDirectory=".phpunit.cache"
6+
backupStaticProperties="false"
47
bootstrap="./vendor/autoload.php"
58
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
1111
>

tests/DataTypes/BTCTest.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,35 @@
55

66
class BTCTest extends TestCase
77
{
8+
/**
9+
* @var \SimpleSoftwareIO\QrCode\DataTypes\BTC
10+
*/
11+
protected $btc;
12+
813
public function setUp(): void
914
{
1015
$this->btc = new BTC();
1116
}
1217

13-
public function test_it_generates_a_valid_btc_qrcode_with_an_address_and_amount()
18+
public function test_it_generates_a_valid_btc_qrcode_with_an_address_and_amount(): void
1419
{
1520
$this->btc->create(['btcaddress', 0.0034]);
1621

1722
$properFormat = 'bitcoin:btcaddress?amount=0.0034';
1823

19-
$this->assertEquals($properFormat, strval($this->btc));
24+
$this->assertEquals($properFormat, \strval($this->btc));
2025
}
2126

22-
public function test_it_generates_a_valid_btc_qrcode_with_an_address_amount_and_label()
27+
public function test_it_generates_a_valid_btc_qrcode_with_an_address_amount_and_label(): void
2328
{
2429
$this->btc->create(['btcaddress', 0.0034, ['label' => 'label']]);
2530

2631
$properFormat = 'bitcoin:btcaddress?amount=0.0034&label=label';
2732

28-
$this->assertEquals($properFormat, strval($this->btc));
33+
$this->assertEquals($properFormat, \strval($this->btc));
2934
}
3035

31-
public function test_it_generates_a_valid_btc_qrcode_with_an_address_amount_label_message_and_return_address()
36+
public function test_it_generates_a_valid_btc_qrcode_with_an_address_amount_label_message_and_return_address(): void
3237
{
3338
$this->btc->create([
3439
'btcaddress',
@@ -40,8 +45,8 @@ public function test_it_generates_a_valid_btc_qrcode_with_an_address_amount_labe
4045
],
4146
]);
4247

43-
$properFormat = 'bitcoin:btcaddress?amount=0.0034&label=label&message=message&r='.urlencode('https://www.returnaddress.com');
48+
$properFormat = 'bitcoin:btcaddress?amount=0.0034&label=label&message=message&r=' . \urlencode('https://www.returnaddress.com');
4449

45-
$this->assertEquals($properFormat, strval($this->btc));
50+
$this->assertEquals($properFormat, \strval($this->btc));
4651
}
4752
}

tests/DataTypes/EmailTest.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,55 @@
55

66
class EmailTest extends TestCase
77
{
8+
/**
9+
* @var \SimpleSoftwareIO\QrCode\DataTypes\Email
10+
*/
11+
protected $email;
12+
813
public function setUp(): void
914
{
1015
$this->email = new Email();
1116
}
1217

13-
public function test_it_generates_the_proper_format_when_only_an_email_address_is_supplied()
18+
public function test_it_generates_the_proper_format_when_only_an_email_address_is_supplied(): void
1419
{
1520
$this->email->create(['[email protected]']);
1621

1722
$properFormat = 'mailto:[email protected]';
1823

19-
$this->assertEquals($properFormat, strval($this->email));
24+
$this->assertEquals($properFormat, \strval($this->email));
2025
}
2126

22-
public function test_it_generates_the_proper_format_when_an_email_subject_and_body_are_supplied()
27+
public function test_it_generates_the_proper_format_when_an_email_subject_and_body_are_supplied(): void
2328
{
2429
$this->email->create(['[email protected]', 'foo', 'bar']);
2530

2631
$properFormat = 'mailto:[email protected]?subject=foo&body=bar';
2732

28-
$this->assertEquals($properFormat, strval($this->email));
33+
$this->assertEquals($properFormat, \strval($this->email));
2934
}
3035

31-
public function test_it_generates_the_proper_format_when_an_email_and_subject_are_supplied()
36+
public function test_it_generates_the_proper_format_when_an_email_and_subject_are_supplied(): void
3237
{
3338
$this->email->create(['[email protected]', 'foo']);
3439

3540
$properFormat = 'mailto:[email protected]?subject=foo';
3641

37-
$this->assertEquals($properFormat, strval($this->email));
42+
$this->assertEquals($properFormat, \strval($this->email));
3843
}
3944

40-
public function test_it_generates_the_proper_format_when_only_a_subject_is_provided()
45+
public function test_it_generates_the_proper_format_when_only_a_subject_is_provided(): void
4146
{
4247
$this->email->create([null, 'foo']);
4348

4449
$properFormat = 'mailto:?subject=foo';
4550

46-
$this->assertEquals($properFormat, strval($this->email));
51+
$this->assertEquals($properFormat, \strval($this->email));
4752
}
4853

49-
public function test_it_throws_an_exception_when_an_invalid_email_is_given()
54+
public function test_it_throws_an_exception_when_an_invalid_email_is_given(): void
5055
{
51-
$this->expectException(InvalidArgumentException::class);
56+
$this->expectException(\InvalidArgumentException::class);
5257

5358
$this->email->create(['foo']);
5459
}

tests/DataTypes/GeoTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
class GeoTest extends TestCase
77
{
8-
public function test_it_generates_the_proper_format_for_a_geo_coordinate()
8+
public function test_it_generates_the_proper_format_for_a_geo_coordinate(): void
99
{
1010
$geo = new Geo();
1111
$geo->create([10.254, -30.254]);
1212

1313
$properFormat = 'geo:10.254,-30.254';
1414

15-
$this->assertEquals($properFormat, strval($geo));
15+
$this->assertEquals($properFormat, \strval($geo));
1616
}
1717
}

tests/DataTypes/PhoneNumberTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
class PhoneNumberTest extends TestCase
77
{
8-
public function test_it_generates_the_proper_format_for_calling_a_phone_number()
8+
public function test_it_generates_the_proper_format_for_calling_a_phone_number(): void
99
{
1010
$phoneNumber = new PhoneNumber();
1111
$phoneNumber->create(['555-555-5555']);
1212

1313
$properFormat = 'tel:555-555-5555';
1414

15-
$this->assertEquals($properFormat, strval($phoneNumber));
15+
$this->assertEquals($properFormat, \strval($phoneNumber));
1616
}
1717
}

tests/DataTypes/SMSTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,40 @@
55

66
class SMSTest extends TestCase
77
{
8+
/**
9+
* @var \SimpleSoftwareIO\QrCode\DataTypes\SMS
10+
*/
11+
protected $sms;
12+
813
public function setUp(): void
914
{
1015
$this->sms = new SMS();
1116
}
1217

13-
public function test_it_generates_a_proper_format_with_a_phone_number()
18+
public function test_it_generates_a_proper_format_with_a_phone_number(): void
1419
{
1520
$this->sms->create(['555-555-5555']);
1621

1722
$properFormat = 'sms:555-555-5555';
1823

19-
$this->assertEquals($properFormat, strval($this->sms));
24+
$this->assertEquals($properFormat, \strval($this->sms));
2025
}
2126

22-
public function test_it_generate_a_proper_format_with_a_message()
27+
public function test_it_generate_a_proper_format_with_a_message(): void
2328
{
2429
$this->sms->create([null, 'foo']);
2530

2631
$properFormat = 'sms:&body=foo';
2732

28-
$this->assertEquals($properFormat, strval($this->sms));
33+
$this->assertEquals($properFormat, \strval($this->sms));
2934
}
3035

31-
public function test_it_generates_a_proper_format_with_a_phone_number_and_message()
36+
public function test_it_generates_a_proper_format_with_a_phone_number_and_message(): void
3237
{
3338
$this->sms->create(['555-555-5555', 'foo']);
3439

3540
$properFormat = 'sms:555-555-5555&body=foo';
3641

37-
$this->assertEquals($properFormat, strval($this->sms));
42+
$this->assertEquals($properFormat, \strval($this->sms));
3843
}
3944
}

tests/DataTypes/WiFiTest.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55

66
class WiFiTest extends TestCase
77
{
8+
/**
9+
* @var \SimpleSoftwareIO\QrCode\DataTypes\WiFi
10+
*/
11+
protected $wifi;
12+
813
public function setUp(): void
914
{
1015
$this->wifi = new Wifi();
1116
}
1217

13-
public function test_it_generates_a_proper_format_with_just_the_ssid()
18+
public function test_it_generates_a_proper_format_with_just_the_ssid(): void
1419
{
1520
$this->wifi->create([
1621
0 => [
@@ -20,10 +25,10 @@ public function test_it_generates_a_proper_format_with_just_the_ssid()
2025

2126
$properFormat = 'WIFI:S:foo;';
2227

23-
$this->assertEquals($properFormat, strval($this->wifi));
28+
$this->assertEquals($properFormat, \strval($this->wifi));
2429
}
2530

26-
public function test_it_generates_a_proper_format_for_a_ssid_that_is_hidden()
31+
public function test_it_generates_a_proper_format_for_a_ssid_that_is_hidden(): void
2732
{
2833
$this->wifi->create([
2934
0 => [
@@ -34,10 +39,10 @@ public function test_it_generates_a_proper_format_for_a_ssid_that_is_hidden()
3439

3540
$properFormat = 'WIFI:S:foo;H:true;';
3641

37-
$this->assertEquals($properFormat, strval($this->wifi));
42+
$this->assertEquals($properFormat, \strval($this->wifi));
3843
}
3944

40-
public function test_it_generates_a_proper_format_for_a_ssid_encryption_and_password()
45+
public function test_it_generates_a_proper_format_for_a_ssid_encryption_and_password(): void
4146
{
4247
$this->wifi->create([
4348
0 => [
@@ -49,10 +54,10 @@ public function test_it_generates_a_proper_format_for_a_ssid_encryption_and_pass
4954

5055
$properFormat = 'WIFI:T:WPA;S:foo;P:bar;';
5156

52-
$this->assertEquals($properFormat, strval($this->wifi));
57+
$this->assertEquals($properFormat, \strval($this->wifi));
5358
}
5459

55-
public function test_it_generates_a_proper_format_for_a_ssid_encryption_password_and_is_hidden()
60+
public function test_it_generates_a_proper_format_for_a_ssid_encryption_password_and_is_hidden(): void
5661
{
5762
$this->wifi->create([
5863
0 => [
@@ -65,6 +70,6 @@ public function test_it_generates_a_proper_format_for_a_ssid_encryption_password
6570

6671
$properFormat = 'WIFI:T:WPA;S:foo;P:bar;H:true;';
6772

68-
$this->assertEquals($properFormat, strval($this->wifi));
73+
$this->assertEquals($properFormat, \strval($this->wifi));
6974
}
7075
}

0 commit comments

Comments
 (0)