TestCase::assertSqlEquals()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 2
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 3
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