Skip to content

Commit 2fe1a48

Browse files
committed
Move to github actions
1 parent 2176aa4 commit 2fe1a48

File tree

11 files changed

+358
-200
lines changed

11 files changed

+358
-200
lines changed

.github/workflows/tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
php-tests:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
php: [8.0, 7.4, 7.3, 7.2]
12+
dependency-version: [prefer-stable]
13+
os: [ubuntu-latest, windows-latest]
14+
15+
name: ${{ matrix.os }} - PHP${{ matrix.php }} - ${{ matrix.dependency-version }}
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v2
20+
21+
- name: Cache dependencies
22+
uses: actions/cache@v2
23+
with:
24+
path: ~/.composer/cache/files
25+
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
26+
27+
- name: Setup PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: ${{ matrix.php }}
31+
extensions: dom, curl, libxml, mbstring, zip, intl
32+
coverage: none
33+
34+
- name: Install dependencies
35+
run: |
36+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --ignore-platform-reqs
37+
38+
- name: Execute tests
39+
run: vendor/bin/phpunit
40+

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ vendor/
22
.idea/
33
bin/
44
composer.lock
5-
.php_cs.cache
65
.phpunit.result.cache
6+
.php-cs-fixer.cache
77
phpunit.xml

.php-cs-fixer.dist.php

Lines changed: 287 additions & 0 deletions
Large diffs are not rendered by default.

.php_cs.dist

Lines changed: 0 additions & 153 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PHPFUI\HTMLUnitTester [![Build Status](https://api.travis-ci.com/phpfui/HTMLUnitTester.png?branch=master)](https://api.travis-ci.com/phpfui/HTMLUnitTester) [![Latest Packagist release](https://img.shields.io/packagist/v/phpfui/html-unit-tester.svg)](https://packagist.org/packages/phpfui/html-unit-tester)
1+
# PHPFUI\HTMLUnitTester [![Tests](https://github.com/phpfui/HTMLUnitTester/actions/workflows/tests.yml/badge.svg)](https://github.com/phpfui/HTMLUnitTester/actions?query=workflow%3Atests) [![Latest Packagist release](https://img.shields.io/packagist/v/phpfui/html-unit-tester.svg)](https://packagist.org/packages/phpfui/html-unit-tester)
22

33
[PHPUnit](https://phpunit.de/) Testing extensions for HMTL and CSS. **PHPFUI\HTMLUnitTester** allows you to unit test HTML and CSS for errors and warnings. Often simple errors in HTML or CSS create hard to debug issues where a simple check will reveal bad code.
44

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
}
1313
],
1414
"require": {
15-
"php": ">=7.1",
15+
"php": "^7.2 | <8.1",
1616
"rexxars/html-validator": ">=2.2"
1717
},
1818
"require-dev": {
1919
"phpunit/phpunit": ">=7.0",
2020
"phpfui/phpunit-syntax-coverage": ">=1.0",
2121
"roave/security-advisories": "dev-latest",
22-
"fabpot/php-cs-fixer": "dev-master"
22+
"friendsofphp/php-cs-fixer": "^3.2"
2323
},
2424
"autoload": {
2525
"psr-0": {"PHPFUI": "src/"}

src/PHPFUI/HTMLUnitTester/Extensions.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ public function assertDirectory(string $type, string $directory, string $message
9393
if ($recurseSubdirectories)
9494
{
9595
$iterator = new \RecursiveIteratorIterator(
96-
new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS),
97-
\RecursiveIteratorIterator::SELF_FIRST);
96+
new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS),
97+
\RecursiveIteratorIterator::SELF_FIRST
98+
);
9899
}
99100
else
100101
{

tests/SyntaxTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
class SyntaxTest extends \PHPFUI\PHPUnitSyntaxCoverage\Extensions
44
{
5-
65
public function testDirectory() : void
76
{
87
$this->assertValidPHPDirectory(__DIR__ . '/../src', 'src directory has an error');
98
}
10-
119
}

tests/UnitTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@
99
* the LICENSE.md file that was distributed with this source
1010
* code
1111
*/
12-
13-
use \PHPFUI\HTMLUnitTester\Extensions;
14-
1512
class UnitTest extends \PHPFUI\HTMLUnitTester\Extensions
1613
{
17-
1814
public function testNotWarningCss() : void
1915
{
2016
$this->assertNotWarningCss('strong {font-weight: bolder;}');
@@ -65,7 +61,7 @@ public function testValidFile() : void
6561
$this->assertValidFile('examples/valid.html');
6662
}
6763

68-
public function testValidHtml()
64+
public function testValidHtml() : void
6965
{
7066
$this->assertValidHtml('<h1>Header</h1>');
7167
$this->assertValidHtml('<!DOCTYPE html><html><head><meta charset="utf-8"/><title>Title</title></head><body><div>This is a test</div></body></html>');
@@ -83,5 +79,4 @@ public function testDirectory() : void
8379
$this->assertDirectory('NotWarning', 'examples');
8480
$this->assertDirectory('NotWarningCSS', 'examples');
8581
}
86-
87-
}
82+
}

tests/bootstrap.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
11
<?php
22

3-
error_reporting(E_ALL);
3+
\error_reporting(E_ALL);
44

55
function classNameExists(string $className) : string
66
{
7-
$path = ".\\src\\$className.php";
8-
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
9-
{
10-
$path = str_replace('\\', '/', $path);
11-
}
7+
$path = ".\\src\\{$className}.php";
128

13-
return file_exists($path) ? $path : '';
9+
if ('WIN' !== \strtoupper(\substr(PHP_OS, 0, 3)))
10+
{
11+
$path = \str_replace('\\', '/', $path);
12+
}
13+
14+
return \file_exists($path) ? $path : '';
1415
}
1516

16-
function autoload($className)
17+
function autoload($className) : void
1718
{
18-
$path = classNameExists($className);
19+
$path = \classNameExists($className);
20+
1921
if ($path)
20-
{
21-
/** @noinspection PhpIncludeInspection */
22-
include $path;
23-
}
22+
{
23+
/** @noinspection PhpIncludeInspection */
24+
include $path;
25+
}
2426
}
25-
spl_autoload_register('autoload');
27+
\spl_autoload_register('autoload');
2628

2729
$vendorDir = __DIR__ . '/../../..';
2830

29-
if (file_exists($file = $vendorDir . '/autoload.php')) {
30-
require_once $file;
31-
} elseif (file_exists($file = './vendor/autoload.php')) {
32-
require_once $file;
31+
if (\file_exists($file = $vendorDir . '/autoload.php')) {
32+
require_once $file;
33+
} elseif (\file_exists($file = './vendor/autoload.php')) {
34+
require_once $file;
3335
} else {
34-
throw new \RuntimeException('Composer autoload file not found');
35-
}
36+
throw new \RuntimeException('Composer autoload file not found');
37+
}

0 commit comments

Comments
 (0)