Skip to content

Commit e9c63ed

Browse files
committed
Enable Travis-CI. Fix tests for PHP >= 7.1
Install coverall for code coverage Added build badges
1 parent 3191f9f commit e9c63ed

20 files changed

+149
-16
lines changed

.travis.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
language: php
2+
3+
matrix:
4+
fast_finish: true
5+
include:
6+
- php: '7.1'
7+
- php: '7.2'
8+
- php: '7.3'
9+
- php: '7.4snapshot'
10+
11+
before_install:
12+
- phpenv config-rm xdebug.ini || echo "No xdebug config."
13+
14+
install:
15+
- composer update --prefer-dist --no-interaction
16+
17+
- mkdir -p coverage/cov coverage/bin
18+
- wget https://phar.phpunit.de/phpcov.phar -O coverage/bin/phpcov
19+
- chmod +x coverage/bin/phpcov
20+
21+
script:
22+
- phpdbg -qrr vendor/bin/phpunit --coverage-php coverage/cov/main.cov
23+
24+
- php examples/card_type.php
25+
- php examples/class_static_construct.php
26+
- php examples/day.php
27+
- php examples/flag.php
28+
- php examples/php-enum_comparision.php
29+
- php examples/planet.php
30+
- php examples/serialization_php74.php
31+
32+
after_script:
33+
- curl -OL https://github.com/php-coveralls/php-coveralls/releases/download/v1.0.0/coveralls.phar
34+
- chmod +x coveralls.phar
35+
- phpdbg -qrr coverage/bin/phpcov merge --clover build/logs/clover.xml coverage/cov
36+
- ./coveralls.phar

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# PHP Enumeration classes
2+
[![Build Status](https://travis-ci.org/dbalabka/php-enumeration.svg?branch=master)](https://travis-ci.org/dbalabka/php-enumeration)
3+
[![Coverage Status](https://coveralls.io/repos/github/dbalabka/php-enumeration/badge.svg)](https://coveralls.io/github/dbalabka/php-enumeration)
4+
25
Implementation of [Enumeration Classes](https://docs.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/enumeration-classes-over-enum-types) in PHP.
36

47
In contrast to [existing solutions](#existing-solutions), this implementation avoids usage of [Magic methods](https://www.php.net/manual/en/language.oop5.magic.php) and

build/php71/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM php:7.1-cli
2+
RUN pecl install xdebug

build/php72/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM php:7.2-cli
2+
RUN pecl install xdebug

build/php73/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM php:7.3-cli
2+
RUN pecl install xdebug
File renamed without changes.

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
"email": "dmitry.balabka@gmail.com"
1010
}
1111
],
12-
"repositories": [{"type": "vcs", "url": "https://github.com/dbalabka/construct-static.git"}],
1312
"require": {
1413
"php": ">=7.1"
1514
},
1615
"require-dev": {
1716
"vladimmi/construct-static": "dev-master",
1817
"myclabs/php-enum": "^1.0",
19-
"phpunit/phpunit": "^8.3",
18+
"phpunit/phpunit": "^7.5",
2019
"phpbench/phpbench": "^0.16.9"
2120
},
2221
"suggest": {

examples/day.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
use Dbalabka\Examples\Enum\Day;
55

66
if (version_compare(PHP_VERSION, '7.4.0', '<')) {
7-
throw new \Exception('This code requires PHP >= 7.4');
7+
trigger_error('This code requires PHP >= 7.4', E_USER_NOTICE);
8+
return;
89
}
910

1011
$composer = require_once(__DIR__ . '/../vendor/autoload.php');

examples/php-enum_comparision.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22
declare(strict_types=1);
33

4-
use Dbalabka\Enumeration;
5-
use Dbalabka\Examples\Enum\Color;
6-
use MyCLabs\Enum\Enum;
74
use Dbalabka\Examples\Enum\Action;
85

6+
if (version_compare(PHP_VERSION, '7.4.0', '<')) {
7+
trigger_error('This code requires PHP >= 7.4', E_USER_NOTICE);
8+
return;
9+
}
10+
911
$composer = require_once(__DIR__ . '/../vendor/autoload.php');
1012
$loader = new ConstructStatic\Loader($composer);
1113

examples/planet.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
use Dbalabka\Examples\Enum\Planet;
55

66
if (version_compare(PHP_VERSION, '7.4.0', '<')) {
7-
throw new \Exception('This code requires PHP >= 7.4');
7+
trigger_error('This code requires PHP >= 7.4', E_USER_NOTICE);
8+
return;
89
}
910

1011
$composer = require_once(__DIR__ . '/../vendor/autoload.php');

0 commit comments

Comments
 (0)