Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
82f3ae52
Commit
82f3ae52
authored
Jul 27, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new tests for search query language
parent
5b611b53
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
17 deletions
+41
-17
QueryTestCase.php
tests/Search/QueryTestCase.php
+41
-17
No files found.
tests/Search/QueryTestCase.php
View file @
82f3ae52
...
...
@@ -35,7 +35,7 @@ class Doctrine_Search_Query_TestCase extends Doctrine_UnitTestCase
public
function
prepareTables
()
{
$this
->
tables
=
array
(
'SearchTest'
,
'SearchTestIndex'
);
parent
::
prepareTables
();
}
public
function
prepareData
()
...
...
@@ -63,7 +63,7 @@ class Doctrine_Search_Query_TestCase extends Doctrine_UnitTestCase
$q
=
new
Doctrine_Search_Query
(
'SearchTestIndex'
);
$ret
=
$q
->
tokenizeClause
(
'doctrine AND orm'
);
$this
->
assertEqual
(
$ret
,
array
(
'doctrine'
,
'orm'
));
}
...
...
@@ -91,7 +91,7 @@ class Doctrine_Search_Query_TestCase extends Doctrine_UnitTestCase
$q
=
new
Doctrine_Search_Query
(
'SearchTestIndex'
);
$ret
=
$q
->
tokenizeClause
(
'doctrine OR orm dbal AND database OR rdbms'
);
print_r
(
$ret
);
$expected
=
array
(
array
(
'doctrine'
,
'orm'
),
'dbal'
,
array
(
'database'
,
'rdbms'
));
$this
->
assertEqual
(
$ret
,
$expected
);
...
...
@@ -106,27 +106,38 @@ class Doctrine_Search_Query_TestCase extends Doctrine_UnitTestCase
$this
->
assertEqual
(
$ret
,
$expected
);
}
/**
public
function
testParseClauseSupportsAndOperator
()
{
$q
=
new
Doctrine_Search_Query
(
'SearchTestIndex'
);
$ret
=
$q
->
parseClause
(
'doctrine AND orm'
);
$sql = 'search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?) '
. 'AND search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?)';
$sql
=
'(search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?)) '
.
'AND (search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?))'
;
$this
->
assertEqual
(
$ret
,
$sql
);
}
public
function
testParseClauseSupportsMixingOfOperatorsAndParenthesis
()
{
$q
=
new
Doctrine_Search_Query
(
'SearchTestIndex'
);
$ret
=
$q
->
parseClause
(
'((doctrine OR orm) AND dbal) OR database'
);
$sql
=
'(search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ? OR keyword = ?)) '
.
'AND (search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?))'
.
' OR keyword = ?'
;
$this
->
assertEqual
(
$ret
,
$sql
);
}
public
function
testParseClauseSupportsMixingOfOperators3
()
{
$q
=
new
Doctrine_Search_Query
(
'SearchTestIndex'
);
$ret
=
$q
->
parseClause
(
'doctrine OR orm AND dbal'
);
$sql = '
search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ? OR keyword = ?
) '
. 'AND
search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?
)';
$sql
=
'
(search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ? OR keyword = ?)
) '
.
'AND
(search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?)
)'
;
$this
->
assertEqual
(
$ret
,
$sql
);
}
...
...
@@ -135,9 +146,9 @@ class Doctrine_Search_Query_TestCase extends Doctrine_UnitTestCase
$q
=
new
Doctrine_Search_Query
(
'SearchTestIndex'
);
$ret
=
$q
->
parseClause
(
'(doctrine OR orm) AND dbal'
);
$sql = '
search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ? OR keyword = ?
) '
. 'AND
search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?
)';
$sql
=
'
(search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ? OR keyword = ?)
) '
.
'AND
(search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?)
)'
;
$this
->
assertEqual
(
$ret
,
$sql
);
}
...
...
@@ -145,13 +156,26 @@ class Doctrine_Search_Query_TestCase extends Doctrine_UnitTestCase
{
$q
=
new
Doctrine_Search_Query
(
'SearchTestIndex'
);
$ret
=
$q
->
parseClause
(
'(doctrine OR orm) dbal'
);
print $ret;
$sql = 'search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ? OR keyword = ?) '
. 'AND search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?)';
$sql
=
'(search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ? OR keyword = ?)) '
.
'AND (search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?))'
;
$this
->
assertEqual
(
$ret
,
$sql
);
}
public
function
testParseClauseSupportsMixingOfOperatorsAndDeeplyNestedParenthesis
()
{
$q
=
new
Doctrine_Search_Query
(
'SearchTestIndex'
);
$ret
=
$q
->
parseClause
(
'(((doctrine OR orm) AND dbal) OR database) AND rdbms'
);
$sql
=
'((search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ? OR keyword = ?)) '
.
'AND (search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?))'
.
' OR keyword = ?) AND (search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?))'
;
$this
->
assertEqual
(
$ret
,
$sql
);
}
/**
public function testSearchSupportsAndOperator()
{
$q = new Doctrine_Search_Query('SearchTestIndex');
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment