Skip to content

Commit

Permalink
Merge pull request #6 from duboism/test_and_github_actions
Browse files Browse the repository at this point in the history
Add tests and GitHub actions
  • Loading branch information
ashnazg authored Nov 24, 2024
2 parents 9e0b080 + e13aa67 commit 06cbacd
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 20 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Main

on:
workflow_dispatch:
push:
branches:
- main
- master
- release/**
pull_request:
branches:
- main
- master
- release/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-latest']
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
steps:
- name: Get source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
ini-values: post_max_size=256M, max_execution_time=180
- name: Check package
run: |
sudo pear list
sudo pear channel-update pear.php.net
sudo pear upgrade --force pear/pear
sudo pear list
sudo pear install --force package.xml
sudo pear list
sudo pear package
sudo pear package-validate
sudo pear install --force *.tgz
sudo pear list
# For some reason ttf-mscorefonts-installer doesn't work
# so we only install Verdana
- name: Download and install Verdana font
run: |
sudo apt install cabextract
curl -L -o verdan32.exe 'http://download.sourceforge.net/corefonts/verdan32.exe'
cabextract -d Image/Canvas/Fonts/ verdan32.exe
mv Image/Canvas/Fonts/Verdana.TTF Image/Canvas/Fonts/verdana.ttf
- name: Install pre-requisites and run test scripts
run: |
composer install
php tests/gradients.php > gradients.png
php tests/imagemap.php > imagemap.html
php tests/png.php
php tests/jpg.php
# php tests/ps.php
# php tests/pdf.php
php tests/svg.php
php tests/text.php > text.png
php tests/lineends.php > lineends.png
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
},
"type": "library",
"require": {
"php": ">=5.6, < 8.0",
"pear/pear_exception": "*",
"pear/image_color": "*"
},
"require-dev": {
"phpunit/phpunit": "*"
}
}
6 changes: 3 additions & 3 deletions tests/canvas_body.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,11 @@

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

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

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

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

//$canvas->show();
$type = basename($_SERVER['SCRIPT_NAME'], '.php');
Expand Down
2 changes: 1 addition & 1 deletion tests/gradients.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @link http://pear.php.net/package/Image_Canvas
*/

require_once 'Image/Canvas.php';
require_once 'vendor/autoload.php';

$canvas =& Image_Canvas::factory(
'png',
Expand Down
2 changes: 1 addition & 1 deletion tests/imagemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @link http://pear.php.net/package/Image_Canvas
*/

require_once 'Image/Canvas.php';
require_once 'vendor/autoload.php';

$canvas =& Image_Canvas::factory(
'png',
Expand Down
4 changes: 2 additions & 2 deletions tests/jpg.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
$testFont = 'c:/windows/fonts/Arial.ttf';

require_once 'Image/Canvas.php';
require_once 'vendor/autoload.php';

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

require_once './canvas_body.php';
require_once __DIR__ . '/canvas_body.php';

?>
2 changes: 1 addition & 1 deletion tests/lineends.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @link http://pear.php.net/package/Image_Canvas
*/

require_once 'Image/Canvas.php';
require_once 'vendor/autoload.php';

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

Expand Down
4 changes: 2 additions & 2 deletions tests/pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
$testFont = 'c:/windows/fonts/Arial.ttf';

require_once 'Image/Canvas.php';
require_once 'vendor/autoload.php';

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

require_once './canvas_body.php';
require_once __DIR__ . '/canvas_body.php';

?>
4 changes: 2 additions & 2 deletions tests/png.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
$testFont = 'c:/windows/fonts/Arial.ttf';

require_once 'Image/Canvas.php';
require_once 'vendor/autoload.php';

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

require_once './canvas_body.php';
require_once __DIR__ . '/canvas_body.php';

?>
4 changes: 2 additions & 2 deletions tests/ps.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
$testFont = 'c:/windows/fonts/Arial.ttf';

require_once 'Image/Canvas.php';
require_once 'vendor/autoload.php';

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

require_once './canvas_body.php';
require_once __DIR__ . '/canvas_body.php';

?>
4 changes: 2 additions & 2 deletions tests/svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
$testFont = 'c:/windows/fonts/Arial.ttf';

require_once 'Image/Canvas.php';
require_once 'vendor/autoload.php';

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

require_once './canvas_body.php';
require_once __DIR__ . '/canvas_body.php';

?>
2 changes: 1 addition & 1 deletion tests/text.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @link http://pear.php.net/package/Image_Canvas
*/

require_once 'Image/Canvas.php';
require_once 'vendor/autoload.php';

$canvas =& Image_Canvas::factory(
'png',
Expand Down

0 comments on commit 06cbacd

Please sign in to comment.