Skip to content

Commit 4c1338e

Browse files
committed
handle more edge cases for the whitespace checks
1 parent 5c0c1d5 commit 4c1338e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

tests/06_Query/QOM/Sql2ToQomConverterTest.php

+16-3
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,30 @@ public function testQueries()
7676
}
7777
}
7878

79-
public function testPropertyComparisonWithWhitespace()
79+
public function getSQL2WithWhitespace()
8080
{
81-
$sql2 = 'SELECT * FROM [nt:file] WHERE prop1 = "Foo bar"';
81+
return array(
82+
array('SELECT * FROM [nt:file] WHERE prop1 = "Foo bar"', 'Foo bar'),
83+
array('SELECT * FROM [nt:file] WHERE prop1 = "Foo bar"', 'Foo bar'),
84+
array('SELECT * FROM [nt:file] WHERE prop1 = "Foo\tbar"', 'Foo\tbar'),
85+
array('SELECT * FROM [nt:file] WHERE prop1 = "Foo\n\tbar"', 'Foo\nbar'),
86+
array('SELECT * FROM [nt:file] WHERE prop1 = "Foo \t bar"', 'Foo \t bar'),
87+
array('SELECT * FROM [nt:file] WHERE prop1 = "Foo \t \n bar"', 'Foo \t \n bar'),
88+
);
89+
}
8290

91+
/**
92+
* @dataProvider getSQL2WithWhitespace
93+
*/
94+
public function testPropertyComparisonWithWhitespace($sql2, $literal)
95+
{
8396
$qom = $this->parser->parse($sql2);
8497

8598
$this->assertInstanceOf('PHPCR\Query\QOM\ComparisonInterface', $qom->getConstraint());
8699
$this->assertInstanceOf('PHPCR\Query\QOM\PropertyValueInterface', $qom->getConstraint()->getOperand1());
87100
$this->assertInstanceOf('PHPCR\Query\QOM\LiteralInterface', $qom->getConstraint()->getOperand2());
88101

89102
$this->assertEquals('prop1', $qom->getConstraint()->getOperand1()->getPropertyName());
90-
$this->assertEquals('Foo bar', $qom->getConstraint()->getOperand2()->getLiteralValue());
103+
$this->assertEquals($literal, $qom->getConstraint()->getOperand2()->getLiteralValue());
91104
}
92105
}

0 commit comments

Comments
 (0)