mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@48463 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f36c42c700
commit
0ded98ff2c
@ -5,22 +5,40 @@
|
||||
class Test_Theme_File extends WP_UnitTestCase {
|
||||
|
||||
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
|
||||
if ( ! function_exists( 'symlink' ) ) {
|
||||
self::markTestSkipped( 'symlink() is not available.' );
|
||||
}
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
||||
if ( ! @symlink( DIR_TESTDATA . '/theme-file-parent', WP_CONTENT_DIR . '/themes/theme-file-parent' ) ) {
|
||||
self::markTestSkipped( 'Could not create parent symlink.' );
|
||||
}
|
||||
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
|
||||
if ( ! @symlink( DIR_TESTDATA . '/theme-file-child', WP_CONTENT_DIR . '/themes/theme-file-child' ) ) {
|
||||
self::markTestSkipped( 'Could not create child symlink.' );
|
||||
$themes = array(
|
||||
'theme-file-parent',
|
||||
'theme-file-child',
|
||||
);
|
||||
|
||||
// Copy themes from tests/phpunit/data to wp-content/themes.
|
||||
foreach ( $themes as $theme ) {
|
||||
$source_dir = DIR_TESTDATA . '/' . $theme;
|
||||
$dest_dir = WP_CONTENT_DIR . '/themes/' . $theme;
|
||||
|
||||
mkdir( $dest_dir );
|
||||
|
||||
foreach ( glob( $source_dir . '/*.*' ) as $theme_file ) {
|
||||
copy( $theme_file, $dest_dir . '/' . basename( $theme_file ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function wpTearDownAfterClass() {
|
||||
unlink( WP_CONTENT_DIR . '/themes/theme-file-parent' );
|
||||
unlink( WP_CONTENT_DIR . '/themes/theme-file-child' );
|
||||
$themes = array(
|
||||
'theme-file-parent',
|
||||
'theme-file-child',
|
||||
);
|
||||
|
||||
// Remove previously copied themes from wp-content/themes.
|
||||
foreach ( $themes as $theme ) {
|
||||
$dest_dir = WP_CONTENT_DIR . '/themes/' . $theme;
|
||||
|
||||
foreach ( glob( $dest_dir . '/*.*' ) as $theme_file ) {
|
||||
unlink( $theme_file );
|
||||
}
|
||||
|
||||
rmdir( $dest_dir );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user