Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to Mantle testkit 1.0 and PHPUnit 11 #37

Merged
merged 6 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
42 changes: 42 additions & 0 deletions .github/workflows/all-pr-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "All Pull Request Tests"

on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened, ready_for_review]

jobs:
# We use a single job to ensure that all steps run in the same environment and
# reduce the number of minutes used.
pr-tests:
# Don't run on draft PRs
if: github.event.pull_request.draft == false
# Timeout after 10 minutes
timeout-minutes: 10
# Define a matrix of PHP/WordPress versions to test against
strategy:
matrix:
php: [8.1, 8.2, 8.3]
srtfisher marked this conversation as resolved.
Show resolved Hide resolved
wordpress: ["latest"]
runs-on: ubuntu-latest
# Cancel any existing runs of this workflow
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}-P${{ matrix.php }}-WP${{ matrix.wordpress }}
cancel-in-progress: true
# Name the job in the matrix
name: "PR Tests PHP ${{ matrix.php }} WordPress ${{ matrix.wordpress }}"
steps:
- uses: actions/checkout@v4

- name: Run General Tests
# See https://github.com/alleyinteractive/action-test-general for more options
uses: alleyinteractive/action-test-general@develop

- name: Run PHP Tests
# See https://github.com/alleyinteractive/action-test-php for more options
uses: alleyinteractive/action-test-php@develop
with:
php-version: '${{ matrix.php }}'
wordpress-version: '${{ matrix.wordpress }}'
skip-wordpress-install: 'true'
18 changes: 0 additions & 18 deletions .github/workflows/coding-standards.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/tests.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@
<property name="prefixes" type="array" value="alley,test" />
</properties>
</rule>

<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<exclude-pattern>tests/</exclude-pattern>
</rule>

<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>tests/</exclude-pattern>
</rule>
</ruleset>
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
}
}
},
"autoload-dev": {
"psr-4": {
"Alley\\WP_Bulk_Task\\Tests\\": "tests/"
}
},
"license": "GPL-2.0-or-later",
"name": "alleyinteractive/wp-bulk-task",
"require": {
Expand All @@ -30,7 +35,7 @@
},
"require-dev": {
"alleyinteractive/alley-coding-standards": "^2.0",
"mantle-framework/testkit": "^0.12",
"mantle-framework/testkit": "^1.0",
"php-stubs/wp-cli-stubs": "^2.10",
"wp-cli/php-cli-tools": "^0.11",
"szepeviktor/phpstan-wordpress": "^1.3"
Expand Down
18 changes: 9 additions & 9 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
srtfisher marked this conversation as resolved.
Show resolved Hide resolved
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<testsuites>
<testsuite name="general">
<directory prefix="class-test-" suffix=".php">tests</directory>
</testsuite>
</testsuites>
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory=".phpunit.result.cache">
<testsuites>
<testsuite name="general">
<directory prefix="Test" suffix=".php">tests</directory>
</testsuite>
</testsuites>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

declare( strict_types=1 );
srtfisher marked this conversation as resolved.
Show resolved Hide resolved

namespace Alley\WP_Bulk_Task\Tests;

use Alley\WP_Bulk_Task\Bulk_Task;
use Mantle\Testing\Concerns\Refresh_Database;
use Mantle\Testkit\Test_Case;
Expand All @@ -16,7 +18,7 @@
*
* @package alleyinteractive/wp-bulk-task
*/
class Test_CSV_Bulk_Task extends Test_Case {
class TestCsvBulkTask extends Test_Case {
use Refresh_Database;

/**
Expand All @@ -39,7 +41,7 @@ public function setUp(): void {
* Test the run function on a invalid CSV file.
*/
public function test_invalid_csv(): void {
$this->expectException( Exception::class );
$this->expectException( \Exception::class );
$this->expectExceptionMessage( 'The CSV file does not exist or is not readable.' );

( new Bulk_Task( 'test_invalid_csv' ) )->run(
Expand Down
4 changes: 3 additions & 1 deletion tests/class-test-cursor.php → tests/TestCursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

declare( strict_types=1 );
srtfisher marked this conversation as resolved.
Show resolved Hide resolved

namespace Alley\WP_Bulk_Task\Tests;

use Alley\WP_Bulk_Task\Cursor;
use Mantle\Testkit\Test_Case;

Expand All @@ -15,7 +17,7 @@
*
* @package alleyinteractive/wp-bulk-task
*/
class Test_Cursor extends Test_Case {
class TestCursor extends Test_Case {
/**
* Tests the cursor lifecycle (does not exist, created, updated, removed).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
* @package alleyinteractive/wp-bulk-task
*/

namespace Alley\WP_Bulk_Task\Tests;

use Alley\WP_Bulk_Task\Bulk_Task;
use Mantle\Testing\Concerns\Refresh_Database;
use Mantle\Testkit\Test_Case;

use WP_Post;

/**
* Tests for the Test_Post_Bulk_Task class.
*
* @package alleyinteractive/wp-bulk-task
*/
class Test_Post_Bulk_Task extends Test_Case {
class TestPostBulkTask extends Test_Case {
use Refresh_Database;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
* @package alleyinteractive/wp-bulk-task
*/

namespace Alley\WP_Bulk_Task\Tests;

use Alley\WP_Bulk_Task\Bulk_Task;
use Mantle\Testing\Concerns\Refresh_Database;
use Mantle\Testkit\Test_Case;
use WP_Term;

/**
* Tests for the Test_Term_Bulk_Task class.
*
* @package alleyinteractive/wp-bulk-task
*/
class Test_Term_Bulk_Task extends Test_Case {
class TestTermBulkTask extends Test_Case {
use Refresh_Database;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@

declare( strict_types=1 );
srtfisher marked this conversation as resolved.
Show resolved Hide resolved

namespace Alley\WP_Bulk_Task\Tests;

use Alley\WP_Bulk_Task\Bulk_Task;
use Mantle\Testing\Concerns\Refresh_Database;
use Mantle\Testkit\Test_Case;
use WP_User;

/**
* Tests for the Test_User_Bulk_Task class.
*
* @package alleyinteractive/wp-bulk-task
*/
class Test_User_Bulk_Task extends Test_Case {
class TestUserBulkTask extends Test_Case {
use Refresh_Database;

/**
Expand Down