Skip to content

Commit

Permalink
Merge pull request #8 from matsuo/migrate-to-github-actions
Browse files Browse the repository at this point in the history
Add a workflow file for GitHub Actions to add support for PHP 8.0 or later and drop support for PHP 5.x
  • Loading branch information
CloCkWeRX authored Jul 16, 2024
2 parents a2c9e23 + 3dc4dbd commit ced326b
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 44 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test

on:
push:
branches:
- "*"
pull_request:
branches: [ master ]

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ '8.0', '8.1', '8.2', '8.3' ]
steps:
- uses: actions/checkout@v4
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Install dependencies
shell: bash
run: |
composer install
- name: Run tests
shell: bash
run: |
./vendor/bin/phpunit --colors ./tests/AllTests.php
8 changes: 3 additions & 5 deletions File/IMC/Parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,14 @@ public function _splitByDelim($text, $delim, $recurse = true)
// if the current char is a double-quote, and the
// previous char was _not_ an escaping backslash,
// then note that we are now inside a quoted passage.
if ($text{$i} == '"' && $prevIsBackslash == false) {
if ($text[$i] == '"' && $prevIsBackslash == false) {
($inQuotes == true) ? $inQuotes = false : $inQuotes = true;
}
// if the current char is the delimiter, and we are _not_
// inside quotes, and the delimiter has not been backslash-
// escaped, then note the position of the delimiter and
// break out of the loop.
if ( $text{$i} == $delim
if ( $text[$i] == $delim
&& $inQuotes == false
&& $prevIsBackslash == false
) {
Expand All @@ -224,7 +224,7 @@ public function _splitByDelim($text, $delim, $recurse = true)
}
// we have not found quotes, or the delimiter.
// is the current char an escaping backslash?
if ($text{$i} == "\\") {
if ($text[$i] == "\\") {
$prevIsBackslash = true;
} else {
$prevIsBackslash = false;
Expand Down Expand Up @@ -693,5 +693,3 @@ protected function _charset_conv(array $params, $text, $charset='UTF-8')
}

}

?>
4 changes: 1 addition & 3 deletions File/IMC/Parse/Vcalendar.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
/**+----------------------------------------------------------------------+
* | PHP version 5 |
* +----------------------------------------------------------------------+
* | Copyright (c) 1997-2008 The PHP Group |
* +----------------------------------------------------------------------+
* | All rights reserved. |
Expand Down
16 changes: 8 additions & 8 deletions File/IMC/Parse/Vcalendar/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ public function __construct(array $data)
$this->index = 0;
}

public function append($value)
public function append($value): void
{
}

public function count()
public function count(): int
{
return count($this->data);
}

public function current()
public function current(): mixed
{
return new File_IMC_Parse_Vcalendar_Event($this->data[$this->index]);
}
Expand All @@ -99,27 +99,27 @@ public function get($index)
}
*/

public function key()
public function key(): string|int|null
{
return $this->index;
}

public function next()
public function next(): void
{
++$this->index;
}

public function rewind()
public function rewind(): void
{
$this->index = 0;
}

public function seek($position)
public function seek($position): void
{
$this->index = $position;
}

public function valid()
public function valid(): bool
{
if (isset($this->data[$this->index])) {
return true;
Expand Down
2 changes: 0 additions & 2 deletions File/IMC/Parse/Vcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,3 @@ protected function _parseGEO($text)
);
}
}

?>
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
"File": "./"
}
},
"description": "More info available on: http://pear.php.net/package/File_IMC",
"description": "More info available on: https://pear.php.net/package/File_IMC",
"include-path": [
"./"
],
"license": "BSD-2-Clause",
"name": "pear/file_imc",
"support": {
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=File_IMC",
"issues": "https://pear.php.net/bugs/search.php?cmd=display&package_name[]=File_IMC",
"source": "https://github.com/pear/File_IMC"
},
"type": "library",
"require-dev": {
"phpunit/phpunit": "*"
"phpunit/phpunit": "^9"
}
}
11 changes: 4 additions & 7 deletions tests/AllTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,22 @@ class File_IMC_AllTests
* Launches the TextUI test runner
*
* @return void
* @uses PHPUnit_TextUI_TestRunner
*/
public static function main()
{
PHPUnit_TextUI_TestRunner::run(self::suite());
}


/**
* Adds all class test suites into the master suite
*
* @return PHPUnit_Framework_TestSuite a master test suite
* @return PHPUnit\Framework\TestSuite a master test suite
* containing all class test suites
* @uses PHPUnit_Framework_TestSuite
* @uses PHPUnit\Framework\TestSuite
*/
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite(
'File_IMC Full Suite of Unit Tests');
$suite = new \PHPUnit\Framework\TestSuite('File_IMC Full Suite of Unit Tests');

