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
bb26c423
Commit
bb26c423
authored
Mar 30, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added array implementation to ReadWrite document
- updated ReadWrite document unittest
parent
9959cad4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
4 deletions
+48
-4
library/Solarium/Client/Adapter/ZendHttp.php
library/Solarium/Client/Adapter/ZendHttp.php
+1
-2
library/Solarium/Document/ReadWrite.php
library/Solarium/Document/ReadWrite.php
+8
-2
tests/Solarium/Document/ReadWriteTest.php
tests/Solarium/Document/ReadWriteTest.php
+39
-0
No files found.
library/Solarium/Client/Adapter/ZendHttp.php
View file @
bb26c423
...
...
@@ -86,8 +86,7 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter_Http
);
// forward adapter options if available
if
(
isset
(
$this
->
_options
[
'adapteroptions'
]))
{
if
(
isset
(
$this
->
_options
[
'adapteroptions'
]))
{
$this
->
_zendHttp
->
setConfig
(
$this
->
_options
[
'adapteroptions'
]);
}
}
...
...
library/Solarium/Document/ReadWrite.php
View file @
bb26c423
...
...
@@ -202,13 +202,19 @@ class Solarium_Document_ReadWrite extends Solarium_Document_ReadOnly
* Magic method for setting fields as properties of this document
* object, by field name.
*
* If you supply NULL as the value the field will be removed
*
* @param string $name
* @param string $value
* @param string
|null
$value
* @return void
*/
public
function
__set
(
$name
,
$value
)
{
$this
->
setField
(
$name
,
$value
);
if
(
$value
==
null
)
{
$this
->
removeField
(
$name
);
}
else
{
$this
->
setField
(
$name
,
$value
);
}
}
}
\ No newline at end of file
tests/Solarium/Document/ReadWriteTest.php
View file @
bb26c423
...
...
@@ -141,6 +141,19 @@ class Solarium_Document_ReadWriteTest extends PHPUnit_Framework_TestCase
);
}
public
function
testRemoveFieldBySettingToNull
()
{
$this
->
_doc
->
setField
(
'name'
,
NULL
);
$expectedFields
=
$this
->
_fields
;
unset
(
$expectedFields
[
'name'
]);
$this
->
assertEquals
(
$expectedFields
,
$this
->
_doc
->
getFields
()
);
}
public
function
testRemoveFieldBoostRemoval
()
{
$this
->
_doc
->
setFieldBoost
(
'name'
,
3.2
);
...
...
@@ -198,5 +211,31 @@ class Solarium_Document_ReadWriteTest extends PHPUnit_Framework_TestCase
$this
->
_doc
->
name
);
}
public
function
testSetFieldAsArray
()
{
$this
->
_doc
[
'name'
]
=
'newname'
;
$expectedFields
=
$this
->
_fields
;
$expectedFields
[
'name'
]
=
'newname'
;
$this
->
assertEquals
(
$expectedFields
,
$this
->
_doc
->
getFields
()
);
}
public
function
testRemoveFieldAsArray
()
{
unset
(
$this
->
_doc
[
'name'
]);
$expectedFields
=
$this
->
_fields
;
unset
(
$expectedFields
[
'name'
]);
$this
->
assertEquals
(
$expectedFields
,
$this
->
_doc
->
getFields
()
);
}
}
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