Skip to content

Commit

Permalink
Merge pull request #141 from hassankhan/ci/add-php-8-1-to-build-matrix
Browse files Browse the repository at this point in the history
Add PHP 8.1 to build matrix
  • Loading branch information
DavidePastore committed Dec 30, 2021
2 parents 1ad529b + bea67ff commit e407ef5
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 57 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
# TODO Add 8.1 version as well
php-versions: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
php-versions: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions tests/AbstractConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function testSetArray()
'host' => 'localhost',
'name' => 'mydatabase'
]);
$this->assertInternalType('array', $this->config->get('database'));
$this->assertIsArray($this->config->get('database'));
$this->assertEquals('localhost', $this->config->get('database.host'));
}

Expand All @@ -152,7 +152,7 @@ public function testCacheWithNestedArray()
'host' => 'localhost',
'name' => 'mydatabase'
]);
$this->assertInternalType('array', $this->config->get('database'));
$this->assertIsArray($this->config->get('database'));
$this->config->set('database.host', '127.0.0.1');
$expected = [
'host' => '127.0.0.1',
Expand Down Expand Up @@ -218,7 +218,7 @@ public function testSetAndUnsetArray()
'host' => 'localhost',
'name' => 'mydatabase'
]);
$this->assertInternalType('array', $this->config->get('database'));
$this->assertIsArray($this->config->get('database'));
$this->assertEquals('localhost', $this->config->get('database.host'));
$this->config->set('database.host', null);
$this->assertNull($this->config->get('database.host'));
Expand Down
18 changes: 10 additions & 8 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
use Noodlehaus\Parser\Json as JsonParser;
use Noodlehaus\Writer\Json as JsonWriter;
use PHPUnit\Framework\TestCase;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;

