Make WordPress Core

Changeset 34601


Ignore:
Timestamp:
09/26/2015 07:10:12 PM (9 years ago)
Author:
wonderboymusic
Message:

After [34577] (not because of), uncover and fix some horrifying anomalies in Tests_Multisite_Site.

Location:
trunk/tests/phpunit/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/site.php

    r34532 r34601  
    1111class Tests_Multisite_Site extends WP_UnitTestCase {
    1212    protected $suppress = false;
     13
     14    protected static $space_used;
     15    protected static $space_allowed;
     16
     17    public static function setUpBeforeClass() {
     18        parent::setUpBeforeClass();
     19
     20        self::$space_allowed = get_space_allowed();
     21        self::$space_used = get_space_used();
     22    }
    1323
    1424    function setUp() {
     
    902912     */
    903913    function test_get_space_allowed_default() {
    904         $this->assertEquals( 100, get_space_allowed() );
     914        $this->assertEquals( 100, self::$space_allowed );
    905915    }
    906916
     
    962972
    963973    function test_upload_is_user_over_quota_check_enabled() {
    964         update_site_option('upload_space_check_disabled', false);
    965         $this->assertFalse( upload_is_user_over_quota( false ) );
     974        update_site_option( 'upload_space_check_disabled', false );
     975        // will be set to ''
     976        $this->assertEmpty( get_site_option( 'upload_space_check_disabled' ) );
     977
     978        $this->assertEquals(
     979            upload_is_user_over_quota( false ),
     980            self::$space_used > self::$space_allowed
     981        );
    966982    }
    967983
     
    974990        update_site_option( 'blog_upload_space', 100 );
    975991        add_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
    976 
    977         $this->assertFalse( upload_is_user_over_quota( false ) );
    978 
     992        $quota = upload_is_user_over_quota( false );
    979993        remove_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
     994
     995        $this->assertFalse( $quota );
    980996    }
    981997
     
    9861002        update_site_option( 'upload_space_check_disabled', false );
    9871003        update_site_option( 'blog_upload_space', 0 );
    988         $this->assertFalse( upload_is_user_over_quota( false ) );
     1004
     1005        $this->assertEquals(
     1006            upload_is_user_over_quota( false ),
     1007            self::$space_used > self::$space_allowed
     1008        );
    9891009    }
    9901010
     
    9971017        update_site_option( 'blog_upload_space', 0 );
    9981018        add_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
    999 
    1000         $this->assertTrue( upload_is_user_over_quota( false ) );
    1001 
     1019        $quota = upload_is_user_over_quota( false );
    10021020        remove_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
     1021
     1022        $this->assertTrue( $quota );
    10031023    }
    10041024
     
    10061026        update_site_option( 'upload_space_check_disabled', false );
    10071027        update_site_option( 'blog_upload_space', 200 );
    1008         $this->assertFalse( upload_is_user_over_quota( false ) );
     1028        $this->assertEquals(
     1029            upload_is_user_over_quota( false ),
     1030            self::$space_used > 200
     1031        );
    10091032    }
    10101033
     
    10131036        update_site_option( 'blog_upload_space', 200 );
    10141037        add_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
    1015 
    1016         $this->assertTrue( upload_is_user_over_quota( false ) );
    1017 
     1038        $quota = upload_is_user_over_quota( false );
    10181039        remove_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
     1040
     1041        $this->assertTrue( $quota );
    10191042    }
    10201043
     
    10221045     * If the space used is exactly the same as the available quota, an over
    10231046     * quota response is not expected.
     1047     *
     1048     * @group woo
    10241049     */
    10251050    function test_upload_is_user_over_quota_upload_space_exact() {
     
    10271052        update_site_option( 'blog_upload_space', 300 );
    10281053        add_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
    1029 
    1030         $this->assertFalse( upload_is_user_over_quota( false ) );
    1031 
     1054        $quota = upload_is_user_over_quota( false );
     1055        $used = get_space_used();
    10321056        remove_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
     1057
     1058        $this->assertEquals(
     1059            $quota,
     1060            $used > 300
     1061        );
    10331062    }
    10341063
     
    10521081        update_site_option( 'blog_upload_space', 350 );
    10531082        add_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
     1083        $available = is_upload_space_available();
     1084        remove_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
    10541085
    10551086        $this->assertTrue( is_upload_space_available() );
    1056 
    1057         remove_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
     1087        $this->assertEquals(
     1088            $available,
     1089            self::$space_used < 350
     1090        );
    10581091    }
    10591092
     
    10621095        update_site_option( 'blog_upload_space', 250 );
    10631096        add_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
    1064 
    1065         $this->assertFalse( is_upload_space_available() );
    1066 
     1097        $available = is_upload_space_available();
    10671098        remove_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
     1099
     1100        $this->assertEquals(
     1101            $available,
     1102            self::$space_used < 250
     1103        );
    10681104    }
    10691105
     
    10711107        update_site_option( 'upload_space_check_disabled', false );
    10721108        update_site_option( 'blog_upload_space', 0 );
    1073         $this->assertTrue( is_upload_space_available() );
     1109        $this->assertFalse( is_upload_space_available() );
    10741110    }
    10751111
     
    11511187    function test_domain_filtered_to_exist() {
    11521188        add_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 );
    1153 
    1154         $this->assertEquals( 1234, domain_exists( 'foo', 'bar' ) );
    1155 
     1189        $exists = domain_exists( 'foo', 'bar' );
    11561190        remove_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 );
     1191        $this->assertEquals( 1234, $exists );
    11571192    }
    11581193
     
    11631198    function test_slashed_path_in_domain_exists() {
    11641199        add_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 );
     1200        $exists1 = domain_exists( 'foo', 'bar' );
     1201        $exists2 = domain_exists( 'foo', 'bar/' );
     1202        remove_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 );
    11651203
    11661204        // Make sure the same result is returned with or without a trailing slash
    1167         $this->assertEquals( domain_exists( 'foo', 'bar' ), domain_exists( 'foo', 'bar/' ) );
    1168 
    1169         remove_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 );
     1205        $this->assertEquals( $exists1, $exists2 );
    11701206    }
    11711207
  • trunk/tests/phpunit/tests/xmlrpc/wp/uploadFile.php

    r34577 r34601  
    55 */
    66class Tests_XMLRPC_wp_uploadFile extends WP_XMLRPC_UnitTestCase {
     7
     8    public function tearDown() {
     9        $this->remove_added_uploads();
     10
     11        parent::tearDown();
     12    }
    713
    814    function test_valid_attachment() {
Note: See TracChangeset for help on using the changeset viewer.