Skip to content

Commit

Permalink
Merge pull request #352 from TravisCarden/feature/php8
Browse files Browse the repository at this point in the history
Update tests to include PHP 8.3 on GitHub Actions
  • Loading branch information
TravisCarden committed Apr 5, 2024
2 parents 75223b5 + 0c2f785 commit 583c938
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 33 deletions.
48 changes: 35 additions & 13 deletions .github/workflows/main.yml
Expand Up @@ -41,34 +41,34 @@ jobs:
run: "composer static"

tests:
name: "Test: ${{ matrix.os }} / ${{ matrix.php }} / ${{ matrix.dependencies }}"
name: "Tests: ${{ matrix.os }} / ${{ matrix.php }} / ${{ matrix.dependencies }}${{ matrix.os == 'ubuntu' && matrix.dependencies == 'high' && matrix.php == '8.3' && ' w/ coverage' || '' }}"
runs-on: "${{ matrix.os }}-latest"
strategy:
fail-fast: false
matrix:
os: [ ubuntu, macos, windows ]
php: [ "8.1", "8.2" ]
dependencies: [ lowest, highest ]
php: [ "8.1", "8.2", "8.3" ]
dependencies: [ low, high ]
steps:
- name: "Install rsync"
uses: GuillaumeFalourd/setup-rsync@v1.2 # https://github.com/marketplace/actions/setup-rsync

- name: "Set up PHP w/ Coverage"
if: ${{ matrix.os == 'ubuntu' && matrix.dependencies == 'highest' }}
if: ${{ matrix.os == 'ubuntu' && matrix.dependencies == 'high' && matrix.php == '8.3' }}
uses: shivammathur/setup-php@v2 # https://github.com/marketplace/actions/setup-php-action
with:
php-version: "${{ matrix.php }}"
extensions: gd
ini-values: assert.active=1, assert.exception=1, zend.assertions=1
ini-values: zend.assertions=1

- name: "Set up PHP w/o Coverage"
if: ${{ !( matrix.os == 'ubuntu' && matrix.dependencies == 'highest' ) }}
if: ${{ !( matrix.os == 'ubuntu' && matrix.dependencies == 'high' && matrix.php == '8.3' ) }}
uses: shivammathur/setup-php@v2 # https://github.com/marketplace/actions/setup-php-action
with:
php-version: "${{ matrix.php }}"
coverage: none
extensions: gd
ini-values: assert.active=1, assert.exception=1, zend.assertions=1
ini-values: zend.assertions=1

- name: "Debugging info"
run: |
Expand All @@ -81,19 +81,19 @@ jobs:
- name: "Install dependencies"
uses: ramsey/composer-install@v3 # https://github.com/marketplace/actions/install-composer-dependencies
with:
dependency-versions: "${{ matrix.dependencies }}"
dependency-versions: "${{ matrix.dependencies }}est"

- name: "Run core tests with coverage"
run: "composer test"
if: ${{ matrix.os == 'ubuntu' && matrix.dependencies == 'highest' }}
if: ${{ matrix.os == 'ubuntu' && matrix.dependencies == 'high' && matrix.php == '8.3' }}

# There's no reason to generate coverage data on multiple jobs--the result should be the same.
- name: "Run core tests without coverage"
run: "./vendor/bin/phpunit --no-coverage --exclude-group=windows_only"
if: ${{ runner.os != 'Windows' && !( matrix.os == 'ubuntu' && matrix.dependencies == 'highest' ) }}
run: "./vendor/bin/phpunit --no-coverage --testsuite=all --exclude-group=windows_only"
if: ${{ runner.os != 'Windows' && !( matrix.os == 'ubuntu' && matrix.dependencies == 'high' && matrix.php == '8.3' ) }}

- name: "Run Windows tests"
run: "./vendor/bin/phpunit --no-coverage --exclude-group=no_windows"
run: "./vendor/bin/phpunit --no-coverage --testsuite=all --exclude-group=no_windows"
if: ${{ runner.os == 'Windows' }}

performance:
Expand Down Expand Up @@ -122,6 +122,28 @@ jobs:
- name: "Run performance tests"
run: "composer phpbench -- --progress=plain --ansi"

compatability:
name: "Compatability"
runs-on: ubuntu-latest
steps:
- name: "Install rsync"
uses: GuillaumeFalourd/setup-rsync@v1.2 # https://github.com/marketplace/actions/setup-rsync

- name: "Set up PHP"
uses: shivammathur/setup-php@v2 # https://github.com/marketplace/actions/setup-php-action
with:
php-version: "8.3"
coverage: none

- name: "Checkout code"
uses: actions/checkout@v4 # https://github.com/marketplace/actions/checkout

- name: "Install dependencies"
uses: ramsey/composer-install@v3 # https://github.com/marketplace/actions/install-composer-dependencies

- name: "Run compatability tests"
run: "composer compatability"

mutation:
name: "Mutation"
runs-on: ubuntu-latest
Expand All @@ -131,7 +153,7 @@ jobs:
with:
php-version: "8.2"
extensions: gd
ini-values: assert.active=1, assert.exception=1, zend.assertions=1
ini-values: zend.assertions=1

