Skip to content

Commit 0ad45c2

Browse files
authored
Merge pull request #8 from studservis/php-8.0
Php 8.0+
2 parents 66704de + 95f4275 commit 0ad45c2

File tree

11 files changed

+118
-28
lines changed

11 files changed

+118
-28
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on: push
4+
5+
jobs:
6+
php-tests:
7+
8+
strategy:
9+
matrix:
10+
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
11+
prefer: [ 'lowest', 'stable' ]
12+
13+
name: Test on PHP ${{ matrix.php }} with ${{ matrix.prefer }} composer prefer option
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout Code
18+
uses: actions/checkout@v4
19+
20+
- name: Install PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php }}
24+
25+
- name: Check PHP Version
26+
run: php -v
27+
28+
- name: Cache Composer packages
29+
id: composer-cache
30+
uses: actions/cache@v4
31+
with:
32+
path: vendor
33+
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.prefer }}-
34+
restore-keys: |
35+
${{ runner.os }}-php-${{ matrix.php }}-composer-${{ matrix.prefer }}-
36+
37+
- name: Install dependencies
38+
if: steps.composer-cache.outputs.cache-hit != 'true'
39+
run: composer update --prefer-${{ matrix.prefer }} --prefer-dist --no-progress
40+
41+
- name: Run tests
42+
run: vendor/bin/phpunit

.gitignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
/vendor
2-
composer.lock
1+
/.idea/
2+
3+
/.phpunit.result.cache
4+
/phpunit-coverage/
5+
6+
/composer.lock
7+
/vendor/

Dockerfile

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
FROM php:7.4-cli
2-
RUN apt-get update -yqq
3-
RUN apt-get install -yqq git libmcrypt-dev libpq-dev libcurl4-gnutls-dev libicu-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev
4-
# Install PHP extensions
5-
RUN docker-php-ext-install curl json opcache
6-
COPY ./ /var/www/html/
7-
WORKDIR /var/www/html/
1+
FROM php:8.1-cli
2+
3+
RUN apt-get update -y \
4+
&& apt-get install -y \
5+
zip
6+
7+
RUN pecl channel-update pecl.php.net \
8+
&& pecl install xdebug-3.1.6 \
9+
&& docker-php-ext-enable xdebug \
10+
&& echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
11+
12+
# trigger all errors in dev env
13+
RUN echo "error_reporting = E_ALL" >> $PHP_INI_DIR/php.ini
14+
15+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
16+
17+
WORKDIR /var/www/
818

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
install:
2+
docker build -t php-dreamkas .
3+
./bin/composer install
4+
5+
test:
6+
./bin/php vendor/bin/phpunit

bin/composer

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/env bash
2+
3+
test -t 1 && USE_TTY="--tty"
4+
5+
docker run --rm --interactive ${USE_TTY} \
6+
--init \
7+
--user `id -u`:`id -g` \
8+
--volume $PWD:/var/www \
9+
--volume $HOME/.composer:/tmp/.composer \
10+
--env COMPOSER_HOME=/tmp/.composer \
11+
php-dreamkas composer "$@"

bin/php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/env bash
2+
3+
test -t 1 && USE_TTY="--tty"
4+
5+
docker run --rm --interactive ${USE_TTY} \
6+
--init \
7+
--user `id -u`:`id -g` \
8+
--volume $PWD:/var/www \
9+
php-dreamkas php "$@"

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
"description": "Фискализация чека для Дримкас-Ф на php",
44
"type": "library",
55
"require": {
6-
"php": "~7.0",
6+
"php": "^7.0 || ^8.0",
77
"guzzlehttp/guzzle": "^7.8"
88
},
99
"require-dev": {
10-
"ext-json": "*",
1110
"phpunit/phpunit": "^9.6"
1211
},
1312
"license": "MIT",

phpunit.xml.dist

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage>
4-
<include>
5-
<directory suffix=".php">src</directory>
6-
</include>
7-
</coverage>
8-
<testsuites>
9-
<testsuite name="default">
10-
<directory>./tests</directory>
11-
</testsuite>
12-
</testsuites>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
stopOnFailure="false"
10+
>
11+
<coverage processUncoveredFiles="true">
12+
<include>
13+
<directory suffix=".php">src</directory>
14+
</include>
15+
<report>
16+
<html outputDirectory="phpunit-coverage"/>
17+
</report>
18+
</coverage>
19+
<testsuites>
20+
<testsuite name="default">
21+
<directory>./tests</directory>
22+
</testsuite>
23+
</testsuites>
1324
</phpunit>

src/Api.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use GuzzleHttp\Client;
66
use GuzzleHttp\ClientInterface;
7+
use GuzzleHttp\Utils;
78

89
/**
910
* Class Api
@@ -42,7 +43,7 @@ public function json(string $method, string $uri = '', array $options = [])
4243
{
4344

4445
$response = $this->request($method, $uri, $options);
45-
return \GuzzleHttp\json_decode($response->getBody(), true);
46+
return Utils::jsonDecode($response->getBody(), true);
4647
}
4748

4849
public function postReceipt(Receipt $receipt)
@@ -54,4 +55,4 @@ public function postReceipt(Receipt $receipt)
5455
'json' => $data,
5556
]);
5657
}
57-
}
58+
}

test.sh

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

0 commit comments

Comments
 (0)