WordPress.org

Make WordPress Core

Changeset 1218 in tests for trunk/tests/media.php


Ignore:
Timestamp:
02/16/2013 03:52:30 AM (8 years ago)
Author:
SergeyBiryukov
Message:

Test for wp_convert_bytes_to_hr(). see #19067.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/media.php

    r1156 r1218  
    144144        $this->assertEquals( '', $prepped['subtype'] );
    145145    }
     146
     147    /**
     148     * @ticket 19067
     149     */
     150    function test_wp_convert_bytes_to_hr() {
     151        $kb = 1024;
     152        $mb = $kb * 1024;
     153        $gb = $mb * 1024;
     154
     155        // test if boundaries are correct
     156        $this->assertEquals( '1GB', wp_convert_bytes_to_hr( $gb ) );
     157        $this->assertEquals( '1MB', wp_convert_bytes_to_hr( $mb ) );
     158        $this->assertEquals( '1kB', wp_convert_bytes_to_hr( $kb ) );
     159
     160        // now some values around
     161        $this->assertEquals( '1.5009765625GB', wp_convert_bytes_to_hr( $gb + $gb / 2 + $mb ) );
     162        $this->assertEquals( '1022.99902344MB', wp_convert_bytes_to_hr( $gb - $mb - $kb ) );
     163
     164        // edge
     165        $this->assertEquals( 'NANB', wp_convert_bytes_to_hr( -1 ) );
     166        $this->assertEquals( '0B', wp_convert_bytes_to_hr( 0 ) );
     167    }
    146168}
Note: See TracChangeset for help on using the changeset viewer.