Skip to content

Commit bc51aa2

Browse files
authored
Merge pull request #21 from chrisryan/master
Add Support for PHP 8.
2 parents 52a4212 + 3593cbb commit bc51aa2

File tree

5 files changed

+36
-37
lines changed

5 files changed

+36
-37
lines changed

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-18.04
1212
strategy:
1313
matrix:
14-
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4']
14+
php-versions: ['7.3', '7.4', '8.0', '8.1']
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v2

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
},
1414
"license": "MIT",
1515
"require": {
16-
"php": "^7.0",
17-
"traderinteractive/exceptions": "^1.0"
16+
"php": "^7.3 || ^8.0",
17+
"traderinteractive/exceptions": "^2.0"
1818
},
1919
"require-dev": {
2020
"ext-SimpleXML": "*",
2121
"ext-dom": "*",
2222
"ext-json": "*",
2323
"ext-libxml": "*",
24-
"phpunit/phpunit": "^6.0",
24+
"phpunit/phpunit": "^9.0",
2525
"squizlabs/php_codesniffer": "^3.2"
2626
},
2727
"suggest": {

tests/Filter/EmailTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ public function filter()
2222

2323
/**
2424
* @test
25-
* @expectedException \TraderInteractive\Exceptions\FilterException
26-
* @expectedExceptionMessage Value '111222333444' is not a string
2725
* @covers ::filter
2826
*/
2927
public function filterNotString()
3028
{
29+
$this->expectException(\TraderInteractive\Exceptions\FilterException::class);
30+
$this->expectExceptionMessage("Value '111222333444' is not a string");
3131
Email::filter(111222333444);
3232
}
3333

3434
/**
3535
* @test
36-
* @expectedException \TraderInteractive\Exceptions\FilterException
37-
* @expectedExceptionMessage Value '@email.com' is not a valid email
3836
* @covers ::filter
3937
*/
4038
public function filterNotValid()
4139
{
40+
$this->expectException(\TraderInteractive\Exceptions\FilterException::class);
41+
$this->expectExceptionMessage("Value '@email.com' is not a valid email");
4242
Email::filter('@email.com');
4343
}
4444
}

tests/Filter/StringsTest.php

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public function filterNullPass()
5757

5858
/**
5959
* @test
60-
* @expectedException \TraderInteractive\Exceptions\FilterException
61-
* @expectedExceptionMessage Value failed filtering, $allowNull is set to false
6260
* @covers ::filter
6361
*/
6462
public function filterNullFail()
6563
{
64+
$this->expectException(\TraderInteractive\Exceptions\FilterException::class);
65+
$this->expectExceptionMessage('Value failed filtering, $allowNull is set to false');
6666
Strings::filter(null);
6767
}
6868

@@ -77,11 +77,11 @@ public function filterMinLengthPass()
7777

7878
/**
7979
* @test
80-
* @expectedException \TraderInteractive\Exceptions\FilterException
8180
* @covers ::filter
8281
*/
8382
public function filterMinLengthFail()
8483
{
84+
$this->expectException(\TraderInteractive\Exceptions\FilterException::class);
8585
Strings::filter('');
8686
}
8787

@@ -96,56 +96,56 @@ public function filterMaxLengthPass()
9696

9797
/**
9898
* @test
99-
* @expectedException \TraderInteractive\Exceptions\FilterException
100-
* @expectedExceptionMessage Value 'a' with length '1' is less than '0' or greater than '0'
10199
* @covers ::filter
102100
*/
103101
public function filterMaxLengthFail()
104102
{
103+
$this->expectException(\TraderInteractive\Exceptions\FilterException::class);
104+
$this->expectExceptionMessage("Value 'a' with length '1' is less than '0' or greater than '0'");
105105
Strings::filter('a', false, 0, 0);
106106
}
107107

108108
/**
109109
* @test
110-
* @expectedException InvalidArgumentException
111-
* @expectedExceptionMessage $minLength was not a positive integer value
112110
* @covers ::filter
113111
*/
114112
public function filterMinLengthNotInteger()
115113
{
114+
$this->expectException(InvalidArgumentException::class);
115+
$this->expectExceptionMessage('$minLength was not a positive integer value');
116116
Strings::filter('a', false, -1);
117117
}
118118

119119
/**
120120
* @test
121-
* @expectedException InvalidArgumentException
122-
* @expectedExceptionMessage $maxLength was not a positive integer value
123121
* @covers ::filter
124122
*/
125123
public function filterMaxLengthNotInteger()
126124
{
125+
$this->expectException(InvalidArgumentException::class);
126+
$this->expectExceptionMessage('$maxLength was not a positive integer value');
127127
Strings::filter('a', false, 1, -1);
128128
}
129129

130130
/**
131131
* @test
132-
* @expectedException InvalidArgumentException
133-
* @expectedExceptionMessage $minLength was not a positive integer value
134132
* @covers ::filter
135133
*/
136134
public function filterMinLengthNegative()
137135
{
136+
$this->expectException(InvalidArgumentException::class);
137+
$this->expectExceptionMessage('$minLength was not a positive integer value');
138138
Strings::filter('a', false, -1);
139139
}
140140

