Skip to content

Commit

Permalink
Test against PHP 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Nov 16, 2024
1 parent 0288676 commit 736c99f
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.1"
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.composer/cache
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ jobs:
- "7.2"
- "7.3"
- "7.4"
- "8.4"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -26,7 +27,7 @@ jobs:
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.composer/cache
Expand All @@ -39,6 +40,8 @@ jobs:

- name: Run PHPUnit
run: make test-coveralls
env:
PHPUNIT_VERSION: "${{ matrix.php-version == '8.4' && '11' || '07' }}"

- name: Upload code coverage
if: ${{ matrix.php-version == '7.1' }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.phpunit.result.cache
build
composer.lock
vendor
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# CHANGELOG

## 1.x to 2.0

### New requirements

- PHP 7.1+

### New features

None

### Backward Incompatible Changes

None

### Deprecated Features

None

### Other Changes

None
34 changes: 21 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
FROM php:7.1-cli-buster
ARG PHP_TAG=7.1-cli-buster
FROM php:${PHP_TAG}

RUN docker-php-ext-enable opcache && \
docker-php-source delete
RUN <<-EOF
docker-php-ext-enable opcache
EOF

RUN echo '\
display_errors=On\n\
error_reporting=E_ALL\n\
date.timezone=UTC\n\
' >> /usr/local/etc/php/conf.d/php.ini
RUN <<-EOF
cat <<-SHELL >> /usr/local/etc/php/conf.d/php.ini
display_errors=On
error_reporting=E_ALL
date.timezone=UTC
SHELL
EOF

ENV COMPOSER_ALLOW_SUPERUSER 1

RUN apt-get update && \
apt-get install unzip && \
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet && \
mv composer.phar /usr/local/bin/composer && \
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"\n' >> /root/.bashrc
RUN <<-EOF
apt-get update
apt-get install unzip
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet
mv composer.phar /usr/local/bin/composer
cat <<-SHELL >> /root/.bashrc
export PATH="$HOME/.composer/vendor/bin:$PATH"
SHELL
EOF

RUN composer global require squizlabs/php_codesniffer
25 changes: 16 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# customization

PACKAGE_NAME = icanboogie/inflector
PHPUNIT = vendor/bin/phpunit
PHPUNIT = vendor/bin/phpunit --configuration=phpunit$(PHPUNIT_VERSION).xml

# do not edit the following lines

Expand All @@ -13,24 +12,32 @@ test-dependencies: vendor

.PHONY: test
test: test-dependencies
@$(PHPUNIT)
@XDEBUG_MODE=none $(PHPUNIT)

.PHONY: test-coverage
test-coverage: test-dependencies
@mkdir -p build/coverage
@$(PHPUNIT) --coverage-html build/coverage
@XDEBUG_MODE=coverage $(PHPUNIT) --coverage-html build/coverage

.PHONY: test-coveralls
test-coveralls: test-dependencies
@mkdir -p build/logs
@$(PHPUNIT) --coverage-clover build/logs/clover.xml
@XDEBUG_MODE=coverage $(PHPUNIT) --coverage-clover build/logs/clover.xml

.PHONY: test-container
test-container:
@docker-compose run --rm app bash
test-container: test-container-71

.PHONY: test-container-71
test-container-71:
@-docker-compose run --rm app71 bash
@docker-compose down -v

.PHONY: test-container-84
test-container-84:
@-docker-compose run --rm app84 bash
@docker-compose down -v

.PHONY: lint
lint:
@phpcs
@vendor/bin/phpstan
@XDEBUG_MODE=off phpcs -s
@XDEBUG_MODE=off vendor/bin/phpstan
7 changes: 0 additions & 7 deletions UPGRADING.md

This file was deleted.

6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"ext-mbstring": "*"
},
"require-dev": {
"icanboogie/common": "^2.0",
"phpstan/phpstan": "^0.12.92",
"phpunit/phpunit": "^7.5"
"icanboogie/common": "^2.1",
"phpstan/phpstan": "^0.12.100|^2.0",
"phpunit/phpunit": "^7.5.20|^11.4"
},
"conflict": {
"icanboogie/common": "<2.0"
Expand Down
21 changes: 17 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
---
version: "3.2"
services:
app:
build: .
app71:
build:
context: .
args:
PHP_TAG: "7.1-cli-buster"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-inflector'
volumes:
PHPUNIT_VERSION: "07"
volumes: &vol
- .:/app:delegated
- ~/.composer:/root/.composer:delegated
working_dir: /app
app84:
build:
context: .
args:
PHP_TAG: "8.4.0RC4-cli-bookworm"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-inflector'
PHPUNIT_VERSION: "11"
volumes: *vol
working_dir: /app
1 change: 0 additions & 1 deletion lib/InflectionsNotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@

class InflectionsNotFound extends LogicException
{

}
4 changes: 2 additions & 2 deletions lib/Inflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* The Inflector transforms words from singular to plural, class names to table names, modularized
* class names to ones without, and class names to foreign keys. Inflections can be localized, the
* default english inflections for pluralization, singularization, and uncountable words are
* default English inflections for pluralization, singularization, and uncountable words are
* kept in `lib/Inflections/en.php`.
*
* @property-read Inflections $inflections Inflections used by the inflector.
Expand Down Expand Up @@ -67,7 +67,7 @@ public static function get(string $locale = self::DEFAULT_LOCALE): self
*/
private $inflections;

public function __construct(Inflections $inflections = null)
public function __construct(?Inflections $inflections = null)
{
$this->inflections = $inflections ?? new Inflections();
}
Expand Down
3 changes: 2 additions & 1 deletion phpunit.xml → phpunit07.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
executionOrder="depends,defects"
beStrictAboutOutputDuringTests="true"
verbose="true"
colors="true">
colors="true"
>
<testsuites>
<testsuite name="icanboogie/inflector">
<directory>./tests</directory>
Expand Down
24 changes: 24 additions & 0 deletions phpunit11.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
bootstrap="tests/bootstrap.php"
colors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnPhpunitDeprecations="true"
executionOrder="depends,defects"
>
<testsuites>
<testsuite name="icanboogie/inflector">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>lib</directory>
</include>
</source>
</phpunit>
6 changes: 5 additions & 1 deletion tests/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,29 @@

namespace Tests\ICanBoogie;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;

use function ICanBoogie\capitalize;

/**
* @group helpers
*/
#[Group('helpers')]
final class HelpersTest extends TestCase
{
/**
* @dataProvider provide_test_capitalize
*/
#[DataProvider('provide_test_capitalize')]
public function test_capitalize(string $str, bool $preserve_str_end, string $expected): void
{
$this->assertSame($expected, capitalize($str, $preserve_str_end));
}

// @phpstan-ignore-next-line
public function provide_test_capitalize(): array
public static function provide_test_capitalize(): array
{
return [

Expand Down
7 changes: 6 additions & 1 deletion tests/InflectionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

use ICanBoogie\Inflections;
use ICanBoogie\InflectionsNotFound;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;

use function ICanBoogie\pluralize;
Expand All @@ -21,6 +23,7 @@
/**
* @group integration
*/
#[Group('integration')]
final class InflectionsTest extends TestCase
{
public function test_fail_on_undefined_inflections(): void
Expand All @@ -33,6 +36,7 @@ public function test_fail_on_undefined_inflections(): void
/**
* @dataProvider provide_singular_and_plural
*/
#[DataProvider('provide_singular_and_plural')]
public function test_singular_to_plural(string $locale, string $singular, string $plural): void
{
$this->assertEquals($plural, pluralize($singular, $locale));
Expand All @@ -41,13 +45,14 @@ public function test_singular_to_plural(string $locale, string $singular, string
/**
* @dataProvider provide_singular_and_plural
*/
#[DataProvider('provide_singular_and_plural')]
public function test_plural_to_singular(string $locale, string $singular, string $plural): void
{
$this->assertEquals($singular, singularize($plural, $locale));
}

// @phpstan-ignore-next-line
public function provide_singular_and_plural(): array
public static function provide_singular_and_plural(): array
{
$locales = explode(' ', 'en es fr nb pt tr');
$rc = [];
Expand Down

0 comments on commit 736c99f

Please sign in to comment.