Make WordPress Core

Ticket #4029: 4029.testcases.diff

File 4029.testcases.diff, 2.7 KB (added by jacobsantos, 17 years ago)

Test cases for maybe_serialize()

  • test_includes_functions.php

     
    99
    1010        function tearDown() {
    1111                parent::tearDown();
     12        }
     13
     14        function test_maybe_serialize_array_should_be_serialized()
     15        {
     16                $data = array();
     17
     18                $actual = maybe_serialize($data);
     19
     20                $this->assertTrue( is_string($data) );
     21                $this->assertEquals($actual, serialize($data) );
     22        }
     23
     24        function test_maybe_serialize_string_should_not_be_serialized()
     25        {
     26                $data = 'thisisatest';
     27
     28                $actual = maybe_serialize($data);
     29
     30                $this->assertEquals($actual, $data );
     31        }
     32
     33        function test_maybe_serialized_string_should_be_serialized()
     34        {
     35                $data = serialize(array());
     36               
     37                $actual = maybe_serialize($data);
     38               
     39                $this->assertEquals($actual, serialize($data) );
     40        }
     41
     42        function test_maybe_serialize_integer_should_not_be_serialized()
     43        {
     44                $data = 10;
     45               
     46                $actual = maybe_serialize($data);
     47               
     48                $this->assertEquals($actual, $data );
    1249        }
    1350
    1451        function test_wp_parse_args_object() {
     
    1956                $this->assertEquals(array('_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x')), wp_parse_args($x));
    2057                $y = new MockClass;
    2158                $this->assertEquals(array(), wp_parse_args($y));
    22         }
     59        }
     60
    2361        function test_wp_parse_args_array()  {
    2462                // arrays
    2563                $a = array();
    2664                $this->assertEquals(array(), wp_parse_args($x));
    2765                $b = array('_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x'));
    2866                $this->assertEquals(array('_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x')), wp_parse_args($b));
    29         }
     67        }
     68
    3069        function test_wp_parse_args_defaults() {
    3170                $x = new MockClass;
    3271                $x->_baba = 5;
     
    3675                $this->assertEquals(array('pu' => 'bu', '_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x')), wp_parse_args($x, $d));
    3776                $e = array('_baba' => 6);
    3877                $this->assertEquals(array('_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x')), wp_parse_args($x, $e));
    39         }
     78        }
     79
    4080        function test_wp_parse_args_other() {
    4181                $b = true;
    4282                wp_parse_str($b, $s);
     
    4484                $q = 'x=5&_baba=dudu&';
    4585                wp_parse_str($q, $ss);
    4686                $this->assertEquals($ss, wp_parse_args($q));
    47         }
     87        }
     88
    4889        function test_size_format() {
    4990                $this->knownWPBug(5246);
    5091                $kb = 1024;
     
    65106                $this->assertFalse(size_format('baba'));
    66107                $this->assertFalse(size_format(array()));
    67108        }
    68        
     109
    69110        function test_path_is_absolute() {
    70111                if ( !is_callable('path_is_absolute') )
    71112                        $this->markTestSkipped();
     
    106147                        $this->assertFalse( path_is_absolute($path), "path_is_absolute('$path') should return false" );
    107148        }
    108149
    109 
    110150        function test_wp_unique_filename() {
    111151                $this->knownWPBug(6294);       
    112152