Skip to content

Commit e407ef5

Browse files
Merge pull request #141 from hassankhan/ci/add-php-8-1-to-build-matrix
Add PHP 8.1 to build matrix
2 parents 1ad529b + bea67ff commit e407ef5

File tree

15 files changed

+76
-57
lines changed

15 files changed

+76
-57
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
operating-system: [ubuntu-latest]
11-
# TODO Add 8.1 version as well
12-
php-versions: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
11+
php-versions: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
1312
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
1413
steps:
1514
- uses: actions/checkout@v2

tests/AbstractConfigTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function testSetArray()
139139
'host' => 'localhost',
140140
'name' => 'mydatabase'
141141
]);
142-
$this->assertInternalType('array', $this->config->get('database'));
142+
$this->assertIsArray($this->config->get('database'));
143143
$this->assertEquals('localhost', $this->config->get('database.host'));
144144
}
145145

@@ -152,7 +152,7 @@ public function testCacheWithNestedArray()
152152
'host' => 'localhost',
153153
'name' => 'mydatabase'
154154
]);
155-
$this->assertInternalType('array', $this->config->get('database'));
155+
$this->assertIsArray($this->config->get('database'));
156156
$this->config->set('database.host', '127.0.0.1');
157157
$expected = [
158158
'host' => '127.0.0.1',
@@ -218,7 +218,7 @@ public function testSetAndUnsetArray()
218218
'host' => 'localhost',
219219
'name' => 'mydatabase'
220220
]);
221-
$this->assertInternalType('array', $this->config->get('database'));
221+
$this->assertIsArray($this->config->get('database'));
222222
$this->assertEquals('localhost', $this->config->get('database.host'));
223223
$this->config->set('database.host', null);
224224
$this->assertNull($this->config->get('database.host'));

tests/ConfigTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
use Noodlehaus\Parser\Json as JsonParser;
55
use Noodlehaus\Writer\Json as JsonWriter;
66
use PHPUnit\Framework\TestCase;
7+
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
78

