Passed
Push — master ( 383493...d29574 )
by Chito
02:01
created

TestCase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
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 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A assertSqlEquals() 0 4 1
A assertJsonEquals() 0 3 1
1
<?php
2
3
namespace Lampager\Cake\Test\TestCase;
4
5
use Cake\TestSuite\TestCase as BaseTestCase;
6
use NilPortugues\Sql\QueryFormatter\Formatter;
7
8
abstract class TestCase extends BaseTestCase
9
{
10
    /**
11
     * Asserts that two given JSON encoded objects or arrays are equal.
12
     *
13
     * @param  mixed                                                        $expected
14
     * @param  mixed                                                        $actual
15
     * @param  string                                                       $message
16
     * @return void
17
     * @throws \PHPUnit\Framework\ExpectationFailedException
18
     * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
19
     */
20
    public function assertJsonEquals($expected, $actual, $message = '')
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
     * @param  string $expected
29
     * @param  string $actual
30
     * @param  string $message
31
     * @return void
32
     */
33
    public function assertSqlEquals($expected, $actual, $message = '')
34
    {
35
        $formatter = new Formatter();
36
        $this->assertSame($formatter->format($expected), $formatter->format($actual), $message);
37
    }
38
}
39