Skip to content

Commit 1938196

Browse files
committed
Add Github workflow build support for all php 7 versions.
1 parent c2c9dd5 commit 1938196

File tree

5 files changed

+54
-15
lines changed

5 files changed

+54
-15
lines changed

.github/workflows/php.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: PHP Composer
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4']
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
- name: Install PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: ${{ matrix.php-versions }}
22+
- name: Validate composer.json and composer.lock
23+
run: composer validate
24+
- name: Install dependencies
25+
run: composer install --prefer-dist --no-progress
26+
- name: Run PHPCS
27+
run: composer run-script lint
28+
- name: Run PHPUnit
29+
run: composer run-script test

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/vendor/
33
/clover.xml
44
composer.lock
5+
.phpunit.result.cache

composer.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@
2424
"sort-packages": true
2525
},
2626
"require": {
27-
"php": "^5.6 || ^7.0",
27+
"php": "^7.0",
2828
"squizlabs/php_codesniffer": "^2.6"
2929
},
3030
"require-dev": {
31-
"phpunit/phpunit": "^5.5"
31+
"phpunit/phpunit": ">=6"
32+
},
33+
"scripts": {
34+
"lint": "vendor/bin/phpcs",
35+
"test": "vendor/bin/phpunit"
3236
}
3337
}

phpcs.xml.dist

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="PHP_CodeSniffer">
3+
<file>.</file>
4+
<exclude-pattern>*/vendor/*</exclude-pattern>
5+
<exclude-pattern>*.inc</exclude-pattern>
6+
<arg name="colors"/>
7+
<arg value="np"/>
8+
<rule ref="DWS"/>
9+
</ruleset>

tests/AbstractSniffUnitTest.php

+9-13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* @package PHP_CodeSniffer
77
*/
88

9+
use PHPUnit\Framework\TestCase;
10+
911
/**
1012
* An abstract class that all sniff unit tests must extend.
1113
*
@@ -16,7 +18,7 @@
1618
* @category PHP
1719
* @package PHP_CodeSniffer
1820
*/
19-
abstract class AbstractSniffUnitTest extends PHPUnit_Framework_TestCase
21+
abstract class AbstractSniffUnitTest extends TestCase
2022
{
2123
/**
2224
* The PHP_CodeSniffer object used for testing.
@@ -26,27 +28,19 @@ abstract class AbstractSniffUnitTest extends PHPUnit_Framework_TestCase
2628
protected static $_phpcs = null;
2729

2830
/**
29-
* Sets up this unit test.
31+
* Tests the extending classes Sniff class.
3032
*
3133
* @return void
34+
* @throws PHPUnit_Framework_Error
35+
* @test
3236
*/
33-
protected function setUp()
37+
public final function runTest()
3438
{
3539
if (self::$_phpcs === null) {
3640
self::$_phpcs = new PHP_CodeSniffer();
3741
self::$_phpcs->cli->setCommandLineValues(['-s']);
3842
}
39-
}
4043

41-
/**
42-
* Tests the extending classes Sniff class.
43-
*
44-
* @return void
45-
* @throws PHPUnit_Framework_Error
46-
* @test
47-
*/
48-
public final function runTest()
49-
{
5044
self::$_phpcs->process([], 'DWS', [$this->_getSniffName()]);
5145
self::$_phpcs->setIgnorePatterns([]);
5246

@@ -72,6 +66,8 @@ public final function runTest()
7266
if (count($failureMessages) > 0) {
7367
$this->fail(implode("\n", $failureMessages));
7468
}
69+
70+
$this->assertEmpty($failureMessages);
7571
}
7672

7773
/**

0 commit comments

Comments
 (0)