diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d7448c2..507ffc0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: tests: strategy: matrix: - php-versions: ['7.2', '7.3', '7.4'] + php-versions: ['7.3', '7.4', '8.0', '8.1'] runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 0f8f64a..8468af1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ vendor/ +.phpunit.result.cache composer.lock !bin/php !build/.gitkeep diff --git a/Dockerfile b/Dockerfile index 81940ce..2c99717 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -ARG PHP_VERSION=7.1 +ARG PHP_VERSION=8.0 FROM php:${PHP_VERSION}-cli-alpine -ARG XDEBUG_VERSION=2.7.0RC1 +ARG XDEBUG_VERSION=3.1.5 RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ && apk add --no-cache --virtual .runtime-deps git libzip-dev \ diff --git a/Makefile b/Makefile index 8f331e3..25dbad9 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,10 @@ MAKEFLAGS =+ -rR --warn-undefined-variables .PHONY: composer-install composer-update examples docker run COMPOSER ?= bin/composer.phar -COMPOSER_VERSION ?= 1.8.3 +COMPOSER_VERSION ?= 2.3.8 PHP ?= bin/php -PHP_VERSION ?= 7.2 -XDEBUG_VERSION ?= 2.7.0RC1 +PHP_VERSION ?= 8.0 +XDEBUG_VERSION ?= 3.1.5 export diff --git a/README.md b/README.md index 7434d9b..72bec6d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A library for using [Avro](http://avro.apache.org/) with PHP. Requirements ============ - * PHP >= 7.1 + * PHP >= 7.3 * On 32-bit platforms, the [GMP PHP extension](http://php.net/gmp) * For testing, [PHPUnit](http://www.phpunit.de/) diff --git a/bin/php b/bin/php index 2c81b97..85fc381 100755 --- a/bin/php +++ b/bin/php @@ -7,7 +7,7 @@ command -v docker >/dev/null 2>&1 || { echo "docker is required to run this bina USER=${USER:-$( id -un )} GROUP=${GROUP:-$( id -gn )} COMPOSER_HOME=${COMPOSER_HOME:-${HOME}/.composer} -PHP_VERSION=${PHP_VERSION:-7.1} +PHP_VERSION=${PHP_VERSION:-8.0} DOCKER_OPTS=${DOCKER_OPTS:-'-it'} exec docker run ${DOCKER_OPTS} --rm \ diff --git a/composer.json b/composer.json index 2ee70b2..c6fe09a 100644 --- a/composer.json +++ b/composer.json @@ -3,10 +3,10 @@ "description": "Composer packaging for vanilla Apache Avro, with fixes", "license": "Apache-2.0", "require": { - "php": ">=7.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^5.0" + "phpunit/phpunit": "^9.5" }, "suggest": { "ext-gmp": "Large integer support for 32-bit platforms." diff --git a/test/DataFileTest.php b/test/DataFileTest.php index da23e9b..5ea5662 100644 --- a/test/DataFileTest.php +++ b/test/DataFileTest.php @@ -17,12 +17,14 @@ * limitations under the License. */ +use PHPUnit\Framework\TestCase; + require_once('test_helper.php'); /** * Class DataFileTest */ -class DataFileTest extends PHPUnit_Framework_TestCase +class DataFileTest extends TestCase { private $data_files; const REMOVE_DATA_FILES = true; @@ -62,13 +64,13 @@ protected function remove_data_files() $this->remove_data_file($data_file); } - protected function setUp() + protected function setUp(): void { if (!file_exists(TEST_TEMP_DIR)) mkdir(TEST_TEMP_DIR); $this->remove_data_files(); } - protected function tearDown() + protected function tearDown(): void { $this->remove_data_files(); } diff --git a/test/DatumIOTest.php b/test/DatumIOTest.php index d988b1a..99261fe 100644 --- a/test/DatumIOTest.php +++ b/test/DatumIOTest.php @@ -17,12 +17,14 @@ * limitations under the License. */ +use PHPUnit\Framework\TestCase; + require_once('test_helper.php'); /** * Class DatumIOTest */ -class DatumIOTest extends PHPUnit_Framework_TestCase +class DatumIOTest extends TestCase { /** * @dataProvider data_provider diff --git a/test/FileIOTest.php b/test/FileIOTest.php index cb5bd9d..ebc76ea 100644 --- a/test/FileIOTest.php +++ b/test/FileIOTest.php @@ -17,14 +17,16 @@ * limitations under the License. */ +use PHPUnit\Framework\TestCase; + require_once('test_helper.php'); /** * Tests against a preexisting file created by a different library */ -class FileIOTest extends PHPUnit_Framework_TestCase +class FileIOTest extends TestCase { - protected function tearDown() + protected function tearDown(): void { $file = $this->getTmpFile(); if (file_exists($file)) diff --git a/test/FloatIntEncodingTest.php b/test/FloatIntEncodingTest.php index 302932c..ecf9d7f 100644 --- a/test/FloatIntEncodingTest.php +++ b/test/FloatIntEncodingTest.php @@ -16,12 +16,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use PHPUnit\Framework\TestCase; + require_once('test_helper.php'); /** * Class FloatIntEncodingTest */ -class FloatIntEncodingTest extends PHPUnit_Framework_TestCase +class FloatIntEncodingTest extends TestCase { const FLOAT_TYPE = 'float'; const DOUBLE_TYPE = 'double'; @@ -57,12 +59,12 @@ static function make_special_vals() self::$INT_BITS_NEG_INF = strrev(pack('H*', 'ff800000')); } - function setUp() + public function setUp(): void { self::make_special_vals(); } - function test_special_values() + public function test_special_values() { $this->assertTrue(is_float(self::$FLOAT_NAN), 'float NaN is a float'); $this->assertTrue(is_nan(self::$FLOAT_NAN), 'float NaN is NaN'); @@ -97,7 +99,7 @@ function test_special_values() /** * @return array */ - function special_vals_provider() + public function special_vals_provider() { self::make_special_vals(); return array(array(self::DOUBLE_TYPE, self::$DOUBLE_POS_INF, self::$LONG_BITS_POS_INF), @@ -112,7 +114,7 @@ function special_vals_provider() * @param $val * @param $bits */ - function test_encoding_special_values($type, $val, $bits) + public function test_encoding_special_values($type, $val, $bits) { $this->assert_encode_values($type, $val, $bits); } @@ -120,7 +122,7 @@ function test_encoding_special_values($type, $val, $bits) /** * @return array */ - function nan_vals_provider() + public function nan_vals_provider() { self::make_special_vals(); return array(array(self::DOUBLE_TYPE, self::$DOUBLE_NAN, self::$LONG_BITS_NAN), @@ -133,7 +135,7 @@ function nan_vals_provider() * @param $val * @param $bits */ - function test_encoding_nan_values($type, $val, $bits) + public function test_encoding_nan_values($type, $val, $bits) { $this->assert_encode_nan_values($type, $val, $bits); } @@ -141,7 +143,7 @@ function test_encoding_nan_values($type, $val, $bits) /** * @return array */ - function normal_vals_provider() + public function normal_vals_provider() { return array( array(self::DOUBLE_TYPE, (double) -10, "\000\000\000\000\000\000$\300", '000000000000420c'), @@ -197,7 +199,7 @@ function normal_vals_provider() /** * @return array */ - function float_vals_provider() + public function float_vals_provider() { $ary = array(); @@ -211,7 +213,7 @@ function float_vals_provider() /** * @return array */ - function double_vals_provider() + public function double_vals_provider() { $ary = array(); @@ -229,7 +231,7 @@ function double_vals_provider() * @param $val * @param $bits */ - function test_encoding_float_values($type, $val, $bits) + public function test_encoding_float_values($type, $val, $bits) { $this->assert_encode_values($type, $val, $bits); } @@ -240,7 +242,7 @@ function test_encoding_float_values($type, $val, $bits) * @param $val * @param $bits */ - function test_encoding_double_values($type, $val, $bits) + public function test_encoding_double_values($type, $val, $bits) { $this->assert_encode_values($type, $val, $bits); } @@ -250,7 +252,7 @@ function test_encoding_double_values($type, $val, $bits) * @param $val * @param $bits */ - function assert_encode_values($type, $val, $bits) + public function assert_encode_values($type, $val, $bits) { if (self::FLOAT_TYPE == $type) { @@ -286,7 +288,7 @@ function assert_encode_values($type, $val, $bits) * @param $val * @param $bits */ - function assert_encode_nan_values($type, $val, $bits) + public function assert_encode_nan_values($type, $val, $bits) { if (self::FLOAT_TYPE == $type) { diff --git a/test/IODatumReaderTest.php b/test/IODatumReaderTest.php index 8877c34..14cb74b 100644 --- a/test/IODatumReaderTest.php +++ b/test/IODatumReaderTest.php @@ -17,12 +17,14 @@ * limitations under the License. */ +use PHPUnit\Framework\TestCase; + require_once('test_helper.php'); /** * Class IODatumReaderTest */ -class IODatumReaderTest extends PHPUnit_Framework_TestCase +class IODatumReaderTest extends TestCase { public function testSchemaMatching() diff --git a/test/InterOpTest.php b/test/InterOpTest.php index 58c6fc3..cec58ab 100644 --- a/test/InterOpTest.php +++ b/test/InterOpTest.php @@ -17,17 +17,19 @@ * limitations under the License. */ +use PHPUnit\Framework\TestCase; + require_once('test_helper.php'); /** * Class InterOpTest */ -class InterOpTest extends PHPUnit_Framework_TestCase +class InterOpTest extends TestCase { var $projection_json; var $projection; - public function setUp() + protected function setUp(): void { $interop_schema_file_name = AVRO_INTEROP_SCHEMA; $this->projection_json = file_get_contents($interop_schema_file_name); diff --git a/test/LongEncodingTest.php b/test/LongEncodingTest.php index b645889..3e77c93 100644 --- a/test/LongEncodingTest.php +++ b/test/LongEncodingTest.php @@ -16,15 +16,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use PHPUnit\Framework\TestCase; + require_once('test_helper.php'); /** * Class LongEncodingTest */ -class LongEncodingTest extends PHPUnit_Framework_TestCase +class LongEncodingTest extends TestCase { - function setUp() + protected function setUp(): void { Avro::check_platform(); } diff --git a/test/NameTest.php b/test/NameTest.php index 762eb31..82f83cb 100644 --- a/test/NameTest.php +++ b/test/NameTest.php @@ -17,6 +17,8 @@ * limitations under the License. */ +use PHPUnit\Framework\TestCase; + require_once('test_helper.php'); /** @@ -60,7 +62,7 @@ function __toString() /** * Class NameTest */ -class NameTest extends PHPUnit_Framework_TestCase +class NameTest extends TestCase { /** @@ -128,6 +130,6 @@ function name_provider() */ function test_name($name, $is_well_formed) { - $this->assertEquals(AvroName::is_well_formed_name($name), $is_well_formed, $name); + $this->assertEquals(AvroName::is_well_formed_name($name), $is_well_formed); } } diff --git a/test/ProtocolFileTest.php b/test/ProtocolFileTest.php index 2bee97a..caa53f2 100644 --- a/test/ProtocolFileTest.php +++ b/test/ProtocolFileTest.php @@ -17,17 +17,16 @@ * limitations under the License. */ +use PHPUnit\Framework\TestCase; + require_once('test_helper.php'); // near-verbatim port of test_protocol.py /** * Class ProtocolFileTest */ -class ProtocolFileTest extends PHPUnit_Framework_TestCase +class ProtocolFileTest extends TestCase { - protected function setUp() { - } - public function testParsing() { $cnt=count($this->prot_parseable); for ($i=0; $i<$cnt; $i++) { diff --git a/test/SchemaTest.php b/test/SchemaTest.php index 5292935..461bef0 100644 --- a/test/SchemaTest.php +++ b/test/SchemaTest.php @@ -17,6 +17,8 @@ * limitations under the License. */ +use PHPUnit\Framework\TestCase; + require_once('test_helper.php'); /** @@ -53,7 +55,7 @@ function __construct($schema_string, $is_valid, $normalized_schema_string=null, /** * Class SchemaTest */ -class SchemaTest extends PHPUnit_Framework_TestCase +class SchemaTest extends TestCase { static $examples = array(); static $valid_examples = array(); diff --git a/test/StringIOTest.php b/test/StringIOTest.php index 58d67dd..f8b72ed 100644 --- a/test/StringIOTest.php +++ b/test/StringIOTest.php @@ -17,12 +17,14 @@ * limitations under the License. */ +use PHPUnit\Framework\TestCase; + require_once('test_helper.php'); /** * Class StringIOTest */ -class StringIOTest extends PHPUnit_Framework_TestCase +class StringIOTest extends TestCase { public function test_write()