- name: "Checkout code"
uses: actions/checkout@v4 # https://github.com/marketplace/actions/checkout
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -91,7 +91,7 @@
"rm -r var/*/* &> /dev/null || true",
"git checkout -- var"
],
"compatability": "phpunit -- tests/Compatability",
"compatability": "phpunit --testsuite=compatability",
"dox": "phpunit --testdox --color=always --exclude-group=windows_only",
"fast": "phpunit --exclude-group=slow,windows_only",
"functional": "phpunit --testsuite=functional --exclude-group=windows_only",
Expand Down
1 change: 1 addition & 0 deletions grumphp.yml.dist
Expand Up @@ -25,6 +25,7 @@ grumphp:
phpstan:
use_grumphp_paths: false
phpunit:
testsuite: all
exclude_group:
- windows_only
rector: ~
Expand Down
2 changes: 1 addition & 1 deletion infection.json5.dist
Expand Up @@ -18,5 +18,5 @@
"IncrementInteger": false,
"RoundingFamily": false
},
"testFrameworkOptions": "--exclude-group=slow,windows_only"
"testFrameworkOptions": "--testsuite=all --exclude-group=slow,windows_only"
}
5 changes: 2 additions & 3 deletions phpunit.xml.dist
Expand Up @@ -16,7 +16,8 @@
>
<testsuites>
<testsuite name="all">
<directory>tests</directory>
<directory suffix="UnitTest.php">tests</directory>
<directory suffix="FunctionalTest.php">tests</directory>
</testsuite>
<testsuite name="unit">
<directory suffix="UnitTest.php">tests</directory>
Expand Down Expand Up @@ -45,8 +46,6 @@
</logging>

<php>
<ini name="assert.active" value="1"/>
<ini name="assert.exception" value="1"/>
<ini name="zend.assertions" value="1"/>
</php>
</phpunit>
Expand Up @@ -6,12 +6,8 @@
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Process;

/**
* @coversNothing
*
* @group slow
*/
final class CompatabilityFunctionalTest extends TestCase
/** @coversNothing */
final class CompatabilityTest extends TestCase
{
// @see https://github.com/php-tuf/composer-stager/wiki/Library-compatibility-policy#drupal
private const SUPPORTED_DRUPAL_VERSIONS = [
Expand All @@ -22,8 +18,7 @@ final class CompatabilityFunctionalTest extends TestCase
'10.1.0',
'10.1.2',
// Next minor dev.
// @todo Drupal 11.x now require PHP 8.3. Update the test setup for support.
//'11.x-dev',
'11.x-dev',
];

public static function setUpBeforeClass(): void
Expand Down
Expand Up @@ -7,7 +7,7 @@
use PhpTuf\ComposerStager\Tests\TestUtils\TranslationTestHelper;

/** @coversDefaultClass \PhpTuf\ComposerStager\Internal\Translation\Service\SymfonyTranslatorProxy */
final class SymfonyTranslatorProxyTest extends TestCase
final class SymfonyTranslatorProxyUnitTest extends TestCase
{
/**
* @covers ::getLocale
Expand Down
4 changes: 2 additions & 2 deletions tests/Translation/Service/TranslatorUnitTest.php
Expand Up @@ -233,11 +233,11 @@ public function testTranslatorException(Throwable $exception): void
$expectedMessage = sprintf('Translation error: %s', $exception->getMessage());

// Disable assertions so production error-handling can be tested.
assert_options(ASSERT_ACTIVE, 0);
ini_set('zend.assertions', 0);
self::assertSame($expectedMessage, $sut->trans($message), 'Returned exception message on failure.');

// Re-enable assertions so development error-handling can be tested.
assert_options(ASSERT_ACTIVE, 1);
ini_set('zend.assertions', 1);
self::assertTranslatableException(static function () use ($sut, $message): void {
$sut->trans($message);
}, AssertionError::class, $expectedMessage);
Expand Down
8 changes: 4 additions & 4 deletions tests/Translation/Value/TranslationParametersUnitTest.php
Expand Up @@ -76,13 +76,13 @@ public function testDefaultParameters(): void
public function testInvalidPlaceholders(array $given, array $expected, mixed $invalidPlaceholder): void
{
// Disable assertions so production error-handling can be tested.
assert_options(ASSERT_ACTIVE, 0);
ini_set('zend.assertions', 0);
$sut = new TranslationParameters($given);

self::assertSame($expected, $sut->getAll(), 'Returned sanitized array on failure.');

// Re-enable assertions so development error-handling can be tested.
assert_options(ASSERT_ACTIVE, 1);
ini_set('zend.assertions', 1);

self::assertTranslatableException(static function () use ($given): void {
new TranslationParameters($given);
Expand Down Expand Up @@ -167,13 +167,13 @@ public function providerInvalidPlaceholders(): array
public function testInvalidValues(array $given, array $expected, string $invalidType): void
{
// Disable assertions so production error-handling can be tested.
assert_options(ASSERT_ACTIVE, 0);
ini_set('zend.assertions', 0);
$sut = new TranslationParameters($given);

self::assertSame($expected, $sut->getAll(), 'Returned sanitized array on failure.');

// Re-enable assertions so development error-handling can be tested.
assert_options(ASSERT_ACTIVE, 1);
ini_set('zend.assertions', 1);

self::assertTranslatableException(static function () use ($given): void {
new TranslationParameters($given);
Expand Down

0 comments on commit 583c938

Please sign in to comment.