Make WordPress Core

Ticket #9930: 9930-unittests.diff

File 9930-unittests.diff, 1.1 KB (added by MikeHansenMe, 11 years ago)

see #30284

  • tests/phpunit/tests/functions.php

    diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php
    index 9c661a7..c52623e 100644
    a b class Tests_Functions extends WP_UnitTestCase { 
    132132        }
    133133
    134134        /**
     135         * @ticket 9930
     136         */
     137        function test_is_serialized() {
     138                $cases = array(
     139                        serialize(null),
     140                        serialize(true),
     141                        serialize(false),
     142                        serialize(-25),
     143                        serialize(25),
     144                        serialize(1.1),
     145                        serialize(2.1E+200),
     146                        serialize('this string will be serialized'),
     147                        serialize("a\nb"),
     148                        serialize(array()),
     149                        serialize(array(1,1,2,3,5,8,13)),
     150                        serialize( (object)array('test' => true, '3', 4) )
     151                );
     152                foreach ( $cases as $case )
     153                        $this->assertTrue( is_serialized($case), "Serialized data: $case" );
     154
     155                $not_serialized = array(
     156                        'a string',
     157                        'garbage:a:0:garbage;',
     158                        'b:4;',
     159                        's:4:test;'
     160                );
     161                foreach ( $not_serialized as $case )
     162                        $this->assertFalse( is_serialized($case), "Test data: $case" );
     163        }
     164
     165        /**
    135166         * @group add_query_arg
    136167         */
    137168        function test_add_query_arg() {