Making WordPress.org

Changeset 5970


Ignore:
Timestamp:
09/28/2017 03:42:20 PM (7 years ago)
Author:
coffee2code
Message:

Browse Happy API: Add unit test for the 'upgrade' parsed data field.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0/tests/phpunit/tests/browse-happy.php

    r5968 r5970  
    420420
    421421    /**
     422     * Test that the 'upgrade' parsed data field is correct.
     423     *
     424     * @dataProvider data_browse_happy
     425     *
     426     * @param string $header 'User-Agent' header value.
     427     */
     428    function test_upgrade_browsers( $header ) {
     429        $parsed = browsehappy_parse_user_agent( $header );
     430
     431        // Currently, mobile browsers are not flagged as upgradable.
     432        if ( $parsed['mobile'] ) {
     433            $this->assertFalse( $parsed['upgrade'] );
     434            return;
     435        }
     436
     437        $versions = get_browser_current_versions();
     438
     439        if ( ! empty( $versions[ $parsed['name'] ] ) ) {
     440            if ( version_compare( $parsed['version'], $versions[ $parsed['name'] ], '<' ) ) {
     441                $this->assertTrue( $parsed['upgrade'] );
     442            } else {
     443                $this->assertFalse( $parsed['upgrade'] );
     444            }
     445        } else {
     446            $this->assertFalse( $parsed['upgrade'] );
     447        }
     448    }
     449
     450    /**
    422451     * @dataProvider data_browse_happy
    423452     *
Note: See TracChangeset for help on using the changeset viewer.