Skip to content

Commit

Permalink
Merge branch 'new' into development
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/tests.yml
#	.gitlab-ci.yml
#	docker-compose.yml
  • Loading branch information
natanfelles committed Jan 8, 2024
2 parents 9984001 + 20bcee8 commit 76a349f
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 70 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes: 10

strategy:
Expand Down Expand Up @@ -45,10 +45,10 @@ jobs:

- name: PHPStan
run:
vendor/bin/phpstan analyse --xdebug -vvv
vendor/bin/phpstan analyse -vvv

- name: PHPUnit
run: vendor/bin/phpunit --verbose
run: vendor/bin/phpunit

- name: Upload coverage results to Coveralls
env:
Expand All @@ -59,14 +59,15 @@ jobs:
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=build/logs/clover.xml -v
tests-last:
runs-on: ubuntu-20.04
tests-latest:
runs-on: ubuntu-22.04
timeout-minutes: 10

strategy:
fail-fast: true

name: PHP 8.2 - Last
name: PHP Latest

steps:
- name: Checkout
Expand All @@ -75,7 +76,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: latest
tools: composer
coverage: xdebug

Expand All @@ -84,4 +85,4 @@ jobs:
composer update

- name: PHPUnit
run: vendor/bin/phpunit --verbose
run: vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build/
raw-tests/
vendor/
.php-cs-fixer.cache
.phpunit.cache
.phpunit.result.cache
composer.lock
composer.phar
Expand Down
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test:php:
- composer normalize --dry-run --indent-size=4 --indent-style=space
- vendor/bin/php-cs-fixer fix --diff --dry-run --verbose
- vendor/bin/phpmd src xml phpmd.xml
- vendor/bin/phpstan analyse --xdebug -vvv
- vendor/bin/phpstan analyse -vvv
- vendor/bin/phpunit --colors=never
- phpdoc
artifacts:
Expand All @@ -30,8 +30,8 @@ test:php:
- build/docs/
coverage: '/^\s*Lines:\s*\d+.\d+\%/'

