Skip to content

Commit 0895fc6

Browse files
authored
Merge pull request #4 from Larium/php7
Migrate to php7
2 parents cb61bad + 4a1ef09 commit 0895fc6

File tree

13 files changed

+111
-57
lines changed

13 files changed

+111
-57
lines changed

.docker/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM php:7.4-cli
2+
WORKDIR "/opt/php"
3+
4+
ENV DEBIAN_FRONTEND noninteractive
5+
6+
RUN apt-get update && \
7+
pecl channel-update pecl.php.net && \
8+
pecl install xdebug && \
9+
docker-php-source delete && \
10+
rm -r /tmp/* /var/cache/*
11+
12+
COPY ./.docker/php-ini-overrides.ini /usr/local/etc/php/conf.d/99-overrides.ini

.docker/php-ini-overrides.ini

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
2+
error_log = /dev/stderr
3+
log_errors = On
4+
display_startup_errors = Off
5+
date.timezone = UTC
6+
upload_max_filesize = 8M
7+
post_max_size = 8M
8+
html_errors = Off
9+
memory_limit = 512M
10+
max_execution_time = 60
11+
expose_php = Off
12+
zend_extension=xdebug.so
13+
xdebug.mode=coverage

.github/workflows/php.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: PHPUnit tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: '7.4'
19+
coverage: xdebug
20+
- name: Checkout code
21+
uses: actions/checkout@v2
22+
23+
- name: Validate composer.json and composer.lock
24+
run: composer validate --strict
25+
26+
- name: Cache Composer packages
27+
id: composer-cache
28+
uses: actions/cache@v2
29+
with:
30+
path: vendor
31+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-php-
34+
35+
- name: Install dependencies
36+
run: composer install --prefer-dist --no-progress
37+
38+
- name: Run test suite
39+
run: composer run-script tests

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
composer.lock
2-
vendor
3-
build
2+
/vendor
3+
/build
4+
.phpunit.result.cache

.scrutinizer.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ checks:
55
code_rating: true
66
duplication: true
77
tools:
8-
external_code_coverage:
9-
timeout: 630
108
php_code_sniffer:
119
config:
1210
standard: "PSR2"
11+
build:
12+
environment:
13+
php:
14+
version: 7.4
15+
tests:
16+
override:
17+
-
18+
command: './vendor/bin/phpunit --configuration code-coverage.xml tests/'

.travis.yml

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

code-coverage.xml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
32
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
4-
<phpunit
5-
backupGlobals = "false"
6-
backupStaticAttributes = "false"
7-
colors = "true"
8-
verbose = "true"
9-
convertErrorsToExceptions = "true"
10-
convertNoticesToExceptions = "true"
11-
convertWarningsToExceptions = "true"
12-
processIsolation = "false"
13-
stopOnFailure = "false"
14-
bootstrap = "vendor/autoload.php">
15-
<filter>
16-
<whitelist>
17-
<directory suffix=".php">src/</directory>
18-
</whitelist>
19-
</filter>
20-
<logging>
21-
<log type="tap" target="build/report.tap"/>
22-
<log type="junit" target="build/report.junit.xml"/>
23-
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
24-
<log type="coverage-text" target="build/coverage.txt"/>
25-
<log type="coverage-clover" target="build/logs/clover.xml"/>
26-
</logging>
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
4+
<coverage>
5+
<include>
6+
<directory suffix=".php">src/</directory>
7+
</include>
8+
<report>
9+
<clover outputFile="build/logs/clover.xml"/>
10+
<html outputDirectory="build/coverage"/>
11+
<text outputFile="build/coverage.txt"/>
12+
</report>
13+
</coverage>
14+
<logging>
15+
<junit outputFile="build/report.junit.xml"/>
16+
</logging>
2717
</phpunit>

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=5.3.3"
14+
"php": ">=7.4"
1515
},
1616
"minimum-stability": "stable",
1717
"autoload": {
@@ -25,6 +25,11 @@
2525
}
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "^4.0"
28+
"phpunit/phpunit": "^9.0"
29+
},
30+
"scripts": {
31+
"docker-build": "docker build -f .docker/Dockerfile -t larium-creditcard .",
32+
"docker-tests": "docker run -v $(pwd):/opt/php larium-creditcard sh -c './vendor/bin/phpunit --configuration code-coverage.xml tests/'",
33+
"tests": "./vendor/bin/phpunit --configuration code-coverage.xml tests/"
2934
}
3035
}

tests/CreditCard/CreditCardDetectorTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace Larium\CreditCard;
44

5-
class CreditCardDetectorTest extends \PHPUnit_Framework_TestCase
5+
use PHPUnit\Framework\TestCase;
6+
7+
class CreditCardDetectorTest extends TestCase
68
{
79
/**
810
* @dataProvider creditCardsProvider

tests/CreditCard/CreditCardTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace Larium\CreditCard;
1313

14-
class CreditCardTest extends \PHPUnit_Framework_TestCase
14+
use PHPUnit\Framework\TestCase;
15+
16+
class CreditCardTest extends TestCase
1517
{
1618
public function testCreditCardInstance()
1719
{
@@ -91,7 +93,7 @@ public function testSettingToken()
9193

9294
$card = $card->withToken(new Token('0123456789'));
9395

94-
$this->assertRegExp('/XXXX-XXXX-XXXX-\d{4}/', $card->getNumber());
96+
$this->assertMatchesRegularExpression('/XXXX-XXXX-XXXX-\d{4}/', $card->getNumber());
9597
}
9698

9799
public function testExpiryDateImmutability()

0 commit comments

Comments
 (0)