WordPress.org

Make WordPress Core

Changeset 34898


Ignore:
Timestamp:
10/07/2015 04:57:12 AM (6 years ago)
Author:
jeremyfelt
Message:

Tests: Improve tests for get_space_allowed().

  • Move all tests to a new multisite/getSpaceAllowed.php
  • Store original blog_upload_space values before the class is loaded.
  • Restore these values after each test tear down to avoid pollution.
  • Add a comprehensive set of expectations and results via data provider.

See #34037.

Location:
trunk/tests/phpunit/tests/multisite
Files:
1 added
1 edited

Legend:

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

    r34606 r34898  
    907907
    908908    /**
    909      * Tests to handle the possibilities provided for in `get_space_allowed()`,
    910      * which is used when checking for upload quota limits. Originally part of
    911      * ticket #18119.
    912      */
    913     function test_get_space_allowed_default() {
    914         $this->assertEquals( 100, self::$space_allowed );
    915     }
    916 
    917     /**
    918      * When an individual site's option is defined, it is used over the option
    919      * defined at the network level.
    920      */
    921     function test_get_space_allowed_from_blog_option() {
    922         update_option( 'blog_upload_space', 123 );
    923         update_site_option( 'blog_upload_space', 200 );
    924         $this->assertEquals( 123, get_space_allowed() );
    925     }
    926 
    927     /**
    928      * If an individual site's option is not available, the default network
    929      * level option is used as a fallback.
    930      */
    931     function test_get_space_allowed_from_network_option() {
    932         update_option( 'blog_upload_space', false );
    933         update_site_option( 'blog_upload_space', 200 );
    934         $this->assertEquals( 200, get_space_allowed() );
    935     }
    936 
    937     /**
    938      * If neither the site or network options are available, 100 is used as
    939      * a hard coded fallback.
    940      */
    941     function test_get_space_allowed_no_option_fallback() {
    942         update_option( 'blog_upload_space', false );
    943         update_site_option( 'blog_upload_space', false );
    944         $this->assertEquals( 100, get_space_allowed() );
    945     }
    946 
    947     function test_get_space_allowed_negative_blog_option() {
    948         update_option( 'blog_upload_space', -1 );
    949         update_site_option( 'blog_upload_space', 200 );
    950         $this->assertEquals( -1, get_space_allowed() );
    951     }
    952 
    953     function test_get_space_allowed_negative_site_option() {
    954         update_option( 'blog_upload_space', false );
    955         update_site_option( 'blog_upload_space', -1 );
    956         $this->assertEquals( -1, get_space_allowed() );
    957     }
    958 
    959     /**
    960909     * Provide a hardcoded amount for space used when testing upload quota,
    961910     * allowed space, and available space.
Note: See TracChangeset for help on using the changeset viewer.