Skip to content

Commit 59c5cd1

Browse files
authored
Github Actions (#73)
testing github actions
1 parent bfd75dd commit 59c5cd1

File tree

4 files changed

+90
-5
lines changed

4 files changed

+90
-5
lines changed

.github/workflows/tests.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction"
7+
CC_TEST_REPORTER_ID: CODECLIMATE_REPORTER_ID
8+
jobs:
9+
phpunit:
10+
name: PHP ${{ matrix.php }} on ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest]
16+
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
17+
steps:
18+
## checkout the repoistory §
19+
- name: Checkout Repo
20+
uses: actions/checkout@v2
21+
22+
- name: Build server image
23+
run: docker build . -t localserver
24+
working-directory: ./tests/server
25+
26+
- name: Run test server
27+
run: docker run -d -p 1234:80 localserver
28+
29+
## Install php
30+
- name: Install PHP
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php }}
34+
extensions: curl, mbstring, imagick, gd
35+
ini-values: date.timezone='UTC'
36+
coverage: xdebug
37+
38+
## install composer
39+
- name: Install dependencies
40+
run: composer install $DEFAULT_COMPOSER_FLAGS
41+
42+
## run unit tests
43+
- name: PHP Unit tests for PHP
44+
run: vendor/bin/phpunit --verbose --configuration actions.phpunit.xml
45+
if: matrix.php == '8.0' || matrix.php == '7.4' || matrix.php == '7.3' || matrix.php == '7.2' || matrix.php == '7.0' || matrix.php == '5.6'
46+
47+
## unit test with coverage
48+
- name: PHP Unit tests for PHP 7.1
49+
run: vendor/bin/phpunit --verbose --coverage-clover=clover.xml --configuration actions.phpunit.xml
50+
if: matrix.php == '7.1'
51+
52+
## coverage
53+
- name: Code coverage
54+
run: |
55+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
56+
chmod +x ./cc-test-reporter
57+
./cc-test-reporter after-build -t clover
58+
if: matrix.php == '7.1'
59+
continue-on-error: true # if is fork

actions.phpunit.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
colors="true"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
processIsolation="false"
9+
stopOnFailure="false"
10+
syntaxCheck="true"
11+
verbose="false"
12+
bootstrap="vendor/autoload.php"
13+
>
14+
<php>
15+
<ini name="display_errors" value="on"/>
16+
</php>
17+
18+
<testsuites>
19+
<testsuite name="PHP MP4Box Tests Suite">
20+
<directory>tests</directory>
21+
</testsuite>
22+
</testsuites>
23+
24+
</phpunit>

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
"ext-curl": "*"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "^5.7",
29-
"squizlabs/php_codesniffer": "~2.1"
28+
"yoast/phpunit-polyfills": "^0.2.0"
3029
},
3130
"autoload": {
3231
"psr-0": {

tests/CurlTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@
22

33
namespace Curl;
44

5-
class CurlTest extends \PHPUnit_Framework_TestCase
5+
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
6+
7+
class CurlTest extends TestCase
68
{
79

8-
const TEST_URL = 'http://server_test';
10+
const TEST_URL = 'http://localhost:1234';
911

1012
/**
1113
*
1214
* @var Curl
1315
*/
1416
protected $curl;
1517

16-
function setUp() {
18+
function set_up() {
19+
parent::set_up();
1720
$this->curl = new Curl();
1821
$this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE);
1922
$this->curl->setOpt(CURLOPT_SSL_VERIFYHOST, FALSE);

0 commit comments

Comments
 (0)