Skip to content

Commit 06cbacd

Browse files
authored
Merge pull request #6 from duboism/test_and_github_actions
Add tests and GitHub actions
2 parents 9e0b080 + e13aa67 commit 06cbacd

File tree

12 files changed

+87
-20
lines changed

12 files changed

+87
-20
lines changed

.github/workflows/main.yaml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Main
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- master
9+
- release/**
10+
pull_request:
11+
branches:
12+
- main
13+
- master
14+
- release/**
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
run:
22+
runs-on: ${{ matrix.operating-system }}
23+
strategy:
24+
matrix:
25+
operating-system: ['ubuntu-latest']
26+
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
27+
steps:
28+
- name: Get source code
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
- name: Setup PHP
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: ${{ matrix.php-versions }}
36+
coverage: none
37+
ini-values: post_max_size=256M, max_execution_time=180
38+
- name: Check package
39+
run: |
40+
sudo pear list
41+
sudo pear channel-update pear.php.net
42+
sudo pear upgrade --force pear/pear
43+
sudo pear list
44+
sudo pear install --force package.xml
45+
sudo pear list
46+
sudo pear package
47+
sudo pear package-validate
48+
sudo pear install --force *.tgz
49+
sudo pear list
50+
# For some reason ttf-mscorefonts-installer doesn't work
51+
# so we only install Verdana
52+
- name: Download and install Verdana font
53+
run: |
54+
sudo apt install cabextract
55+
curl -L -o verdan32.exe 'http://download.sourceforge.net/corefonts/verdan32.exe'
56+
cabextract -d Image/Canvas/Fonts/ verdan32.exe
57+
mv Image/Canvas/Fonts/Verdana.TTF Image/Canvas/Fonts/verdana.ttf
58+
- name: Install pre-requisites and run test scripts
59+
run: |
60+
composer install
61+
php tests/gradients.php > gradients.png
62+
php tests/imagemap.php > imagemap.html
63+
php tests/png.php
64+
php tests/jpg.php
65+
# php tests/ps.php
66+
# php tests/pdf.php
67+
php tests/svg.php
68+
php tests/text.php > text.png
69+
php tests/lineends.php > lineends.png

composer.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
},
2424
"type": "library",
2525
"require": {
26+
"php": ">=5.6, < 8.0",
2627
"pear/pear_exception": "*",
2728
"pear/image_color": "*"
28-
},
29-
"require-dev": {
30-
"phpunit/phpunit": "*"
3129
}
3230
}

tests/canvas_body.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,11 @@
305305

306306
$canvas->addText(array('x' => 375, 'y' => 455, 'text' => 'Image'));
307307

308-
$canvas->image(array('x' => 445, 'y' => 455, 'filename' => './pear-icon.png', 'url' => 'http://pear.veggerby.dk/', 'target' => '_blank'));
308+
$canvas->image(array('x' => 445, 'y' => 455, 'filename' => __DIR__ . '/pear-icon.png', 'url' => 'http://pear.veggerby.dk/', 'target' => '_blank'));
309309

310-
$canvas->image(array('x' => 445, 'y' => 495, 'filename' => './pear-icon.png', 'width' => 20, 'height' => 20));
310+
$canvas->image(array('x' => 445, 'y' => 495, 'filename' => __DIR__ . '/pear-icon.png', 'width' => 20, 'height' => 20));
311311

312-
$canvas->image(array('x' => 445, 'y' => 523, 'filename' => './pear-icon.png', 'width' => 40, 'height' => 40));
312+
$canvas->image(array('x' => 445, 'y' => 523, 'filename' => __DIR__ . '/pear-icon.png', 'width' => 40, 'height' => 40));
313313

314314
//$canvas->show();
315315
$type = basename($_SERVER['SCRIPT_NAME'], '.php');

tests/gradients.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* @link http://pear.php.net/package/Image_Canvas
2828
*/
2929

30-
require_once 'Image/Canvas.php';
30+
require_once 'vendor/autoload.php';
3131

3232
$canvas =& Image_Canvas::factory(
3333
'png',

tests/imagemap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* @link http://pear.php.net/package/Image_Canvas
2828
*/
2929

30-
require_once 'Image/Canvas.php';
30+
require_once 'vendor/autoload.php';
3131

3232
$canvas =& Image_Canvas::factory(
3333
'png',

tests/jpg.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
3131
$testFont = 'c:/windows/fonts/Arial.ttf';
3232

33-
require_once 'Image/Canvas.php';
33+
require_once 'vendor/autoload.php';
3434

3535
$canvas =& Image_Canvas::factory('jpg', array('width' => 600, 'height' => 600, 'quality' => 90));
3636

37-
require_once './canvas_body.php';
37+
require_once __DIR__ . '/canvas_body.php';
3838

3939
?>

tests/lineends.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* @link http://pear.php.net/package/Image_Canvas
2828
*/
2929

30-
require_once 'Image/Canvas.php';
30+
require_once 'vendor/autoload.php';
3131

3232
$font = array('name' => 'Verdana', 'size' => 10);
3333

tests/pdf.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
3131
$testFont = 'c:/windows/fonts/Arial.ttf';
3232

33-
require_once 'Image/Canvas.php';
33+
require_once 'vendor/autoload.php';
3434

3535
$canvas =& Image_Canvas::factory('pdf', array('page' => 'A4', 'align' => 'center', 'width' => 600, 'height' => 600));
3636

37-
require_once './canvas_body.php';
37+
require_once __DIR__ . '/canvas_body.php';
3838

3939
?>

tests/png.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
3131
$testFont = 'c:/windows/fonts/Arial.ttf';
3232

33-
require_once 'Image/Canvas.php';
33+
require_once 'vendor/autoload.php';
3434

3535
$canvas =& Image_Canvas::factory('png', array('width' => 600, 'height' => 600));
3636

37-
require_once './canvas_body.php';
37+
require_once __DIR__ . '/canvas_body.php';
3838

3939
?>

tests/ps.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
3131
$testFont = 'c:/windows/fonts/Arial.ttf';
3232

33-
require_once 'Image/Canvas.php';
33+
require_once 'vendor/autoload.php';
3434

3535
$canvas =& Image_Canvas::factory('ps', array('page' => 'A4', 'align' => 'center', 'width' => 600, 'height' => 600, 'filename'=>'testps.ps'));
3636

37-
require_once './canvas_body.php';
37+
require_once __DIR__ . '/canvas_body.php';
3838

3939
?>

tests/svg.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
3131
$testFont = 'c:/windows/fonts/Arial.ttf';
3232

33-
require_once 'Image/Canvas.php';
33+
require_once 'vendor/autoload.php';
3434

3535
$canvas =& Image_Canvas::factory('svg', array('width' => 600, 'height' => 600));
3636

37-
require_once './canvas_body.php';
37+
require_once __DIR__ . '/canvas_body.php';
3838

3939
?>

tests/text.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* @link http://pear.php.net/package/Image_Canvas
2828
*/
2929

30-
require_once 'Image/Canvas.php';
30+
require_once 'vendor/autoload.php';
3131

3232
$canvas =& Image_Canvas::factory(
3333
'png',

0 commit comments

Comments
 (0)