Make WordPress Core

Changeset 44478


Ignore:
Timestamp:
01/08/2019 07:04:51 PM (6 years ago)
Author:
desrosj
Message:

Tests: Add missing test cases for is_serialized_string().

Also, reorganize these tests into their own class.

Props pbearne.
Fixes #42870.

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

Legend:

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

    r44442 r44478  
    237237    }
    238238
    239     /**
    240      * @dataProvider data_is_serialized_string
    241      */
    242     public function test_is_serialized_string( $value, $result ) {
    243         $this->assertSame( is_serialized_string( $value ), $result );
    244     }
    245 
    246     public function data_is_serialized_string() {
    247         return array(
    248             // Not a string.
    249             array( 0, false ),
    250 
    251             // Too short when trimmed.
    252             array( 's:3   ', false ),
    253 
    254             // Too short.
    255             array( 's:3', false ),
    256 
    257             // No colon in second position.
    258             array( 's!3:"foo";', false ),
    259 
    260             // No trailing semicolon.
    261             array( 's:3:"foo"', false ),
    262 
    263             // Wrong type.
    264             array( 'a:3:"foo";', false ),
    265 
    266             // No closing quote.
    267             array( 'a:3:"foo;', false ),
    268 
    269             // Wrong number of characters is close enough for is_serialized_string().
    270             array( 's:12:"foo";', true ),
    271 
    272             // Okay.
    273             array( 's:3:"foo";', true ),
    274 
    275         );
    276     }
    277239
    278240    /**
Note: See TracChangeset for help on using the changeset viewer.