141141
/**
142142
* @test
143-
* @expectedException InvalidArgumentException
144-
* @expectedExceptionMessage $maxLength was not a positive integer value
145143
* @covers ::filter
146144
*/
147145
public function filterMaxLengthNegative()
148146
{
147+
$this->expectException(InvalidArgumentException::class);
148+
$this->expectExceptionMessage('$maxLength was not a positive integer value');
149149
Strings::filter('a', false, 1, -1);
150150
}
151151

@@ -184,12 +184,11 @@ public function __toString()
184184
/**
185185
* @test
186186
* @covers ::filter
187-
*
188-
* @expectedException \TraderInteractive\Exceptions\FilterException
189-
* @expectedExceptionMessage Value 'class@anonymous
190187
*/
191188
public function filterWithObjectNoToStringMethod()
192189
{
190+
$this->expectException(\TraderInteractive\Exceptions\FilterException::class);
191+
$this->expectExceptionMessage("Value 'class@anonymous");
193192
$testObject = new class() {
194193
private $data;
195194

@@ -215,11 +214,11 @@ public function translateValue()
215214
/**
216215
* @test
217216
* @covers ::translate
218-
* @expectedException \TraderInteractive\Exceptions\FilterException
219-
* @expectedExceptionMessage The value 'baz' was not found in the translation map array.
220217
*/
221218
public function translateValueNotFoundInMap()
222219
{
220+
$this->expectException(\TraderInteractive\Exceptions\FilterException::class);
221+
$this->expectExceptionMessage("The value 'baz' was not found in the translation map array.");
223222
$map = ['foo' => '100', 'bar' => '200'];
224223
Strings::translate('baz', $map);
225224
}
@@ -248,25 +247,25 @@ public function explodeCustomDelimiter()
248247

249248
/**
250249
* @test
251-
* @expectedException \TraderInteractive\Exceptions\FilterException
252-
* @expectedExceptionMessage Value '1234' is not a string
253250
* @covers ::explode
254251
*/
255252
public function explodeNonString()
256253
{
254+
$this->expectException(\TraderInteractive\Exceptions\FilterException::class);
255+
$this->expectExceptionMessage("Value '1234' is not a string");
257256
Strings::explode(1234, '');
258257
}
259258

260259
/**
261260
* Verifies explode filter with an empty delimiter.
262261
*
263262
* @test
264-
* @expectedException \InvalidArgumentException
265-
* @expectedExceptionMessage Delimiter '''' is not a non-empty string
266263
* @covers ::explode
267264
*/
268265
public function explodeEmptyDelimiter()
269266
{
267+
$this->expectException(\InvalidArgumentException::class);
268+
$this->expectExceptionMessage("Delimiter '''' is not a non-empty string");
270269
Strings::explode('test', '');
271270
}
272271

@@ -348,12 +347,12 @@ public function concat()
348347
*
349348
* @test
350349
* @covers ::concat
351-
* @expectedException \TraderInteractive\Exceptions\FilterException
352350
*
353351
* @return void
354352
*/
355353
public function concatValueNotFilterable()
356354
{
355+
$this->expectException(\TraderInteractive\Exceptions\FilterException::class);
357356
Strings::concat(new \StdClass(), 'prefix', 'suffix');
358357
}
359358

tests/Filter/UrlTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ public function filter()
2222

2323
/**
2424
* @test
25-
* @expectedException \TraderInteractive\Exceptions\FilterException
26-
* @expectedExceptionMessage Value '1' is not a string
2725
* @covers ::filter
2826
*/
2927
public function filterNonString()
3028
{
29+
$this->expectException(\TraderInteractive\Exceptions\FilterException::class);
30+
$this->expectExceptionMessage("Value '1' is not a string");
3131
Url::filter(1);
3232
}
3333

3434
/**
3535
* @test
36-
* @expectedException \TraderInteractive\Exceptions\FilterException
37-
* @expectedExceptionMessage Value 'www.example.com' is not a valid url
3836
* @covers ::filter
3937
*/
4038
public function filterNotValid()
4139
{
40+
$this->expectException(\TraderInteractive\Exceptions\FilterException::class);
41+
$this->expectExceptionMessage("Value 'www.example.com' is not a valid url");
4242
Url::filter('www.example.com');
4343
}
4444

@@ -53,12 +53,12 @@ public function filterNullPass()
5353

5454
/**
5555
* @test
56-
* @expectedException \TraderInteractive\Exceptions\FilterException
57-
* @expectedExceptionMessage Value failed filtering, $allowNull is set to false
5856
* @covers ::filter
5957
*/
6058
public function filterNullFail()
6159
{
60+
$this->expectException(\TraderInteractive\Exceptions\FilterException::class);
61+
$this->expectExceptionMessage('Value failed filtering, $allowNull is set to false');
6262
Url::filter(null);
6363
}
6464
}

0 commit comments

Comments
 (0)