Make WordPress Core

Changeset 36810


Ignore:
Timestamp:
03/03/2016 02:00:06 AM (9 years ago)
Author:
johnbillion
Message:

Uploads: Add tests for device upload capabilities based on user agent.

Fixes #35976
Props borgesbruno

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions.php

    r36764 r36810  
    418418            array( array( 1, 2, 3, 4 ), '-1,2,-3,4' ),
    419419            array( array( 1, 2, 3, 4 ), array( -1, 2, '-3', '4' ) ),
     420        );
     421    }
     422
     423    /**
     424     * @dataProvider data_device_can_upload
     425     */
     426    function test_device_can_upload( $user_agent, $expected ) {
     427        $_SERVER['HTTP_USER_AGENT'] = $user_agent;
     428        $actual = _device_can_upload();
     429        unset( $_SERVER['HTTP_USER_AGENT'] );
     430        $this->assertEquals( $expected, $actual );
     431    }
     432
     433    function data_device_can_upload() {
     434        return array(
     435            // iPhone iOS 5.0.1, Safari 5.1
     436            array(
     437                'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A406)',
     438                false,
     439            ),
     440            // iPad iOS 3.2, Safari 4.0.4
     441            array(
     442                'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10',
     443                false,
     444            ),
     445            // iPod iOS 4.3.3, Safari 5.0.2
     446            array(
     447                'Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5',
     448                false,
     449            ),
     450            // iPhone iOS 6.0.0, Safari 6.0
     451            array(
     452                'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25',
     453                true,
     454            ),
     455            // iPad iOS 6.0.0, Safari 6.0
     456            array(
     457                'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25',
     458                true,
     459            ),
     460            // Android 2.2, Android Webkit Browser
     461            array(
     462                'Mozilla/5.0 (Android 2.2; Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4',
     463                true,
     464            ),
     465            // BlackBerry 9900, BlackBerry browser
     466            array(
     467                'Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.346 Mobile Safari/534.11+',
     468                true,
     469            ),
     470            // Windows Phone 8.0, Internet Explorer 10.0;
     471            array(
     472                'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)',
     473                true,
     474            ),
     475            // Ubuntu desktop, Firefox 41.0
     476            array(
     477                'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:41.0) Gecko/20100101 Firefox/41.0',
     478                true,
     479            ),
    420480        );
    421481    }
Note: See TracChangeset for help on using the changeset viewer.