Skip to content

Commit

Permalink
Added support PHP 8.3|8.4 (#83)
Browse files Browse the repository at this point in the history
* Added support php 8.3|8.4
  • Loading branch information
pvsaintpe authored May 2, 2024
1 parent dca1965 commit 8f07516
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 237 deletions.
76 changes: 24 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ on:

env:
COVERAGE: '1'
php_extensions: 'apcu, bcmath, ctype, curl, dom, iconv, intl, json, mbstring, opcache, openssl, pdo, pdo_pgsql, pcntl, pcov, posix, redis, session, simplexml, sockets, tokenizer, xml, xmlwriter, zip'
php_extensions: 'apcu, bcmath, ctype, curl, dom, iconv, intl, json, mbstring, opcache, openssl, pdo, pdo_pgsql, pcntl, pcov, posix, redis, session, simplexml, sockets, tokenizer, xml, xmlwriter, zip, xdebug'
key: cache-v0.1
DB_USER: 'postgres'
DB_NAME: 'testing'
DB_NAME: 'postgres'
DB_PASSWORD: 'postgres'
DB_HOST: '127.0.0.1'

Expand All @@ -26,14 +26,17 @@ jobs:
timeout-minutes: 20
strategy:
matrix:
operating_system:
- ubuntu-latest
php_versions:
- '7.4'
operating_system: [ubuntu-latest]
experimental: [false]
php_versions: ['8.3']
include:
- operating_system: 'ubuntu-latest'
php_versions: '8.4'
experimental: true
fail-fast: false
env:
PHP_CS_FIXER_FUTURE_MODE: '0'
name: 'Lint PHP'
name: 'Linter / PHP ${{ matrix.php_versions }} '
steps:
- name: 'Checkout'
uses: actions/checkout@v2
Expand Down Expand Up @@ -63,58 +66,24 @@ jobs:
- name: 'Setup problem matchers for PHPUnit'
run: 'echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"'
- name: 'Install PHP dependencies with Composer'
continue-on-error: ${{ matrix.experimental }}
run: COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist --no-progress --no-suggest --optimize-autoloader
working-directory: './'
- name: 'Linting PHP source files'
continue-on-error: ${{ matrix.experimental }}
run: 'vendor/bin/ecs check --config=ecs.php .'
test:
strategy:
fail-fast: false
matrix:
experimental:
- false
operating_system:
- ubuntu-latest
postgres:
- '10'
- '11'
- '12'
php_versions:
- '7.3'
- '7.4'
- '8.0'
experimental: [false]
operating_system: [ubuntu-latest]
postgres: ['10', '11', '12', '13', '14', '15']
php_versions: ['8.3']
include:
- operating_system: ubuntu-latest
postgres: '9.6'
php_versions: '7.3'
experimental: false
- operating_system: ubuntu-latest
postgres: '9.6'
php_versions: '7.4'
experimental: false
- operating_system: ubuntu-latest
postgres: '10'
php_versions: '8.0'
experimental: true
- operating_system: ubuntu-latest
postgres: '11'
php_versions: '8.0'
experimental: true
- operating_system: ubuntu-latest
postgres: '12'
php_versions: '8.0'
experimental: true
- operating_system: ubuntu-latest
postgres: '13'
php_versions: '8.0'
experimental: true
- operating_system: ubuntu-latest
postgres: '14'
php_versions: '8.1'
experimental: true
- operating_system: ubuntu-latest
postgres: '15'
php_versions: '8.2'
postgres: '16'
php_versions: '8.4'
experimental: true
runs-on: '${{ matrix.operating_system }}'
services:
Expand Down Expand Up @@ -158,10 +127,11 @@ jobs:
with:
php-version: ${{ matrix.php_versions }}
extensions: ${{ env.php_extensions }}
ini-values: 'pcov.directory=src, date.timezone=UTC, upload_max_filesize=20M, post_max_size=20M, memory_limit=512M, short_open_tag=Off'
coverage: pcov
ini-values: 'date.timezone=UTC, upload_max_filesize=20M, post_max_size=20M, memory_limit=512M, short_open_tag=Off, xdebug.mode="develop,coverage"'
coverage: xdebug
tools: 'phpunit'
- name: 'Install PHP dependencies with Composer'
continue-on-error: ${{ matrix.experimental }}
run: COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist --no-progress --no-suggest --optimize-autoloader
working-directory: './'
- name: 'Run Unit Tests with PHPUnit'
Expand All @@ -172,9 +142,11 @@ jobs:
-e "s/\${DATABASE}/${{ env.DB_NAME }}/" \
-e "s/\${HOST}/${{ env.DB_HOST }}/" \
phpunit.xml.dist > phpunit.xml
./vendor/bin/phpunit -c phpunit.xml --migrate-configuration
./vendor/bin/phpunit \
--stderr \
--coverage-clover build/logs/clover.xml
--coverage-clover build/logs/clover.xml \
--coverage-text
working-directory: './'
- name: 'Upload coverage results to Coveralls'
if: ${{ !matrix.experimental }}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/vendor
/.idea
.ecs_cache
.phpunit.cache
phpunit.xml
/build/*
/build
.phpunit.result.cache
.DS_Store
composer.lock

12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
],
"license": "MIT",
"require": {
"php": "^7.3|^7.4|^8.0|^8.1|^8.2",
"laravel/framework": "^5.8|^6.20.26|^7.0|^8.40|^9.0|^10.0|^11.0",
"doctrine/dbal": "^2.9|^3.0",
"umbrellio/laravel-pg-extensions": "^5.0|^6.0",
"umbrellio/laravel-common-objects": "^2.3"
"php": "^8.3|^8.4",
"laravel/framework": "^11.0",
"doctrine/dbal": "^3.0",
"umbrellio/laravel-pg-extensions": "^7.0",
"umbrellio/laravel-common-objects": "*"
},
"require-dev": {
"umbrellio/code-style-php": "^1.0",
"orchestra/testbench": "^3.5|^6.0|^4.0|^7.0|^8.0|^9.0",
"orchestra/testbench": "^9.0",
"php-coveralls/php-coveralls": "^2.1",
"squizlabs/php_codesniffer": "^3.5"
},
Expand Down
3 changes: 2 additions & 1 deletion tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ sed -e "s/\${USERNAME}/postgres/" \
phpunit.xml.dist > phpunit.xml
COMPOSER_MEMORY_LIMIT=-1 composer update
composer lint
php -d pcov.directory='.' vendor/bin/phpunit --coverage-html build --coverage-text
php vendor/bin/phpunit -c phpunit.xml --migrate-configuration
php -d xdebug.mode=coverage -d memory_limit=-1 vendor/bin/phpunit --coverage-html build --coverage-text
60 changes: 26 additions & 34 deletions tests/functional/Collections/LTreeCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
namespace Umbrellio\LTree\tests\functional\Resources;

use Generator;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Umbrellio\LTree\Exceptions\LTreeUndefinedNodeException;
use Umbrellio\LTree\Interfaces\LTreeModelInterface;
use Umbrellio\LTree\tests\_data\Models\CategoryStub;
use Umbrellio\LTree\tests\LTreeBaseTestCase;

class LTreeCollectionTest extends LTreeBaseTestCase
{
/**
* @test
*/
#[Test]
public function collectionCanBeConvertedIntoTree()
{
$tree = $this
Expand All @@ -26,15 +26,13 @@ public function collectionCanBeConvertedIntoTree()
$this->assertSame($tree, $tree->getChildren()[0]->getParent());
}

/**
* @test
* @dataProvider provideNoConstencyTree
*/
public function loadMissingNodes(array $ids, array $expected): void
#[Test]
#[DataProvider('provideNoConstencyTree')]
public function loadMissingNodes(array $items, array $expected): void
{
$this->assertSame(
CategoryStub::query()
->whereKey($ids)
->whereKey($items)
->get()
->toTree()
->toCollection()
Expand All @@ -47,15 +45,13 @@ public function loadMissingNodes(array $ids, array $expected): void
);
}

/**
* @test
* @dataProvider providePartialConstencyTree
*/
public function withoutLoadMissingForPartialTree(array $ids, array $expected): void
#[Test]
#[DataProvider('providePartialConstencyTree')]
public function withoutLoadMissingForPartialTree(array $items, array $expected): void
{
$this->assertSame(
CategoryStub::query()
->whereKey($ids)
->whereKey($items)
->get()
->toTree(true, false)
->toCollection()
Expand All @@ -68,23 +64,21 @@ public function withoutLoadMissingForPartialTree(array $ids, array $expected): v
);
}

public function provideTreeWithoutLeaves(): Generator
public static function provideTreeWithoutLeaves(): Generator
{
yield 'without_leaves' => [
'ids' => [10, 7, 12],
'items' => [10, 7, 12],
'expected' => [1, 3, 6, 11],
];
}

/**
* @test
* @dataProvider provideTreeWithoutLeaves
*/
public function withoutLeaves(array $ids, array $expected): void
#[Test]
#[DataProvider('provideTreeWithoutLeaves')]
public function withoutLeaves(array $items, array $expected): void
{
$this->assertSame(
CategoryStub::query()
->whereKey($ids)
->whereKey($items)
->get()
->withLeaves(false)
->toTree()
Expand All @@ -98,25 +92,23 @@ public function withoutLeaves(array $ids, array $expected): void
);
}

public function provideNoConstency(): Generator
public static function provideNoConstency(): Generator
{
yield 'non_consistent_without_loading' => [
'ids' => [1, 6, 8],
'items' => [1, 6, 8],
'expected' => [1, 6, 8],
'loadMissing' => false,
];
}

/**
* @test
* @dataProvider provideNoConstency
*/
public function withoutLoadMissingNodes(array $ids, array $expected): void
#[Test]
#[DataProvider('provideNoConstency')]
public function withoutLoadMissingNodes(array $items, array $expected, bool $loadMissing): void
{
$this->expectException(LTreeUndefinedNodeException::class);
$this->assertSame(
CategoryStub::query()
->whereKey($ids)
->whereKey($items)
->get()
->toTree(true, false)
->toCollection()
Expand All @@ -129,18 +121,18 @@ public function withoutLoadMissingNodes(array $ids, array $expected): void
);
}

public function provideNoConstencyTree(): Generator
public static function provideNoConstencyTree(): Generator
{
yield 'non_consistent_with_loading' => [
'ids' => [7, 3, 12],
'items' => [7, 3, 12],
'expected' => [1, 3, 7, 11, 12],
];
yield 'consistent' => [
'items' => [1, 3, 7],
'expected' => [1, 3, 7],
];
}
public function providePartialConstencyTree(): Generator
public static function providePartialConstencyTree(): Generator
{
yield 'partial with single branch without single nodes' => [
'items' => [3, 6, 7, 8, 9, 10],
Expand Down
25 changes: 7 additions & 18 deletions tests/functional/Helpers/LTreeHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

namespace Umbrellio\LTree\tests\functional\Helpers;

use PHPUnit\Framework\Attributes\Test;
use Umbrellio\LTree\Interfaces\LTreeModelInterface;
use Umbrellio\LTree\tests\_data\Models\CategoryStub;
use Umbrellio\LTree\tests\LTreeBaseTestCase;

class LTreeHelperTest extends LTreeBaseTestCase
{
/**
* @test
*/
#[Test]
public function createViaServiceRoot(): void
{
$node = $this->createCategory([
Expand All @@ -25,9 +24,7 @@ public function createViaServiceRoot(): void
$this->assertSame('15', $node->getLtreePath(LTreeModelInterface::AS_STRING));
}

/**
* @test
*/
#[Test]
public function moveSubtrees(): void
{
$nodes = $this->getCategories();
Expand All @@ -44,9 +41,7 @@ public function moveSubtrees(): void
$this->assertSame(11, $root->getLtreeParentId());
}

/**
* @test
*/
#[Test]
public function proxyColumns(): void
{
$nodeMoscow = $this->findNodeByPath('1.3');
Expand All @@ -69,9 +64,7 @@ public function proxyColumns(): void
$this->assertNull($nodeMoscow->name);
}

/**
* @test
*/
#[Test]
public function deleteRoot(): void
{
$root = $this->getRoot();
Expand All @@ -81,9 +74,7 @@ public function deleteRoot(): void
$this->assertFalse($root::descendantsOf($root)->exists());
}

/**
* @test
*/
#[Test]
public function deleteSubtree(): void
{
$root = $this->getRoot();
Expand All @@ -94,9 +85,7 @@ public function deleteSubtree(): void
$this->assertSame(1, $root::descendantsOf($root)->count());
}

/**
* @test
*/
#[Test]
public function deleteViaServiceSubtree(): void
{
$root = $this->getRoot();
Expand Down
Loading

0 comments on commit 8f07516

Please sign in to comment.