Make WordPress Core


Ignore:
Timestamp:
12/19/2021 01:42:37 PM (3 years ago)
Author:
johnbillion
Message:

Build/Test Tools: Reduce the use of unnecessary randomness in tests.

This increases the overall reliability of the tests.

Props johnillo

Fixes #37371

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesPlugin.php

    r52010 r52389  
    488488
    489489        $dropins = get_dropins();
    490         $this->assertSame( array( 'advanced-cache.php' ), array_keys( $dropins ) );
    491490
    492491        unlink( $p1[1] );
    493492        unlink( $p2[1] );
    494493
     494        $this->assertSame( array( 'advanced-cache.php' ), array_keys( $dropins ) );
     495
    495496        // Clean up.
    496497        $this->_restore_drop_ins();
     
    510511        $p = $this->_create_plugin( "<?php\n/*\nPlugin Name: test\nNetwork: true" );
    511512
    512         $this->assertTrue( is_network_only_plugin( $p[0] ) );
     513        $network_only = is_network_only_plugin( $p[0] );
    513514
    514515        unlink( $p[1] );
     516
     517        $this->assertTrue( $network_only );
    515518    }
    516519
     
    572575        update_option( 'uninstall_plugins', $uninstallable_plugins );
    573576
    574         $this->assertTrue( is_uninstallable_plugin( $plugin[0] ) );
     577        $is_uninstallable = is_uninstallable_plugin( $plugin[0] );
    575578
    576579        unset( $uninstallable_plugins[ $plugin[0] ] );
     
    578581
    579582        unlink( $plugin[1] );
     583
     584        $this->assertTrue( $is_uninstallable );
    580585    }
    581586
     
    596601    private function _create_plugin( $data = "<?php\n/*\nPlugin Name: Test\n*/", $filename = false, $dir_path = false ) {
    597602        if ( false === $filename ) {
    598             $filename = rand_str() . '.php';
     603            $filename = __FUNCTION__ . '.php';
    599604        }
    600605
     
    603608        }
    604609
    605         $full_name = $dir_path . '/' . wp_unique_filename( $dir_path, $filename );
     610        $filename  = wp_unique_filename( $dir_path, $filename );
     611        $full_name = $dir_path . '/' . $filename;
    606612
    607613        $file = fopen( $full_name, 'w' );
Note: See TracChangeset for help on using the changeset viewer.