gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

StringUtilSpec.php (2857B)


      1 <?php
      2 
      3 namespace spec\Prophecy\Util;
      4 
      5 use PhpSpec\ObjectBehavior;
      6 
      7 class StringUtilSpec extends ObjectBehavior
      8 {
      9     function it_generates_proper_string_representation_for_integer()
     10     {
     11         $this->stringify(42)->shouldReturn('42');
     12     }
     13 
     14     function it_generates_proper_string_representation_for_string()
     15     {
     16         $this->stringify('some string')->shouldReturn('"some string"');
     17     }
     18 
     19     function it_generates_single_line_representation_for_multiline_string()
     20     {
     21         $this->stringify("some\nstring")->shouldReturn('"some\\nstring"');
     22     }
     23 
     24     function it_generates_proper_string_representation_for_double()
     25     {
     26         $this->stringify(42.3)->shouldReturn('42.3');
     27     }
     28 
     29     function it_generates_proper_string_representation_for_boolean_true()
     30     {
     31         $this->stringify(true)->shouldReturn('true');
     32     }
     33 
     34     function it_generates_proper_string_representation_for_boolean_false()
     35     {
     36         $this->stringify(false)->shouldReturn('false');
     37     }
     38 
     39     function it_generates_proper_string_representation_for_null()
     40     {
     41         $this->stringify(null)->shouldReturn('null');
     42     }
     43 
     44     function it_generates_proper_string_representation_for_empty_array()
     45     {
     46         $this->stringify(array())->shouldReturn('[]');
     47     }
     48 
     49     function it_generates_proper_string_representation_for_array()
     50     {
     51         $this->stringify(array('zet', 42))->shouldReturn('["zet", 42]');
     52     }
     53 
     54     function it_generates_proper_string_representation_for_hash_containing_one_value()
     55     {
     56         $this->stringify(array('ever' => 'zet'))->shouldReturn('["ever" => "zet"]');
     57     }
     58 
     59     function it_generates_proper_string_representation_for_hash()
     60     {
     61         $this->stringify(array('ever' => 'zet', 52 => 'hey', 'num' => 42))->shouldReturn(
     62             '["ever" => "zet", 52 => "hey", "num" => 42]'
     63         );
     64     }
     65 
     66     function it_generates_proper_string_representation_for_resource()
     67     {
     68         $resource = fopen(__FILE__, 'r');
     69         $this->stringify($resource)->shouldReturn('stream:'.$resource);
     70     }
     71 
     72     /**
     73      * @param \stdClass $object
     74      */
     75     function it_generates_proper_string_representation_for_object($object)
     76     {
     77         $objHash = sprintf('%s:%s',
     78             get_class($object->getWrappedObject()),
     79             spl_object_hash($object->getWrappedObject())
     80         ) . " Object (\n    'objectProphecy' => Prophecy\Prophecy\ObjectProphecy Object (*Prophecy*)\n)";
     81 
     82         $this->stringify($object)->shouldReturn("$objHash");
     83     }
     84 
     85     /**
     86      * @param stdClass $object
     87      */
     88     function it_generates_proper_string_representation_for_object_without_exporting($object)
     89     {
     90         $objHash = sprintf('%s:%s',
     91             get_class($object->getWrappedObject()),
     92             spl_object_hash($object->getWrappedObject())
     93         );
     94 
     95         $this->stringify($object, false)->shouldReturn("$objHash");
     96     }
     97 }