|
| 1 | +<?php |
| 2 | + |
| 3 | +class GetDumpTest extends TestCase |
| 4 | +{ |
| 5 | + /** @test */ |
| 6 | + public function it_correctly_dumps_null() |
| 7 | + { |
| 8 | + $this->assertEquals("null\n", get_dump(null)); |
| 9 | + } |
| 10 | + |
| 11 | + /** @test */ |
| 12 | + public function it_correctly_dumps_boolean_true() |
| 13 | + { |
| 14 | + $this->assertEquals("true\n", get_dump(true)); |
| 15 | + } |
| 16 | + |
| 17 | + /** @test */ |
| 18 | + public function it_correctly_dumps_boolean_false() |
| 19 | + { |
| 20 | + $this->assertEquals("false\n", get_dump(false)); |
| 21 | + } |
| 22 | + |
| 23 | + /** @test */ |
| 24 | + public function it_correctly_dumps_integer() |
| 25 | + { |
| 26 | + $this->assertEquals("123\n", get_dump(123)); |
| 27 | + } |
| 28 | + |
| 29 | + /** @test */ |
| 30 | + public function it_correctly_dumps_float() |
| 31 | + { |
| 32 | + $this->assertEquals("123.45\n", get_dump(123.45)); |
| 33 | + } |
| 34 | + |
| 35 | + /** @test */ |
| 36 | + public function it_correctly_dumps_string() |
| 37 | + { |
| 38 | + $this->assertEquals("\"some string to dump\"\n", get_dump('some string to dump')); |
| 39 | + } |
| 40 | + |
| 41 | + /** @test */ |
| 42 | + public function it_correctly_dumps_array() |
| 43 | + { |
| 44 | + $array = [ |
| 45 | + 'a simple string' => 'in an array of 5 elements', |
| 46 | + 'a float' => 1.0, |
| 47 | + 'an integer' => 1, |
| 48 | + 'a boolean' => true, |
| 49 | + 'an empty array' => [], |
| 50 | + ]; |
| 51 | + |
| 52 | + $expected = "array:5 [\n" |
| 53 | + . " \"a simple string\" => \"in an array of 5 elements\"\n" |
| 54 | + . " \"a float\" => 1.0\n" |
| 55 | + . " \"an integer\" => 1\n" |
| 56 | + . " \"a boolean\" => true\n" |
| 57 | + . " \"an empty array\" => []\n" |
| 58 | + . "]\n" |
| 59 | + ; |
| 60 | + |
| 61 | + $this->assertEquals($expected, get_dump($array)); |
| 62 | + } |
| 63 | +} |
0 commit comments