Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Add PHP 8.0 support, raise min to PHP 7.3
Browse files Browse the repository at this point in the history
Upgrade to PHPUnit 9.5 for that.
  • Loading branch information
mdio committed Jul 5, 2022
1 parent 0364835 commit de79a3a
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor/
.phpunit.result.cache
composer.lock
!bin/php
!build/.gitkeep
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

Expand Down
2 changes: 1 addition & 1 deletion bin/php
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
8 changes: 5 additions & 3 deletions test/DataFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 3 additions & 1 deletion test/DatumIOTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions test/FileIOTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
30 changes: 16 additions & 14 deletions test/FloatIntEncodingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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),
Expand All @@ -112,15 +114,15 @@ 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);
}

/**
* @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),
Expand All @@ -133,15 +135,15 @@ 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);
}

/**
* @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'),
Expand Down Expand Up @@ -197,7 +199,7 @@ function normal_vals_provider()
/**
* @return array
*/
function float_vals_provider()
public function float_vals_provider()
{
$ary = array();

Expand All @@ -211,7 +213,7 @@ function float_vals_provider()
/**
* @return array
*/
function double_vals_provider()
public function double_vals_provider()
{
$ary = array();

Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 3 additions & 1 deletion test/IODatumReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions test/InterOpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions test/LongEncodingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
6 changes: 4 additions & 2 deletions test/NameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* limitations under the License.
*/

use PHPUnit\Framework\TestCase;

require_once('test_helper.php');

/**
Expand Down Expand Up @@ -60,7 +62,7 @@ function __toString()
/**
* Class NameTest
*/
class NameTest extends PHPUnit_Framework_TestCase
class NameTest extends TestCase
{

/**
Expand Down Expand Up @@ -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);
}
}
7 changes: 3 additions & 4 deletions test/ProtocolFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
4 changes: 3 additions & 1 deletion test/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* limitations under the License.
*/

use PHPUnit\Framework\TestCase;

require_once('test_helper.php');

/**
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit de79a3a

Please sign in to comment.