/*
* You must add each additional class-level test suite name here
Expand All @@ -137,7 +134,7 @@ public static function suite()
/*
* add PHPT tests
*/
$phpt = new PHPUnit_Extensions_PhptTestSuite(File_IMC_DIR_PHPT);
$phpt = new \PHPUnit\Framework\TestSuite(File_IMC_DIR_PHPT);
$suite->addTestSuite($phpt);

return $suite;
Expand Down
2 changes: 1 addition & 1 deletion tests/File/IMC/BugsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @version Release: @package_version@
* @link http://pear.php.net/package/File_IMC
*/
class File_IMC_BugsTest extends PHPUnit_Framework_TestCase
class File_IMC_BugsTest extends \PHPUnit\Framework\TestCase
{
public function testBug17656()
{
Expand Down
15 changes: 8 additions & 7 deletions tests/File/IMC/BuildTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @version Release: @package_version@
* @link http://pear.php.net/package/File_IMC
*/
class File_IMC_BuildTest extends PHPUnit_Framework_TestCase
class File_IMC_BuildTest extends \PHPUnit\Framework\TestCase
{
/**
* @var File_IMC_Build_Vcard
Expand All @@ -50,7 +50,7 @@ class File_IMC_BuildTest extends PHPUnit_Framework_TestCase
* @uses self::$vcard
* @uses self::$parser
*/
public function setUp()
public function setUp(): void
{
$this->vcard = File_IMC::build('vcard');
}
Expand Down Expand Up @@ -239,18 +239,20 @@ public function testSettingValues($propName,$passedValue,$depMethod=null,$propVa
}

/**
* @expectedException File_IMC_Exception
* Test Exception
*/
public function testExceptionIfNoFormatIsProvided()
{
$this->expectException('File_IMC_Exception');
$foo = File_IMC::build('');
}

/**
* @expectedException File_IMC_Exception
* Test Exception
*/
public function testExceptionIfInvalidFormatIsProvided()
{
$this->expectException('File_IMC_Exception');
$foo = File_IMC::build('bar');
}

Expand All @@ -274,10 +276,11 @@ public function testFormattedName()
}

/**
* @expectedException File_IMC_Exception
*Test Exception
*/
public function testVersionException()
{
$this->expectException('File_IMC_Exception');
$this->vcard->setVersion('4.0');
}

Expand All @@ -291,5 +294,3 @@ public function testVersion()
$this->assertSame("VERSION:{$version}", $this->vcard->get('VERSION'));
}
}

?>
4 changes: 2 additions & 2 deletions tests/File/IMC/Parse/VcalendarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @version Release: @package_version@
* @link http://pear.php.net/package/File_IMC
*/
class File_IMC_Parse_VcalendarTest extends PHPUnit_Framework_TestCase
class File_IMC_Parse_VcalendarTest extends \PHPUnit\Framework\TestCase
{
/**
* @var File_IMC_Parse_Vcalendar
Expand All @@ -51,7 +51,7 @@ class File_IMC_Parse_VcalendarTest extends PHPUnit_Framework_TestCase
* @uses self::$parser
* @uses self::$calendar
*/
public function setUp()
public function setUp(): void
{
self::$parser = File_IMC::parse('vcalendar');

Expand Down
12 changes: 6 additions & 6 deletions tests/File/IMC/ParseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @version Release: @package_version@
* @link http://pear.php.net/package/File_IMC
*/
class File_IMC_ParseTest extends PHPUnit_Framework_TestCase
class File_IMC_ParseTest extends \PHPUnit\Framework\TestCase
{
/**
* @var string
Expand All @@ -56,7 +56,7 @@ class File_IMC_ParseTest extends PHPUnit_Framework_TestCase
* @uses self::$vcard
* @uses self::$parser
*/
public function setUp()
public function setUp(): void
{
$familyName = "FamilyName";
$givenName = "GivenName";
Expand Down Expand Up @@ -272,20 +272,20 @@ public static function provideInterfaceTestData()
}

/**
* @expectedException File_IMC_Exception
* Test Exception
*/
public function testExceptionIfNoFormatIsProvided()
{
$this->expectException('File_IMC_Exception');
$foo = File_IMC::parse('');
}

/**
* @expectedException File_IMC_Exception
* Test Exception
*/
public function testExceptionIfInvalidFormatIsProvided()
{
$this->expectException('File_IMC_Exception');
$foo = File_IMC::parse('bar');
}
}

?>

0 comments on commit ced326b

Please sign in to comment.