Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit 4d282c4

Browse files
committed
add tests for dumpProperties
1 parent 5b0dfbe commit 4d282c4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/RecursiveClassDumpTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace MichaelRubel\LoopFunctions\Tests;
4+
5+
use Illuminate\Support\Collection;
6+
use MichaelRubel\LoopFunctions\Tests\Boilerplate\TestClass;
7+
8+
class RecursiveClassDumpTest extends TestCase
9+
{
10+
/** @test */
11+
public function testCanDumpClassProperties()
12+
{
13+
$properties = app(TestClass::class)->dumpProperties();
14+
15+
$this->assertTrue($properties['bool']);
16+
$this->assertStringContainsString( 'new string', $properties['string']);
17+
$this->assertArrayHasKey('array', $properties['array']);
18+
$this->assertTrue($properties['collection']->isEmpty());
19+
$this->assertArrayHasKey('static', $properties['static']);
20+
21+
$this->assertNull($properties['nullable_string']);
22+
$this->assertNull($properties['nullable_array']);
23+
$this->assertNull($properties['nullable_collection']);
24+
$this->assertNull($properties['nullable_static_array']);
25+
}
26+
27+
/** @test */
28+
public function testCanDumpPassedObjectProperties()
29+
{
30+
$properties = app(TestClass::class)->dumpProperties(Collection::class);
31+
32+
$this->assertArrayHasKey('items', $properties);
33+
$this->assertArrayHasKey('escapeWhenCastingToString', $properties);
34+
$this->assertFalse($properties['escapeWhenCastingToString']);
35+
}
36+
}

0 commit comments

Comments
 (0)