Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
5e1ba7ee
Commit
5e1ba7ee
authored
Feb 02, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for Solarium_Query_Select
parent
a4d959a2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
146 additions
and
39 deletions
+146
-39
tests/Solarium/Query/SelectTest.php
tests/Solarium/Query/SelectTest.php
+146
-39
No files found.
tests/Solarium/Query/SelectTest.php
View file @
5e1ba7ee
...
...
@@ -32,59 +32,173 @@
class
Solarium_Query_SelectTest
extends
PHPUnit_Framework_TestCase
{
public
function
testDummy
()
protected
$_query
;
public
function
setUp
()
{
$this
->
assertEquals
(
1
,
1
)
;
$this
->
_query
=
new
Solarium_Query_Select
;
}
/**
TODO testDefaultOptions
TODO testInitOptions
TODO testSetQueryWithEmptyQuery
TODO testSetQueryTrim
TODO testSetStartWithInvalidValues
TODO testSetAndGetStart
public
function
testSetAndGetStart
()
{
$this
->
_query
->
setStart
(
234
);
$this
->
assertEquals
(
234
,
$this
->
_query
->
getQuery
());
}
TODO testSetRowsWithInvalidValues
public
function
testSetAndGetQueryWithTrim
()
{
$this
->
_query
->
setQuery
(
' *:* '
);
$this
->
assertEquals
(
'*:*'
,
$this
->
_query
->
getStart
());
}
TODO testSetAndGetRows
public
function
testSetAndGetResultClass
()
{
$this
->
_query
->
setResultClass
(
'MyResult'
);
$this
->
assertEquals
(
'MyResult'
,
$this
->
_query
->
getResultClass
());
}
TODO testAddFieldWithInvalidValues
public
function
testSetAndGetDocumentClass
()
{
$this
->
_query
->
setDocumentClass
(
'MyDocument'
);
$this
->
assertEquals
(
'MyDocument'
,
$this
->
_query
->
getDocumentClass
());
}
TODO testAddField
public
function
testSetAndGetRows
()
{
$this
->
_query
->
setRows
(
100
);
$this
->
assertEquals
(
100
,
$this
->
_query
->
getRows
());
}
TODO testAddFieldsCommaSeparated
public
function
testAddField
()
{
$expectedFields
=
$this
->
_query
->
getFields
();
$expectedFields
[]
=
'newfield'
;
$this
->
assertEquals
(
$expectedFields
,
$this
->
_query
->
addField
(
'newfield'
));
}
TODO testAddFieldsArray
public
function
testClearFields
()
{
$this
->
_query
->
addField
(
'newfield'
);
$this
->
_query
->
clearFields
();
$this
->
assertEquals
(
array
(),
$this
->
_query
->
getFields
());
}
TODO testRemoveField
public
function
testAddFields
()
{
$fields
=
array
(
'field1'
,
'field2'
);
TODO testClearFields
$this
->
_query
->
clearFields
();
$this
->
_query
->
addFields
(
$fields
);
$this
->
assertEquals
(
$fields
,
$this
->
_query
->
getFields
());
}
TODO testSetFields
public
function
testAddFieldsAsStringWithTrim
()
{
$this
->
_query
->
clearFields
();
$this
->
_query
->
addFields
(
'field1, field2'
);
$this
->
assertEquals
(
array
(
'field1'
,
'field2'
),
$this
->
_query
->
getFields
());
}
TODO testAddSortFieldEmptyValue
public
function
testRemoveField
()
{
$this
->
_query
->
clearFields
();
$this
->
_query
->
addFields
(
array
(
'field1'
,
'field2'
));
$this
->
_query
->
removeField
(
'field1'
);
$this
->
assertEquals
(
array
(
'field2'
),
$this
->
_query
->
getFields
());
}
TODO testAddSortFieldInvalidOrder
public
function
testSetFields
()
{
$this
->
_query
->
clearFields
();
$this
->
_query
->
addFields
(
array
(
'field1'
,
'field2'
));
$this
->
_query
->
setFields
(
array
(
'field3'
,
'field4'
));
$this
->
assertEquals
(
array
(
'field3'
,
'field4'
),
$this
->
_query
->
getFields
());
}
TODO testAddSortField
public
function
testAddSortField
()
{
$this
->
_query
->
addSortField
(
'field1'
,
Solarium_Query_Select
::
SORT_DESC
);
$this
->
assertEquals
(
array
(
'field1'
=>
Solarium_Query_Select
::
SORT_DESC
),
$this
->
_query
->
getSortFields
()
);
}
TODO testAddSortFields
public
function
testAddSortFields
()
{
$sortFields
=
array
(
'field1'
=>
Solarium_Query_Select
::
SORT_DESC
,
'field2'
=>
Solarium_Query_Select
::
SORT_ASC
);
$this
->
_query
->
addSortFields
(
$sortFields
);
$this
->
assertEquals
(
$sortFields
,
$this
->
_query
->
getSortFields
()
);
}
TODO testRemoveSortField
public
function
testRemoveSortField
()
{
$sortFields
=
array
(
'field1'
=>
Solarium_Query_Select
::
SORT_DESC
,
'field2'
=>
Solarium_Query_Select
::
SORT_ASC
);
$this
->
_query
->
addSortFields
(
$sortFields
);
$this
->
_query
->
removeSortField
(
'field1'
);
$this
->
assertEquals
(
array
(
'field2'
=>
Solarium_Query_Select
::
SORT_ASC
),
$this
->
_query
->
getSortFields
()
);
}
TODO testRemoveInvalidSortField
public
function
testRemoveInvalidSortField
()
{
$sortFields
=
array
(
'field1'
=>
Solarium_Query_Select
::
SORT_DESC
,
'field2'
=>
Solarium_Query_Select
::
SORT_ASC
);
$this
->
_query
->
addSortFields
(
$sortFields
);
$this
->
_query
->
removeSortField
(
'invalidfield'
);
//continue silently
$this
->
assertEquals
(
$sortFields
,
$this
->
_query
->
getSortFields
()
);
}
TODO testClearSortFields
public
function
testClearSortFields
()
{
$sortFields
=
array
(
'field1'
=>
Solarium_Query_Select
::
SORT_DESC
,
'field2'
=>
Solarium_Query_Select
::
SORT_ASC
);
$this
->
_query
->
addSortFields
(
$sortFields
);
$this
->
_query
->
clearSortFields
();
$this
->
assertEquals
(
array
(),
$this
->
_query
->
getSortFields
()
);
}
TODO testSetSortFields
public
function
testSetSortFields
()
{
$sortFields
=
array
(
'field1'
=>
Solarium_Query_Select
::
SORT_DESC
,
'field2'
=>
Solarium_Query_Select
::
SORT_ASC
);
$this
->
_query
->
addSortFields
(
$sortFields
);
$this
->
_query
->
setSortFields
(
array
(
'field3'
=>
Solarium_Query_Select
::
SORT_ASC
));
$this
->
assertEquals
(
array
(
'field3'
=>
Solarium_Query_Select
::
SORT_ASC
),
$this
->
_query
->
getSortFields
()
);
}
TODO testAddFilterQueryEmptyInput
/**
TODO testAddFilterQuery
...
...
@@ -102,12 +216,5 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
TODO testSetFilterQueries
TODO testSetAndGetResultClass
TODO testSetAndGetDocumentClass
TODO testCustomResultClass
TODO testCustomDocumentClass
*/
}
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