@@ -14,46 +14,32 @@ public function __toString()
14
14
15
15
class StringSpec extends ObjectBehavior
16
16
{
17
- function it_convert_double_to_string ()
17
+ /**
18
+ * @dataProvider positiveConversionExamples
19
+ */
20
+ function it_convert_values_to_string ($ value , $ expectedValue )
18
21
{
19
- $ this ->beConstructedWith (1.1 );
20
- $ this ->__toString ()->shouldReturn (' 1.1 ' );
22
+ $ this ->beConstructedWith ($ value );
23
+ $ this ->__toString ()->shouldReturn ($ expectedValue );
21
24
}
22
25
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 ()
30
27
{
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
+ );
33
37
}
34
38
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 ()
54
40
{
55
- $ this ->beConstructedWith (array ( ' foo ' , 'bar ' ) );
56
- $ this ->__toString ()->shouldReturn ('Array(2) ' );
41
+ $ this ->beConstructedWith (1.1 , 'pl ' );
42
+ $ this ->__toString ()->shouldReturn ('1,1 ' );
57
43
}
58
44
59
45
function it_convert_resource_to_string ()
@@ -64,11 +50,4 @@ function it_convert_resource_to_string()
64
50
fclose ($ resource );
65
51
unlink (sys_get_temp_dir () . "/foo " );
66
52
}
67
-
68
- function it_convert_callback_string ()
69
- {
70
- $ func = function () {return 'test ' ;};
71
- $ this ->beConstructedWith ($ func );
72
- $ this ->__toString ()->shouldReturn ('\Closure ' );
73
- }
74
53
}
0 commit comments