close

Making WordPress.org

Changeset 14691


Ignore:
Timestamp:
03/10/2026 05:11:01 AM (4 days ago)
Author:
dd32
Message:

Github actions: Run the Handbook unit tests.

Closes https://github.com/WordPress/wordpress.org/pull/559

Location:
sites/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/.github/workflows/unit-tests.yml

    r14690 r14691  
    22
    33on:
     4  pull_request:
    45  push:
    5     branches: [ trunk ]
    6   pull_request:
    76    branches: [ trunk ]
    87
     
    5251        working-directory: ${{ matrix.working-directory }}
    5352        run: phpunit ${{ matrix.phpunit-args }}
     53
     54  # WordPress-dependent PHP tests — require wp-env (Docker).
     55  php-wordpress:
     56    name: "WP: ${{ matrix.name }}"
     57    runs-on: ubuntu-latest
     58    strategy:
     59      fail-fast: false
     60      matrix:
     61        include:
     62          - name: Handbook Plugin
     63            plugin-directory: wordpress.org/public_html/wp-content/plugins/handbook
     64    steps:
     65      - uses: actions/checkout@v4
     66
     67      - name: Set up Node.js
     68        uses: actions/setup-node@v4
     69        with:
     70          node-version: 20
     71
     72      - name: Install wp-env
     73        run: npm -g install @wordpress/env
     74
     75      - name: Start wp-env
     76        working-directory: ${{ matrix.plugin-directory }}
     77        run: wp-env start
     78
     79      - name: Install PHPUnit Polyfills
     80        working-directory: ${{ matrix.plugin-directory }}
     81        run: wp-env run tests-cli composer require --dev yoast/phpunit-polyfills:^4.0 --working-dir=/wordpress-phpunit
     82
     83      - name: Run PHPUnit
     84        working-directory: ${{ matrix.plugin-directory }}
     85        run: wp-env run tests-cli --env-cwd=wp-content/plugins/$(basename ${{ matrix.plugin-directory }}) phpunit --no-configuration --bootstrap phpunit/bootstrap.php phpunit/tests/
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/phpunit/bootstrap.php

    r10757 r14691  
    1515    $_tests_dir = substr( __FILE__, 0, $pos ) . '/tests/phpunit/';
    1616}
     17// Check for wp-env test directory.
     18elseif ( ! $_tests_dir && file_exists( '/wordpress-phpunit/includes/functions.php' ) ) {
     19    $_tests_dir = '/wordpress-phpunit/';
     20}
    1721// Elseif no path yet, assume a temp directory path.
    1822elseif ( ! $_tests_dir ) {
     
    2327    echo "Could not find $_tests_dir/includes/functions.php\n";
    2428    exit( 1 );
     29}
     30
     31// Set polyfills path if available (required by WP test suite).
     32if ( ! defined( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ) && file_exists( $_tests_dir . '/vendor/yoast/phpunit-polyfills' ) ) {
     33    define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', $_tests_dir . '/vendor/yoast/phpunit-polyfills' );
    2534}
    2635
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/phpunit/tests/handbook.php

    r10774 r14691  
    1818    protected $handbook;
    1919
    20     public function setUp() {
     20    public function setUp(): void {
    2121        parent::setup();
    2222        WPorg_Handbook_Init::init();
     
    2626    }
    2727
    28     public function tearDown() {
     28    public function tearDown(): void {
    2929        parent::tearDown();
    3030
     
    456456        $this->assertTrue( isset( $wp_registered_sidebars[ 'handbook' ] ) );
    457457        $this->assertSame(
    458             [ 'name', 'id', 'description', 'class', 'before_widget', 'after_widget', 'before_title', 'after_title', 'before_sidebar', 'after_sidebar' ],
     458            [ 'name', 'id', 'description', 'class', 'before_widget', 'after_widget', 'before_title', 'after_title', 'before_sidebar', 'after_sidebar', 'show_in_rest' ],
    459459            array_keys( $wp_registered_sidebars[ 'handbook' ] )
    460460        );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/phpunit/tests/init.php

    r10773 r14691  
    55class WPorg_Handbook_Init_Test extends WP_UnitTestCase {
    66
    7     public function setUp() {
     7    public function setUp(): void {
    88        parent::setup();
    99
     
    1111    }
    1212
    13     public function tearDown() {
     13    public function tearDown(): void {
    1414        parent::tearDown();
    1515
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/phpunit/tests/template-tags.php

    r10762 r14691  
    55class WPorg_Handbook_Template_Tags_Test extends WP_UnitTestCase {
    66
    7     public function setUp() {
     7    public function setUp(): void {
    88        parent::setup();
    99
     
    1111    }
    1212
    13     public function tearDown() {
     13    public function tearDown(): void {
    1414        parent::tearDown();
    1515
Note: See TracChangeset for help on using the changeset viewer.