Make WordPress Core

Changeset 48463


Ignore:
Timestamp:
07/14/2020 12:32:36 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Tests: Copy themes from tests/phpunit/data to wp-content/themes, instead of creating a symlink.

This allows the theme file tests in phpunit/tests/link/themeFile.php to run on Windows without requiring administrative privileges.

Follow-up to [42812], [42819].

Props danielhuesken, christophherr, davidbaumwald, SergeyBiryukov.
See #40856, #39975.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/link/themeFile.php

    r46586 r48463  
    66
    77        public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
    8                 if ( ! function_exists( 'symlink' ) ) {
    9                         self::markTestSkipped( 'symlink() is not available.' );
    10                 }
    11                 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    12                 if ( ! @symlink( DIR_TESTDATA . '/theme-file-parent', WP_CONTENT_DIR . '/themes/theme-file-parent' ) ) {
    13                         self::markTestSkipped( 'Could not create parent symlink.' );
    14                 }
    15                 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    16                 if ( ! @symlink( DIR_TESTDATA . '/theme-file-child', WP_CONTENT_DIR . '/themes/theme-file-child' ) ) {
    17                         self::markTestSkipped( 'Could not create child symlink.' );
     8                $themes = array(
     9                        'theme-file-parent',
     10                        'theme-file-child',
     11                );
     12
     13                // Copy themes from tests/phpunit/data to wp-content/themes.
     14                foreach ( $themes as $theme ) {
     15                        $source_dir = DIR_TESTDATA . '/' . $theme;
     16                        $dest_dir   = WP_CONTENT_DIR . '/themes/' . $theme;
     17
     18                        mkdir( $dest_dir );
     19
     20                        foreach ( glob( $source_dir . '/*.*' ) as $theme_file ) {
     21                                copy( $theme_file, $dest_dir . '/' . basename( $theme_file ) );
     22                        }
    1823                }
    1924        }
    2025
    2126        public static function wpTearDownAfterClass() {
    22                 unlink( WP_CONTENT_DIR . '/themes/theme-file-parent' );
    23                 unlink( WP_CONTENT_DIR . '/themes/theme-file-child' );
     27                $themes = array(
     28                        'theme-file-parent',
     29                        'theme-file-child',
     30                );
     31
     32                // Remove previously copied themes from wp-content/themes.
     33                foreach ( $themes as $theme ) {
     34                        $dest_dir = WP_CONTENT_DIR . '/themes/' . $theme;
     35
     36                        foreach ( glob( $dest_dir . '/*.*' ) as $theme_file ) {
     37                                unlink( $theme_file );
     38                        }
     39
     40                        rmdir( $dest_dir );
     41                }
    2442        }
    2543
Note: See TracChangeset for help on using the changeset viewer.