Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: PHPUnit Tests

on:
push:
branches: master
paths:
- '**.php'
- 'phpunit.xml.dist'
- '**.neon'
- 'composer.json'
- '.github/workflows/phpunit-tests.yml'
pull_request:
branches:
- master
paths:
- '**.php'
- 'phpunit.xml.dist'
- '**.neon'
- 'composer.json'
- '.github/workflows/phpunit-tests.yml'
workflow_dispatch:

jobs:
testing:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [7.4, 8.4]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there only two versions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the min and max version supported by our szepeviktor/phpstan-wordpress dependency.
No need to test all versions in between IMHO.


steps:
- name: Check out the source code
uses: actions/checkout@v4

- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}

- name: Install PHP Dependencies
uses: ramsey/composer-install@v3
with:
dependency-versions: 'highest'

- name: Run PHPUnit tests
run: composer test
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
"szepeviktor/phpstan-wordpress": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^7 || ^9"
"phpunit/phpunit": "^7 || ^9",
"wpsyntex/polylang-stubs": "dev-master"
},
"autoload": {
"psr-4": {
"WPSyntex\\Polylang\\PHPStan\\": "src/"
}
},
"scripts": {
"test":"vendor/bin/phpunit"
"test":"vendor/bin/phpunit -d memory_limit=1G"
}
}
2 changes: 1 addition & 1 deletion tests/DynamicReturnTypeExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testFileAsserts(string $assertType, string $file, ...$args): voi

public static function getAdditionalConfigFiles(): array
{
// path to your project's phpstan.neon, or extension.neon in case of custom extension packages
// phpstan.neon or extension.neon use relative paths, so we need to use a fake vendor directory regarding szepeviktor/phpstan-wordpress dependency.
return [dirname(__DIR__) . '/vendor/wpsyntex/polylang-phpstan/extension.neon'];
}
}
10 changes: 4 additions & 6 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
if (! is_dir($helperDirectory)) {
mkdir($helperDirectory, 0777, true);
}
if ( ! file_exists( $helperDirectory . '/extension.neon' ) ) {
copy(dirname(__DIR__) . '/extension.neon', $helperDirectory . '/extension.neon');
}
if ( ! file_exists( $helperDirectory . '/bootstrap.php' ) ) {
copy(dirname(__DIR__) . '/bootstrap.php', $helperDirectory . '/bootstrap.php');
}

// Copy package to a fake vendor directory.
copy(dirname(__DIR__) . '/extension.neon', $helperDirectory . '/extension.neon');
copy(dirname(__DIR__) . '/bootstrap.php', $helperDirectory . '/bootstrap.php');

require_once dirname(__DIR__) . '/vendor/autoload.php';