Making WordPress.org


Ignore:
Timestamp:
10/16/2017 10:32:50 PM (8 years ago)
Author:
coffee2code
Message:

Browse Happy API: Refactor to reduce both code duplication and the number of repeated checks performed.

  • Compacts near-identical handling for explicitly identifiable browsers into single handler
  • Removes individual handlers for 17 browsers
  • Adds browsehappy_get_explicit_browser_tokens() to return data for the similarly-handled explicitly identifiable browsers
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

    r6021 r6037  
    866866    }
    867867
     868    function test_browsehappy_get_explicit_browser_tokens() {
     869        $tokens = browsehappy_get_explicit_browser_tokens();
     870
     871        $this->assertTrue( is_array( $tokens ) );
     872
     873        $this->assertArrayHasKey( 'Camino', $tokens );
     874        $this->assertEmpty( $tokens['Camino'] );
     875
     876        $this->assertArrayHasKey( 'S40OviBrowser', $tokens );
     877        $this->assertArrayHasKey( 'name', $tokens['S40OviBrowser'] );
     878        $this->assertEquals( 'Ovi Browser', $tokens['S40OviBrowser']['name'] );
     879        $this->assertArrayHasKey( 'mobile', $tokens['S40OviBrowser'] );
     880        $this->assertTrue( $tokens['S40OviBrowser']['mobile'] );
     881        $this->assertArrayHasKey( 'platform', $tokens['S40OviBrowser'] );
     882        $this->assertEquals( 'Symbian', $tokens['S40OviBrowser']['platform'] );
     883    }
     884
    868885}
Note: See TracChangeset for help on using the changeset viewer.