Skip to content

Commit fe86ec8

Browse files
authored
Merge pull request #54 from mikehaertl/github-actions
Migrate to GitHub Actions
2 parents 06d6220 + f926d3e commit fe86ec8

9 files changed

+73
-39
lines changed

.github/workflows/tests.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Tests
2+
on: pull_request
3+
jobs:
4+
phpunit:
5+
name: PHP ${{ matrix.php }}
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
php:
10+
- "5.3"
11+
- "5.4"
12+
- "5.5"
13+
- "5.6"
14+
- "7.0"
15+
- "7.1"
16+
- "7.2"
17+
- "7.3"
18+
- "7.4"
19+
- "8.0"
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
24+
- name: Install PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php }}
28+
tools: composer:v2
29+
30+
- name: Update composer
31+
run: composer self-update
32+
33+
- name: Get composer cache directory
34+
id: composer-cache
35+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
36+
37+
- name: Cache dependencies
38+
uses: actions/cache@v2
39+
with:
40+
path: ${{ steps.composer-cache.outputs.dir }}
41+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
42+
restore-keys: ${{ runner.os }}-composer-
43+
44+
- name: Install composer packages
45+
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
46+
47+
- name: Run phpunit
48+
run: vendor/bin/phpunit --color=always

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
phpunit.xml
22
composer.lock
33
/vendor/
4+
.phpunit.result.cache
45
*.swp

.travis.yml

-14
This file was deleted.

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
php-shellcommand
22
===========
33

4-
[![Build Status](https://secure.travis-ci.org/mikehaertl/php-shellcommand.png)](http://travis-ci.org/mikehaertl/php-shellcommand)
5-
[![Latest Stable Version](https://poser.pugx.org/mikehaertl/php-shellcommand/v/stable.svg)](https://packagist.org/packages/mikehaertl/php-shellcommand)
6-
[![Total Downloads](https://poser.pugx.org/mikehaertl/php-shellcommand/downloads)](https://packagist.org/packages/mikehaertl/php-shellcommand)
7-
[![Latest Unstable Version](https://poser.pugx.org/mikehaertl/php-shellcommand/v/unstable.svg)](https://packagist.org/packages/mikehaertl/php-shellcommand)
8-
[![License](https://poser.pugx.org/mikehaertl/php-shellcommand/license.svg)](https://packagist.org/packages/mikehaertl/php-shellcommand)
4+
[![GitHub Tests](https://github.com/mikehaertl/php-shellcommand/workflows/Tests/badge.svg)](https://github.com/mikehaertl/php-shellcommand/actions)
5+
[![Packagist Version](https://img.shields.io/packagist/v/mikehaertl/php-shellcommand?label=version)](https://packagist.org/packages/mikehaertl/php-shellcommand)
6+
[![Packagist Downloads](https://img.shields.io/packagist/dt/mikehaertl/php-shellcommand)](https://packagist.org/packages/mikehaertl/php-shellcommand)
7+
[![GitHub license](https://img.shields.io/github/license/mikehaertl/php-shellcommand)](https://github.com/mikehaertl/php-shellcommand/blob/master/LICENSE)
8+
[![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/mikehaertl/php-shellcommand)](https://packagist.org/packages/mikehaertl/php-shellcommand)
99

1010
php-shellcommand provides a simple object oriented interface to execute shell commands.
1111

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">= 5.4.0"
13+
"php": ">= 5.3.0"
1414
},
1515
"require-dev": {
16-
"phpunit/phpunit": ">4.0 <8"
16+
"phpunit/phpunit": ">4.0 <=9.4"
1717
},
1818
"autoload": {
1919
"psr-4": {

phpunit.xml.dist

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
bootstrap="./tests/bootstrap.php"
1312
>
1413
<testsuites>

tests/BlockingCommandTest.php

-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66

77
class BlockingCommandTest extends TestCase
88
{
9-
public function setUp()
10-
{
11-
// Default in some installations
12-
setlocale(LC_CTYPE, 'C');
13-
}
14-
159
// Create command from command string
1610
public function testCanPassCommandStringToConstructor()
1711
{

tests/CommandTest.php

-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66

77
class CommandTest extends TestCase
88
{
9-
public function setUp()
10-
{
11-
// Default in some installations
12-
setlocale(LC_CTYPE, 'C');
13-
}
14-
159
// Create command from command string
1610
public function testCanPassCommandStringToConstructor()
1711
{

tests/bootstrap.php

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
<?php
2-
// Some travis environments use phpunit > 6
3-
$newClass = '\PHPUnit\Framework\TestCase';
4-
$oldClass = '\PHPUnit_Framework_TestCase';
5-
if (!class_exists($newClass) && class_exists($oldClass)) {
6-
class_alias($oldClass, $newClass);
2+
/**
3+
* Utility method to check the version of PHPUnit.
4+
*
5+
* Example: phpUnitVersion('<', '8.3'); // true e.g. for 8.2.1
6+
*
7+
* @param string $operator an operator like '>', '<', etc.
8+
* @param string $version the version to check against
9+
* @return bool whether PHPUnit matches the version to check
10+
*/
11+
function phpUnitVersion($operator, $version)
12+
{
13+
$phpUnitVersion = class_exists('\PHPUnit\Runner\Version') ?
14+
call_user_func(array('\PHPUnit\Runner\Version', 'id')) :
15+
call_user_func(array('\PHPUnit_Runner_Version', 'id'));
16+
return version_compare($phpUnitVersion, $version, $operator);
717
}
818

919
require __DIR__ . '/../vendor/autoload.php';
1020

21+
// Default in some installations
22+
setlocale(LC_CTYPE, 'C');

0 commit comments

Comments
 (0)