Skip to content

Commit

Permalink
Merge pull request #4 from Larium/php7
Browse files Browse the repository at this point in the history
Migrate to php7
  • Loading branch information
akDeveloper authored Aug 23, 2021
2 parents cb61bad + 4a1ef09 commit 0895fc6
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 57 deletions.
12 changes: 12 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM php:7.4-cli
WORKDIR "/opt/php"

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && \
pecl channel-update pecl.php.net && \
pecl install xdebug && \
docker-php-source delete && \
rm -r /tmp/* /var/cache/*

COPY ./.docker/php-ini-overrides.ini /usr/local/etc/php/conf.d/99-overrides.ini
13 changes: 13 additions & 0 deletions .docker/php-ini-overrides.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
error_log = /dev/stderr
log_errors = On
display_startup_errors = Off
date.timezone = UTC
upload_max_filesize = 8M
post_max_size = 8M
html_errors = Off
memory_limit = 512M
max_execution_time = 60
expose_php = Off
zend_extension=xdebug.so
xdebug.mode=coverage
39 changes: 39 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PHPUnit tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: xdebug
- name: Checkout code
uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run-script tests
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
composer.lock
vendor
build
/vendor
/build
.phpunit.result.cache
10 changes: 8 additions & 2 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ checks:
code_rating: true
duplication: true
tools:
external_code_coverage:
timeout: 630
php_code_sniffer:
config:
standard: "PSR2"
build:
environment:
php:
version: 7.4
tests:
override:
-
command: './vendor/bin/phpunit --configuration code-coverage.xml tests/'
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

38 changes: 14 additions & 24 deletions code-coverage.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
verbose = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
bootstrap = "vendor/autoload.php">
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<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">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
</phpunit>
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": ">=5.3.3"
"php": ">=7.4"
},
"minimum-stability": "stable",
"autoload": {
Expand All @@ -25,6 +25,11 @@
}
},
"require-dev": {
"phpunit/phpunit": "^4.0"
"phpunit/phpunit": "^9.0"
},
"scripts": {
"docker-build": "docker build -f .docker/Dockerfile -t larium-creditcard .",
"docker-tests": "docker run -v $(pwd):/opt/php larium-creditcard sh -c './vendor/bin/phpunit --configuration code-coverage.xml tests/'",
"tests": "./vendor/bin/phpunit --configuration code-coverage.xml tests/"
}
}
4 changes: 3 additions & 1 deletion tests/CreditCard/CreditCardDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Larium\CreditCard;

class CreditCardDetectorTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class CreditCardDetectorTest extends TestCase
{
/**
* @dataProvider creditCardsProvider
Expand Down
6 changes: 4 additions & 2 deletions tests/CreditCard/CreditCardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

namespace Larium\CreditCard;

class CreditCardTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class CreditCardTest extends TestCase
{
public function testCreditCardInstance()
{
Expand Down Expand Up @@ -91,7 +93,7 @@ public function testSettingToken()

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

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

public function testExpiryDateImmutability()
Expand Down
8 changes: 4 additions & 4 deletions tests/CreditCard/CreditCardValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

namespace Larium\CreditCard;

class CreditCardValidatorTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class CreditCardValidatorTest extends TestCase
{
/**
* @dataProvider cardOptionsProvider
Expand Down Expand Up @@ -50,11 +52,9 @@ public function testValidatorContext()
$this->assertEmpty($errors);
}

/**
* @expectedException RuntimeException
*/
public function testInvalidValidatorContext()
{
$this->expectException(\RuntimeException::class);
$validator = new CreditCardValidator();

$validator->setContext('wrong');
Expand Down
3 changes: 2 additions & 1 deletion tests/CreditCard/ExpiryDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
namespace Larium\CreditCard;

use DateTime;
use PHPUnit\Framework\TestCase;

class ExpiryDateTest extends \PHPUnit_Framework_TestCase
class ExpiryDateTest extends TestCase
{
public function testExpiryDateFormatters()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/CreditCard/TokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace Larium\CreditCard;

use DateTime;
use PHPUnit\Framework\TestCase;

class TokenTest extends \PHPUnit_Framework_TestCase
class TokenTest extends TestCase
{
public function testTokenInstance()
{
Expand Down

0 comments on commit 0895fc6

Please sign in to comment.