test:php-last:
image: registry.gitlab.com/aplus-framework/images/base:3
test:php-latest:
image: registry.gitlab.com/aplus-framework/images/base:latest
stage: test
timeout: 10 minutes
cache:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
},
"require-dev": {
"ext-xdebug": "*",
"aplus/coding-standard": "^1.14",
"aplus/coding-standard": "^2.1",
"ergebnis/composer-normalize": "^2.25",
"jetbrains/phpstorm-attributes": "^1.0",
"phpmd/phpmd": "^2.13",
"phpstan/phpstan": "^1.5",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^10.5"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ services:
volumes:
- .:/package
tty: true
package-last:
image: registry.gitlab.com/aplus-framework/images/package:3
container_name: package-pagination-last
package-latest:
image: registry.gitlab.com/aplus-framework/images/package:latest
container_name: package-pagination-latest
working_dir: /package
volumes:
- .:/package
Expand Down
18 changes: 10 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false"
bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnError="false"
stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
bootstrap="vendor/autoload.php" colors="true" stopOnError="false" stopOnFailure="false"
stopOnIncomplete="false" stopOnSkipped="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory=".phpunit.cache">
<coverage>
<report>
<clover outputFile="build/coverage/clover.xml"/>
<html outputDirectory="build/coverage"/>
Expand All @@ -21,4 +18,9 @@
<php>
<env name="XDEBUG_MODE" value="coverage"/>
</php>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
12 changes: 6 additions & 6 deletions src/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function setLanguage(Language $language = null) : static
*/
public function getLanguage() : Language
{
if ( ! isset($this->language)) {
if (!isset($this->language)) {
$this->setLanguage();
}
return $this->language;
Expand All @@ -211,7 +211,7 @@ public function getLanguage() : Language
*/
public function setView(string $name, string $filepath) : static
{
if ( ! \is_file($filepath)) {
if (!\is_file($filepath)) {
throw new InvalidArgumentException('Invalid Pager view filepath: ' . $filepath);
}
$this->views[$name] = $filepath;
Expand Down Expand Up @@ -539,15 +539,15 @@ public function render(string $view = null) : string
public function renderShort() : string
{
$view = $this->getDefaultView();
if ( ! \str_ends_with($view, '-short')) {
if (!\str_ends_with($view, '-short')) {
$view .= '-short';
}
return $this->render($view);
}

public function setDefaultView(string $defaultView) : static
{
if ( ! \array_key_exists($defaultView, $this->views)) {
if (!\array_key_exists($defaultView, $this->views)) {
throw new LogicException(
'Default view "' . $defaultView . '" is not a valid value'
);
Expand Down Expand Up @@ -596,7 +596,7 @@ public static function sanitizePageNumber(int | string $number) : int
'Method ' . __METHOD__ . ' is deprecated',
\E_USER_DEPRECATED
);
$number = $number < 1 || ! \is_numeric($number) ? 1 : $number;
$number = $number < 1 || !\is_numeric($number) ? 1 : $number;
return $number > \PHP_INT_MAX ? \PHP_INT_MAX : (int) $number;
}

Expand All @@ -610,7 +610,7 @@ public static function sanitizePageNumber(int | string $number) : int
#[Pure]
public static function sanitize(mixed $number) : int
{
if ( ! \is_numeric($number)) {
if (!\is_numeric($number)) {
return 1;
}
if ($number < 1) {
Expand Down
80 changes: 40 additions & 40 deletions tests/PagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,24 +304,6 @@ public function testJsonSerializable() : void
);
}

/**
* @return array<array<string>>
*/
public function viewsProvider() : array
{
return [
['pagination'],
['bootstrap'],
['bulma'],
['foundation'],
['materialize'],
['primer'],
['semantic-ui'],
['tailwind'],
['w3'],
];
}

/**
* @dataProvider viewsProvider
*
Expand All @@ -337,17 +319,6 @@ public function testPaginationViews(string $view) : void
self::assertStringContainsString('Last', $contents);
}

/**
* @return array<array<string>>
*/
public function previousDisabledProvider() : array
{
return [
['primer', 'aria-disabled="true"'],
['primer-short', 'aria-disabled="true"'],
];
}

/**
* @dataProvider previousDisabledProvider
*
Expand All @@ -363,17 +334,6 @@ public function testPreviousIsDisabled(string $view, string $needle) : void
self::assertStringContainsString($needle, $contents);
}

/**
* @return array<array<string>>
*/
public function nextDisabledProvider() : array
{
return [
['primer', 'aria-disabled="true"'],
['primer-short', 'aria-disabled="true"'],
];
}

/**
* @dataProvider nextDisabledProvider
*
Expand Down Expand Up @@ -420,4 +380,44 @@ public function testSanitize() : void
self::assertSame(\PHP_INT_MAX, Pager::sanitize(\PHP_INT_MAX . '123'));
self::assertSame(\PHP_INT_MAX - 1, Pager::sanitize(\PHP_INT_MAX - 1));
}

/**
* @return array<array<string>>
*/
public static function viewsProvider() : array
{
return [
['pagination'],
['bootstrap'],
['bulma'],
['foundation'],
['materialize'],
['primer'],
['semantic-ui'],
['tailwind'],
['w3'],
];
}

/**
* @return array<array<string>>
*/
public static function previousDisabledProvider() : array
{
return [
['primer', 'aria-disabled="true"'],
['primer-short', 'aria-disabled="true"'],
];
}

/**
* @return array<array<string>>
*/
public static function nextDisabledProvider() : array
{
return [
['primer', 'aria-disabled="true"'],
['primer-short', 'aria-disabled="true"'],
];
}
}

0 comments on commit 76a349f

Please sign in to comment.