89
/**
910
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
1011
*/
1112
class ConfigTest extends TestCase
1213
{
14+
use ExpectException;
1315
/**
1416
* @var Config
1517
*/
@@ -19,11 +21,11 @@ class ConfigTest extends TestCase
1921
* @covers Noodlehaus\Config::load()
2022
* @covers Noodlehaus\Config::loadFromFile()
2123
* @covers Noodlehaus\Config::getParser()
22-
* @expectedException Noodlehaus\Exception\UnsupportedFormatException
23-
* @expectedExceptionMessage Unsupported configuration format
2424
*/
2525
public function testLoadWithUnsupportedFormat()
2626
{
27+
$this->expectException(\Noodlehaus\Exception\UnsupportedFormatException::class);
28+
$this->expectExceptionMessage('Unsupported configuration format');
2729
$config = Config::load(__DIR__ . '/mocks/fail/error.lib');
2830
// $this->markTestIncomplete('Not yet implemented');
2931
}
@@ -32,11 +34,11 @@ public function testLoadWithUnsupportedFormat()
3234
* @covers Noodlehaus\Config::__construct()
3335
* @covers Noodlehaus\Config::loadFromFile()
3436
* @covers Noodlehaus\Config::getParser()
35-
* @expectedException Noodlehaus\Exception\UnsupportedFormatException
36-
* @expectedExceptionMessage Unsupported configuration format
3737
*/
3838
public function testConstructWithUnsupportedFormat()
3939
{
40+
$this->expectException(\Noodlehaus\Exception\UnsupportedFormatException::class);
41+
$this->expectExceptionMessage('Unsupported configuration format');
4042
$config = new Config(__DIR__ . '/mocks/fail/error.lib');
4143
}
4244

@@ -46,11 +48,11 @@ public function testConstructWithUnsupportedFormat()
4648
* @covers Noodlehaus\Config::getParser()
4749
* @covers Noodlehaus\Config::getPathFromArray()
4850
* @covers Noodlehaus\Config::getValidPath()
49-
* @expectedException Noodlehaus\Exception\FileNotFoundException
50-
* @expectedExceptionMessage Configuration file: [ladadeedee] cannot be found
5151
*/
5252
public function testConstructWithInvalidPath()
5353
{
54+
$this->expectException(\Noodlehaus\Exception\FileNotFoundException::class);
55+
$this->expectExceptionMessage('Configuration file: [ladadeedee] cannot be found');
5456
$config = new Config('ladadeedee');
5557
}
5658

@@ -60,10 +62,10 @@ public function testConstructWithInvalidPath()
6062
* @covers Noodlehaus\Config::getParser()
6163
* @covers Noodlehaus\Config::getPathFromArray()
6264
* @covers Noodlehaus\Config::getValidPath()
63-
* @expectedException Noodlehaus\Exception\EmptyDirectoryException
6465
*/
6566
public function testConstructWithEmptyDirectory()
6667
{
68+
$this->expectException(\Noodlehaus\Exception\EmptyDirectoryException::class);
6769
$config = new Config(__DIR__ . '/mocks/empty');
6870
}
6971

@@ -91,10 +93,10 @@ public function testConstructWithArray()
9193
* @covers Noodlehaus\Config::getParser()
9294
* @covers Noodlehaus\Config::getPathFromArray()
9395
* @covers Noodlehaus\Config::getValidPath()
94-
* @expectedException Noodlehaus\Exception\FileNotFoundException
9596
*/
9697
public function testConstructWithArrayWithNonexistentFile()
9798
{
99+
$this->expectException(\Noodlehaus\Exception\FileNotFoundException::class);
98100
$paths = [__DIR__ . '/mocks/pass/config.xml', __DIR__ . '/mocks/pass/config3.json'];
99101
$config = new Config($paths);
100102

tests/Parser/IniTest.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
22
namespace Noodlehaus\Parser\Test;
33

4-
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
54
use Noodlehaus\Parser\Ini;
5+
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
6+
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
67

78
/**
89
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
910
*/
1011
class IniTest extends TestCase
1112
{
13+
use ExpectException;
1214
/**
1315
* @var Ini
1416
*/
@@ -36,13 +38,13 @@ public function testGetSupportedExtensions()
3638
/**
3739
* @covers Noodlehaus\Parser\Ini::parseFile()
3840
* @covers Noodlehaus\Parser\Ini::parse()
39-
* @expectedException Noodlehaus\Exception\ParseException
40-
* @expectedExceptionMessage No parsable content
4141
* Tests the case where an INI string contains no parsable data at all, resulting in parse_ini_string
4242
* returning NULL, but not setting an error retrievable by error_get_last()
4343
*/
4444
public function testLoadInvalidIniGBH()
4545
{
46+
$this->expectException(\Noodlehaus\Exception\ParseException::class);
47+
$this->expectExceptionMessage('No parsable content');
4648
$this->ini->parseFile(__DIR__ . '/../mocks/fail/error2.ini');
4749
}
4850

@@ -58,14 +60,8 @@ public function testLoadInvalidIni()
5860
$exceptionMessage = "syntax error, unexpected end of file, expecting ']' in Unknown on line 1";
5961
}
6062

61-
if (PHP_VERSION_ID < 50600 && PHP_VERSION_ID >= 50500) {
62-
$this->setExpectedException(
63-
'\Noodlehaus\Exception\ParseException', $exceptionMessage
64-
);
65-
} else {
66-
$this->expectException(\Noodlehaus\Exception\ParseException::class);
67-
$this->expectExceptionMessage($exceptionMessage);
68-
}
63+
$this->expectException(\Noodlehaus\Exception\ParseException::class);
64+
$this->expectExceptionMessage($exceptionMessage);
6965

7066
$this->ini->parseString(file_get_contents(__DIR__ . '/../mocks/fail/error.ini'));
7167
}

tests/Parser/JsonTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
22
namespace Noodlehaus\Parser\Test;
33

4-
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
54
use Noodlehaus\Parser\Json;
5+
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
6+
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
67

78
/**
89
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
910
*/
1011
class JsonTest extends TestCase
1112
{
13+
use ExpectException;
1214
/**
1315
* @var Json
1416
*/
@@ -36,11 +38,11 @@ public function testGetSupportedExtensions()
3638
/**
3739
* @covers Noodlehaus\Parser\Json::parseFile()
3840
* @covers Noodlehaus\Parser\Json::parse()
39-
* @expectedException Noodlehaus\Exception\ParseException
40-
* @expectedExceptionMessage Syntax error
4141
*/
4242
public function testLoadInvalidJson()
4343
{
44+
$this->expectException(\Noodlehaus\Exception\ParseException::class);
45+
$this->expectExceptionMessage('Syntax error');
4446
$this->json->parseFile(__DIR__ . '/../mocks/fail/error.json');
4547
}
4648

tests/Parser/PhpTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
22
namespace Noodlehaus\Parser\Test;
33

4-
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
54
use Noodlehaus\Parser\Php;
5+
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
6+
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
67

78
/**
89
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
910
*/
1011
class PhpTest extends TestCase
1112
{
13+
use ExpectException;
1214
/**
1315
* @var Php
1416
*/
@@ -36,32 +38,32 @@ public function testGetSupportedExtensions()
3638
/**
3739
* @covers Noodlehaus\Parser\Php::parseFile()
3840
* @covers Noodlehaus\Parser\Php::parse()
39-
* @expectedException Noodlehaus\Exception\UnsupportedFormatException
40-
* @expectedExceptionMessage PHP data does not return an array
4141
*/
4242
public function testLoadInvalidPhp()
4343
{
44+
$this->expectException(\Noodlehaus\Exception\UnsupportedFormatException::class);
45+
$this->expectExceptionMessage('PHP data does not return an array');
4446
$this->php->parseFile(__DIR__ . '/../mocks/fail/error.php');
4547
}
4648

4749
/**
4850
* @covers Noodlehaus\Parser\Php::parseFile()
49-
* @expectedException Noodlehaus\Exception\ParseException
50-
* @expectedExceptionMessage PHP file threw an exception
5151
*/
5252
public function testLoadExceptionalPhpFile()
5353
{
54+
$this->expectException(\Noodlehaus\Exception\ParseException::class);
55+
$this->expectExceptionMessage('PHP file threw an exception');
5456
$this->php->parseFile(__DIR__ . '/../mocks/fail/error-exception.php');
5557
}
5658

5759
/**
5860
* @covers Noodlehaus\Parser\Php::parseString()
5961
* @covers Noodlehaus\Parser\Php::isolate()
60-
* @expectedException Noodlehaus\Exception\ParseException
61-
* @expectedExceptionMessage PHP string threw an exception
6262
*/
6363
public function testLoadExceptionalPhpString()
6464
{
65+
$this->expectException(\Noodlehaus\Exception\ParseException::class);
66+
$this->expectExceptionMessage('PHP string threw an exception');
6567
$this->php->parseString(file_get_contents(__DIR__ . '/../mocks/fail/error-exception.php'));
6668
}
6769

tests/Parser/SerializeTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
22
namespace Noodlehaus\Parser\Test;
33

4-
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
54
use Noodlehaus\Parser\Serialize;
5+
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
6+
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
67

78
/**
89
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
910
*/
1011
class SerializeTest extends TestCase
1112
{
13+
use ExpectException;
1214
/**
1315
* @var Serialize
1416
*/
@@ -36,11 +38,11 @@ public function testGetSupportedExtensions()
3638
/**
3739
* @covers Noodlehaus\Parser\Serialize::parseFile()
3840
* @covers Noodlehaus\Parser\Serialize::parse()
39-
* @expectedException Noodlehaus\Exception\ParseException
40-
* @expectedExceptionMessage unserialize(): Error at offset 57 of 58 bytes
4141
*/
4242
public function testLoadInvalidSerialize()
4343
{
44+
$this->expectException(\Noodlehaus\Exception\ParseException::class);
45+
$this->expectExceptionMessage('unserialize(): Error at offset 57 of 58 bytes');
4446
$this->serialize->parseFile(__DIR__ . '/../mocks/fail/error.txt');
4547
}
4648

tests/Parser/XmlTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
22
namespace Noodlehaus\Parser\Test;
33

4-
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
54
use Noodlehaus\Parser\Xml;
5+
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
6+
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
67

78
/**
89
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
910
*/
1011
class XmlTest extends TestCase
1112
{
13+
use ExpectException;
1214
/**
1315
* @var Xml
1416
*/
@@ -36,11 +38,11 @@ public function testGetSupportedExtensions()
3638
/**
3739
* @covers Noodlehaus\Parser\Xml::parseFile()
3840
* @covers Noodlehaus\Parser\Xml::parse()
39-
* @expectedException Noodlehaus\Exception\ParseException
40-
* @expectedExceptionMessage Opening and ending tag mismatch: name line 4
4141
*/
4242
public function testLoadInvalidXml()
4343
{
44+
$this->expectException(\Noodlehaus\Exception\ParseException::class);
45+
$this->expectExceptionMessage('Opening and ending tag mismatch: name line 4');
4446
$this->xml->parseFile(__DIR__ . '/../mocks/fail/error.xml');
4547
}
4648

tests/Parser/YamlTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
22
namespace Noodlehaus\Parser\Test;
33

4-
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
54
use Noodlehaus\Parser\Yaml;
5+
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
6+
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
67

78
/**
89
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
910
*/
1011
class YamlTest extends TestCase
1112
{
13+
use ExpectException;
1214
/**
1315
* @var Yaml
1416
*/
@@ -36,22 +38,22 @@ public function testGetSupportedExtensions()
3638
/**
3739
* @covers Noodlehaus\Parser\Yaml::parseFile()
3840
* @covers Noodlehaus\Parser\Yaml::parse()
39-
* @expectedException Noodlehaus\Exception\ParseException
40-
* @expectedExceptionMessage Error parsing YAML file
4141
*/
4242
public function testLoadInvalidYamlFile()
4343
{
44+
$this->expectException(\Noodlehaus\Exception\ParseException::class);
45+
$this->expectExceptionMessage('Error parsing YAML file');
4446
$this->yaml->parseFile(__DIR__ . '/../mocks/fail/error.yaml');
4547
}
4648

4749
/**
4850
* @covers Noodlehaus\Parser\Yaml::parseString()
4951
* @covers Noodlehaus\Parser\Yaml::parse()
50-
* @expectedException Noodlehaus\Exception\ParseException
51-
* @expectedExceptionMessage Error parsing YAML string
5252
*/
5353
public function testLoadInvalidYamlString()
5454
{
55+
$this->expectException(\Noodlehaus\Exception\ParseException::class);
56+
$this->expectExceptionMessage('Error parsing YAML string');
5557
$this->yaml->parseString(file_get_contents(__DIR__ . '/../mocks/fail/error.yaml'));
5658
}
5759

tests/Writer/IniTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
namespace Noodlehaus\Writer\Test;
44

55
use Noodlehaus\Writer\Ini;
6+
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
67
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
78

89
class IniTest extends TestCase
910
{
11+
use ExpectException;
1012
/**
1113
* @var Ini
1214
*/
@@ -97,11 +99,11 @@ public function testWriteIni()
9799
* @covers Noodlehaus\Writer\Ini::toString()
98100
* @covers Noodlehaus\Writer\Ini::toFile()
99101
* @covers Noodlehaus\Writer\Ini::toINI()
100-
* @expectedException Noodlehaus\Exception\WriteException
101-
* @expectedExceptionMessage There was an error writing the file
102102
*/
103103
public function testUnwritableFile()
104104
{
105+
$this->expectException(\Noodlehaus\Exception\WriteException::class);
106+
$this->expectExceptionMessage('There was an error writing the file');
105107
chmod($this->temp_file, 0444);
106108

107109
$this->writer->toFile($this->data, $this->temp_file);

0 commit comments

Comments
 (0)