Passed
Branch stable (668427)
by Nuno
04:13 queued 01:26
created

ArgumentFormatterTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 42
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Tests\Unit;
4
5
use PHPUnit\Framework\TestCase;
6
use NunoMaduro\Collision\ArgumentFormatter;
7
use NunoMaduro\Collision\Contracts\ArgumentFormatter as ArgumentFormatterContract;
8
9
class ArgumentFormatterTest extends TestCase
10
{
11
    /** @test */
12
    public function it_respects_is_contract(): void
13
    {
14
        $this->assertInstanceOf(ArgumentFormatterContract::class, new ArgumentFormatter());
15
    }
16
17
    /** @test */
18
    public function it_formats_a_string(): void
19
    {
20
        $argumentFormatter = new ArgumentFormatter();
21
22
        $args = ['string' => 'foo'];
23
24
        $result = $argumentFormatter->format($args);
25
26
        $this->assertEquals($result, '"foo"');
27
    }
28
29
    /** @test */
30
    public function it_formats_a_array(): void
31
    {
32
        $argumentFormatter = new ArgumentFormatter();
33
34
        $args = ['array' => ['foo' => 'bar', 'key' => 'value']];
35
36
        $result = $argumentFormatter->format($args);
37
38
        $this->assertEquals($result, '["bar", "value"]');
39
    }
40
41
    /** @test */
42
    public function it_formats_a_object(): void
43
    {
44
        $argumentFormatter = new ArgumentFormatter();
45
46
        $object = new \stdClass();
47
48
        $result = $argumentFormatter->format([$object]);
49
50
        $this->assertEquals($result, 'Object(stdClass)');
51
    }
52
}
53