/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
*/
class ConfigTest extends TestCase
{
use ExpectException;
/**
* @var Config
*/
Expand All @@ -19,11 +21,11 @@ class ConfigTest extends TestCase
* @covers Noodlehaus\Config::load()
* @covers Noodlehaus\Config::loadFromFile()
* @covers Noodlehaus\Config::getParser()
* @expectedException Noodlehaus\Exception\UnsupportedFormatException
* @expectedExceptionMessage Unsupported configuration format
*/
public function testLoadWithUnsupportedFormat()
{
$this->expectException(\Noodlehaus\Exception\UnsupportedFormatException::class);
$this->expectExceptionMessage('Unsupported configuration format');
$config = Config::load(__DIR__ . '/mocks/fail/error.lib');
// $this->markTestIncomplete('Not yet implemented');
}
Expand All @@ -32,11 +34,11 @@ public function testLoadWithUnsupportedFormat()
* @covers Noodlehaus\Config::__construct()
* @covers Noodlehaus\Config::loadFromFile()
* @covers Noodlehaus\Config::getParser()
* @expectedException Noodlehaus\Exception\UnsupportedFormatException
* @expectedExceptionMessage Unsupported configuration format
*/
public function testConstructWithUnsupportedFormat()
{
$this->expectException(\Noodlehaus\Exception\UnsupportedFormatException::class);
$this->expectExceptionMessage('Unsupported configuration format');
$config = new Config(__DIR__ . '/mocks/fail/error.lib');
}

Expand All @@ -46,11 +48,11 @@ public function testConstructWithUnsupportedFormat()
* @covers Noodlehaus\Config::getParser()
* @covers Noodlehaus\Config::getPathFromArray()
* @covers Noodlehaus\Config::getValidPath()
* @expectedException Noodlehaus\Exception\FileNotFoundException
* @expectedExceptionMessage Configuration file: [ladadeedee] cannot be found
*/
public function testConstructWithInvalidPath()
{
$this->expectException(\Noodlehaus\Exception\FileNotFoundException::class);
$this->expectExceptionMessage('Configuration file: [ladadeedee] cannot be found');
$config = new Config('ladadeedee');
}

Expand All @@ -60,10 +62,10 @@ public function testConstructWithInvalidPath()
* @covers Noodlehaus\Config::getParser()
* @covers Noodlehaus\Config::getPathFromArray()
* @covers Noodlehaus\Config::getValidPath()
* @expectedException Noodlehaus\Exception\EmptyDirectoryException
*/
public function testConstructWithEmptyDirectory()
{
$this->expectException(\Noodlehaus\Exception\EmptyDirectoryException::class);
$config = new Config(__DIR__ . '/mocks/empty');
}

Expand Down Expand Up @@ -91,10 +93,10 @@ public function testConstructWithArray()
* @covers Noodlehaus\Config::getParser()
* @covers Noodlehaus\Config::getPathFromArray()
* @covers Noodlehaus\Config::getValidPath()
* @expectedException Noodlehaus\Exception\FileNotFoundException
*/
public function testConstructWithArrayWithNonexistentFile()
{
$this->expectException(\Noodlehaus\Exception\FileNotFoundException::class);
$paths = [__DIR__ . '/mocks/pass/config.xml', __DIR__ . '/mocks/pass/config3.json'];
$config = new Config($paths);

Expand Down
18 changes: 7 additions & 11 deletions tests/Parser/IniTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php
namespace Noodlehaus\Parser\Test;

use Yoast\PHPUnitPolyfills\TestCases\TestCase;
use Noodlehaus\Parser\Ini;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
*/
class IniTest extends TestCase
{
use ExpectException;
/**
* @var Ini
*/
Expand Down Expand Up @@ -36,13 +38,13 @@ public function testGetSupportedExtensions()
/**
* @covers Noodlehaus\Parser\Ini::parseFile()
* @covers Noodlehaus\Parser\Ini::parse()
* @expectedException Noodlehaus\Exception\ParseException
* @expectedExceptionMessage No parsable content
* Tests the case where an INI string contains no parsable data at all, resulting in parse_ini_string
* returning NULL, but not setting an error retrievable by error_get_last()
*/
public function testLoadInvalidIniGBH()
{
$this->expectException(\Noodlehaus\Exception\ParseException::class);
$this->expectExceptionMessage('No parsable content');
$this->ini->parseFile(__DIR__ . '/../mocks/fail/error2.ini');
}

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

if (PHP_VERSION_ID < 50600 && PHP_VERSION_ID >= 50500) {
$this->setExpectedException(
'\Noodlehaus\Exception\ParseException', $exceptionMessage
);
} else {
$this->expectException(\Noodlehaus\Exception\ParseException::class);
$this->expectExceptionMessage($exceptionMessage);
}
$this->expectException(\Noodlehaus\Exception\ParseException::class);
$this->expectExceptionMessage($exceptionMessage);

$this->ini->parseString(file_get_contents(__DIR__ . '/../mocks/fail/error.ini'));
}
Expand Down
8 changes: 5 additions & 3 deletions tests/Parser/JsonTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php
namespace Noodlehaus\Parser\Test;

use Yoast\PHPUnitPolyfills\TestCases\TestCase;
use Noodlehaus\Parser\Json;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
*/
class JsonTest extends TestCase
{
use ExpectException;
/**
* @var Json
*/
Expand Down Expand Up @@ -36,11 +38,11 @@ public function testGetSupportedExtensions()
/**
* @covers Noodlehaus\Parser\Json::parseFile()
* @covers Noodlehaus\Parser\Json::parse()
* @expectedException Noodlehaus\Exception\ParseException
* @expectedExceptionMessage Syntax error
*/
public function testLoadInvalidJson()
{
$this->expectException(\Noodlehaus\Exception\ParseException::class);
$this->expectExceptionMessage('Syntax error');
$this->json->parseFile(__DIR__ . '/../mocks/fail/error.json');
}

Expand Down
16 changes: 9 additions & 7 deletions tests/Parser/PhpTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php
namespace Noodlehaus\Parser\Test;

use Yoast\PHPUnitPolyfills\TestCases\TestCase;
use Noodlehaus\Parser\Php;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
*/
class PhpTest extends TestCase
{
use ExpectException;
/**
* @var Php
*/
Expand Down Expand Up @@ -36,32 +38,32 @@ public function testGetSupportedExtensions()
/**
* @covers Noodlehaus\Parser\Php::parseFile()
* @covers Noodlehaus\Parser\Php::parse()
* @expectedException Noodlehaus\Exception\UnsupportedFormatException
* @expectedExceptionMessage PHP data does not return an array
*/
public function testLoadInvalidPhp()
{
$this->expectException(\Noodlehaus\Exception\UnsupportedFormatException::class);
$this->expectExceptionMessage('PHP data does not return an array');
$this->php->parseFile(__DIR__ . '/../mocks/fail/error.php');
}

/**
* @covers Noodlehaus\Parser\Php::parseFile()
* @expectedException Noodlehaus\Exception\ParseException
* @expectedExceptionMessage PHP file threw an exception
*/
public function testLoadExceptionalPhpFile()
{
$this->expectException(\Noodlehaus\Exception\ParseException::class);
$this->expectExceptionMessage('PHP file threw an exception');
$this->php->parseFile(__DIR__ . '/../mocks/fail/error-exception.php');
}

/**
* @covers Noodlehaus\Parser\Php::parseString()
* @covers Noodlehaus\Parser\Php::isolate()
* @expectedException Noodlehaus\Exception\ParseException
* @expectedExceptionMessage PHP string threw an exception
*/
public function testLoadExceptionalPhpString()
{
$this->expectException(\Noodlehaus\Exception\ParseException::class);
$this->expectExceptionMessage('PHP string threw an exception');
$this->php->parseString(file_get_contents(__DIR__ . '/../mocks/fail/error-exception.php'));
}

Expand Down
8 changes: 5 additions & 3 deletions tests/Parser/SerializeTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php
namespace Noodlehaus\Parser\Test;

use Yoast\PHPUnitPolyfills\TestCases\TestCase;
use Noodlehaus\Parser\Serialize;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
*/
class SerializeTest extends TestCase
{
use ExpectException;
/**
* @var Serialize
*/
Expand Down Expand Up @@ -36,11 +38,11 @@ public function testGetSupportedExtensions()
/**
* @covers Noodlehaus\Parser\Serialize::parseFile()
* @covers Noodlehaus\Parser\Serialize::parse()
* @expectedException Noodlehaus\Exception\ParseException
* @expectedExceptionMessage unserialize(): Error at offset 57 of 58 bytes
*/
public function testLoadInvalidSerialize()
{
$this->expectException(\Noodlehaus\Exception\ParseException::class);
$this->expectExceptionMessage('unserialize(): Error at offset 57 of 58 bytes');
$this->serialize->parseFile(__DIR__ . '/../mocks/fail/error.txt');
}

Expand Down
8 changes: 5 additions & 3 deletions tests/Parser/XmlTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php
namespace Noodlehaus\Parser\Test;

use Yoast\PHPUnitPolyfills\TestCases\TestCase;
use Noodlehaus\Parser\Xml;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
*/
class XmlTest extends TestCase
{
use ExpectException;
/**
* @var Xml
*/
Expand Down Expand Up @@ -36,11 +38,11 @@ public function testGetSupportedExtensions()
/**
* @covers Noodlehaus\Parser\Xml::parseFile()
* @covers Noodlehaus\Parser\Xml::parse()
* @expectedException Noodlehaus\Exception\ParseException
* @expectedExceptionMessage Opening and ending tag mismatch: name line 4
*/
public function testLoadInvalidXml()
{
$this->expectException(\Noodlehaus\Exception\ParseException::class);
$this->expectExceptionMessage('Opening and ending tag mismatch: name line 4');
$this->xml->parseFile(__DIR__ . '/../mocks/fail/error.xml');
}

Expand Down
12 changes: 7 additions & 5 deletions tests/Parser/YamlTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php
namespace Noodlehaus\Parser\Test;

use Yoast\PHPUnitPolyfills\TestCases\TestCase;
use Noodlehaus\Parser\Yaml;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-04-21 at 22:37:22.
*/
class YamlTest extends TestCase
{
use ExpectException;
/**
* @var Yaml
*/
Expand Down Expand Up @@ -36,22 +38,22 @@ public function testGetSupportedExtensions()
/**
* @covers Noodlehaus\Parser\Yaml::parseFile()
* @covers Noodlehaus\Parser\Yaml::parse()
* @expectedException Noodlehaus\Exception\ParseException
* @expectedExceptionMessage Error parsing YAML file
*/
public function testLoadInvalidYamlFile()
{
$this->expectException(\Noodlehaus\Exception\ParseException::class);
$this->expectExceptionMessage('Error parsing YAML file');
$this->yaml->parseFile(__DIR__ . '/../mocks/fail/error.yaml');
}

/**
* @covers Noodlehaus\Parser\Yaml::parseString()
* @covers Noodlehaus\Parser\Yaml::parse()
* @expectedException Noodlehaus\Exception\ParseException
* @expectedExceptionMessage Error parsing YAML string
*/
public function testLoadInvalidYamlString()
{
$this->expectException(\Noodlehaus\Exception\ParseException::class);
$this->expectExceptionMessage('Error parsing YAML string');
$this->yaml->parseString(file_get_contents(__DIR__ . '/../mocks/fail/error.yaml'));
}

Expand Down
6 changes: 4 additions & 2 deletions tests/Writer/IniTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
namespace Noodlehaus\Writer\Test;

use Noodlehaus\Writer\Ini;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

class IniTest extends TestCase
{
use ExpectException;
/**
* @var Ini
*/
Expand Down Expand Up @@ -97,11 +99,11 @@ public function testWriteIni()
* @covers Noodlehaus\Writer\Ini::toString()
* @covers Noodlehaus\Writer\Ini::toFile()
* @covers Noodlehaus\Writer\Ini::toINI()
* @expectedException Noodlehaus\Exception\WriteException
* @expectedExceptionMessage There was an error writing the file
*/
public function testUnwritableFile()
{
$this->expectException(\Noodlehaus\Exception\WriteException::class);
$this->expectExceptionMessage('There was an error writing the file');
chmod($this->temp_file, 0444);

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

0 comments on commit e407ef5

Please sign in to comment.