@@ -14,46 +14,32 @@ public function __toString()
1414
1515class StringSpec extends ObjectBehavior
1616{
17- function it_convert_double_to_string ()
17+ /**
18+ * @dataProvider positiveConversionExamples
19+ */
20+ function it_convert_values_to_string ($ value , $ expectedValue )
1821 {
19- $ this ->beConstructedWith (1.1 );
20- $ this ->__toString ()->shouldReturn (' 1.1 ' );
22+ $ this ->beConstructedWith ($ value );
23+ $ this ->__toString ()->shouldReturn ($ expectedValue );
2124 }
2225
23- function it_convert_double_to_string_for_specific_locale ()
24- {
25- $ this ->beConstructedWith (1.1 , 'pl ' );
26- $ this ->__toString ()->shouldReturn ('1,1 ' );
27- }
28-
29- function it_convert_integer_to_string ()
26+ function positiveConversionExamples ()
3027 {
31- $ this ->beConstructedWith (20 );
32- $ this ->__toString ()->shouldReturn ('20 ' );
28+ return array (
29+ array (1.1 , '1.1 ' ),
30+ array (20 , '20 ' ),
31+ array (true , 'true ' ),
32+ array (new \stdClass (), '\stdClass ' ),
33+ array (new Foo (), 'This is Foo ' ),
34+ array (array ('foo ' , 'bar ' ), 'Array(2) ' ),
35+ array (function () {return 'test ' ;}, '\Closure ' )
36+ );
3337 }
3438
35- function it_convert_boolean_to_string ()
36- {
37- $ this ->beConstructedWith (true );
38- $ this ->__toString ()->shouldReturn ('true ' );
39- }
40-
41- function it_convert_object_to_string ()
42- {
43- $ this ->beConstructedWith (new \stdClass ());
44- $ this ->__toString ()->shouldReturn ('\stdClass ' );
45- }
46-
47- function it_convert_object_with_toString_method_to_string ()
48- {
49- $ this ->beConstructedWith (new Foo ());
50- $ this ->__toString ()->shouldReturn ('This is Foo ' );
51- }
52-
53- function it_convert_array_to_string ()
39+ function it_convert_double_to_string_for_specific_locale ()
5440 {
55- $ this ->beConstructedWith (array ( ' foo ' , 'bar ' ) );
56- $ this ->__toString ()->shouldReturn ('Array(2) ' );
41+ $ this ->beConstructedWith (1.1 , 'pl ' );
42+ $ this ->__toString ()->shouldReturn ('1,1 ' );
5743 }
5844
5945 function it_convert_resource_to_string ()
@@ -64,11 +50,4 @@ function it_convert_resource_to_string()
6450 fclose ($ resource );
6551 unlink (sys_get_temp_dir () . "/foo " );
6652 }
67-
68- function it_convert_callback_string ()
69- {
70- $ func = function () {return 'test ' ;};
71- $ this ->beConstructedWith ($ func );
72- $ this ->__toString ()->shouldReturn ('\Closure ' );
73- }
7453}
0 commit comments