TestCase   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
eloc 4
c 2
b 1
f 0
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A assertJsonEquals() 0 3 1
A assertSqlEquals() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lampager\Cake\Test\TestCase;
6
7
use Cake\TestSuite\TestCase as BaseTestCase;
8
use NilPortugues\Sql\QueryFormatter\Formatter;
9
10
abstract class TestCase extends BaseTestCase
11
{
12
    /**
13
     * Asserts that two given JSON encoded objects or arrays are equal.
14
     *
15
     * @param  mixed                                                        $expected
16
     * @param  mixed                                                        $actual
17
     * @throws \PHPUnit\Framework\ExpectationFailedException
18
     * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
19
     */
20
    public function assertJsonEquals($expected, $actual, string $message = ''): void
21
    {
22
        $this->assertJsonStringEqualsJsonString(json_encode($expected), json_encode($actual), $message);
23
    }
24
25
    /**
26
     * Asserts that two given SQL query statements are equal.
27
     */
28
    public function assertSqlEquals(string $expected, string $actual, string $message = ''): void
29
    {
30
        $formatter = new Formatter();
31
        $this->assertSame($formatter->format($expected), $formatter->format($actual), $message);
32
    }
33
}
34