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
baa133ec
Commit
baa133ec
authored
Dec 04, 2014
by
Robin Kunde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for calling empty() and isset() on result document properties
parent
6af1b2da
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
0 deletions
+47
-0
library/Solarium/Plugin/MinimumScoreFilter/Document.php
library/Solarium/Plugin/MinimumScoreFilter/Document.php
+11
-0
library/Solarium/QueryType/Select/Result/AbstractDocument.php
...ary/Solarium/QueryType/Select/Result/AbstractDocument.php
+14
-0
tests/Solarium/Tests/QueryType/Select/Result/AbstractDocumentTest.php
...um/Tests/QueryType/Select/Result/AbstractDocumentTest.php
+22
-0
No files found.
library/Solarium/Plugin/MinimumScoreFilter/Document.php
View file @
baa133ec
...
...
@@ -104,6 +104,17 @@ class Document implements \IteratorAggregate, \Countable, \ArrayAccess
return
$this
->
document
->
__get
(
$name
);
}
/**
* Forward isset call to the original document
*
* @param string $name
* @return boolean
*/
public
function
__isset
(
$name
)
{
return
$this
->
document
->
__isset
(
$name
);
}
/**
* IteratorAggregate implementation
*
...
...
library/Solarium/QueryType/Select/Result/AbstractDocument.php
View file @
baa133ec
...
...
@@ -78,6 +78,20 @@ abstract class AbstractDocument implements \IteratorAggregate, \Countable, \Arra
return
$this
->
fields
[
$name
];
}
/**
* Check if field is set by name
*
* Magic method for checking if fields are set as properties of this document
* object, by field name. Also used by empty().
*
* @param string $name
* @return boolean
*/
public
function
__isset
(
$name
)
{
return
isset
(
$this
->
fields
[
$name
]);
}
/**
* IteratorAggregate implementation
*
...
...
tests/Solarium/Tests/QueryType/Select/Result/AbstractDocumentTest.php
View file @
baa133ec
...
...
@@ -60,6 +60,28 @@ abstract class AbstractDocumentTest extends \PHPUnit_Framework_TestCase
);
}
public
function
testPropertyIsset
()
{
$this
->
assertTrue
(
isset
(
$this
->
doc
->
categories
)
);
$this
->
assertFalse
(
isset
(
$this
->
doc
->
invalidfieldname
)
);
}
public
function
testPropertyEmpty
()
{
$this
->
assertTrue
(
empty
(
$this
->
doc
->
empty_field
)
);
$this
->
assertFalse
(
empty
(
$this
->
doc
->
categories
)
);
}
public
function
testSetField
()
{
$this
->
setExpectedException
(
'Solarium\Exception\RuntimeException'
);
...
...
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