Make WordPress Core


Ignore:
Timestamp:
02/20/2020 05:43:23 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Build/Test Tools: Merge some test fixes to the 4.0 branch, for consistency with other branches.

This backports [30518], [30520], [30526], [31253-31254], [31257].

See #49485.

Location:
branches/4.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0

  • branches/4.0/tests/phpunit/tests/functions.php

    r45013 r47331  
    130130        $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\\fg.png' ), 'Double slashed not removed' );
    131131        $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\\\fg.png' ), 'Tripple slashed not removed' );
     132    }
     133
     134    function test_is_serialized() {
     135        $cases = array(
     136            serialize(null),
     137            serialize(true),
     138            serialize(false),
     139            serialize(-25),
     140            serialize(25),
     141            serialize(1.1),
     142            serialize('this string will be serialized'),
     143            serialize("a\nb"),
     144            serialize(array()),
     145            serialize(array(1,1,2,3,5,8,13)),
     146            serialize( (object)array('test' => true, '3', 4) )
     147        );
     148        foreach ( $cases as $case )
     149            $this->assertTrue( is_serialized($case), "Serialized data: $case" );
     150
     151        $not_serialized = array(
     152            'a string',
     153            'garbage:a:0:garbage;',
     154            's:4:test;'
     155        );
     156        foreach ( $not_serialized as $case )
     157            $this->assertFalse( is_serialized($case), "Test data: $case" );
    132158    }
    133159
Note: See TracChangeset for help on using the changeset viewer.