QueryFormatterTest::testFormat()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Asparagus\Tests;
4
5
use Asparagus\QueryFormatter;
6
7
/**
8
 * @covers Asparagus\QueryFormatter
9
 *
10
 * @license GNU GPL v2+
11
 * @author Bene* < [email protected] >
12
 */
13
class QueryFormatterTest extends \PHPUnit_Framework_TestCase {
14
15
	/**
16
	 * @dataProvider provideTestFormat
17
	 */
18
	public function testFormat( $expected, $input ) {
19
		$formatter = new QueryFormatter();
20
21
		$this->assertEquals( $expected, $formatter->format( $input ) );
22
	}
23
24
	public function provideTestFormat() {
25
		return array(
26
			'new line before prefix' => array( "PREFIX abc\nPREFIX\n", 'PREFIX abc PREFIX' ),
27
			'new lines before select' => array( "foobar\n\nSELECT xyz\n", 'foobar SELECT xyz' ),
28
			'new line after brackets' => array( "abc {\n}\ndef\n", 'abc { } def' ),
29
			'indentation by brackets' => array( "{\n\t{\n\t\tfoobar .\n\t}\n\tnyan .\n}\n", '{ { foobar . } nyan . }' ),
30
			'strings get escaped' => array( '"abc { def } hij" <abc { xyy > <"a{2>' . "\n", '"abc { def } hij" <abc { xyy > <"a{2>' ),
31
			'spaces before characters' => array( "a .\nb =c (d <e {\n\tf ?g \$h\n", 'a.b=c(d<e{f?g$h' )
32
		);
33
	}
34
35
}
36