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
af7e6f04
Commit
af7e6f04
authored
Mar 30, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added unset property option to ReadWrite document
- updated ReadWrite unittest
parent
3f84f73e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
library/Solarium/Autoloader.php
library/Solarium/Autoloader.php
+1
-1
library/Solarium/Document/ReadWrite.php
library/Solarium/Document/ReadWrite.php
+13
-0
tests/Solarium/Document/ReadWriteTest.php
tests/Solarium/Document/ReadWriteTest.php
+13
-0
No files found.
library/Solarium/Autoloader.php
View file @
af7e6f04
...
@@ -75,7 +75,7 @@ class Solarium_Autoloader
...
@@ -75,7 +75,7 @@ class Solarium_Autoloader
*/
*/
static
public
function
load
(
$class
)
static
public
function
load
(
$class
)
{
{
if
(
substr
(
$class
,
0
,
8
)
==
'Solarium'
)
{
if
(
substr
(
$class
,
0
,
8
)
==
'Solarium'
)
{
$class
=
str_replace
(
$class
=
str_replace
(
array
(
'Solarium'
,
'_'
),
array
(
'Solarium'
,
'_'
),
...
...
library/Solarium/Document/ReadWrite.php
View file @
af7e6f04
...
@@ -218,4 +218,17 @@ class Solarium_Document_ReadWrite extends Solarium_Document_ReadOnly
...
@@ -218,4 +218,17 @@ class Solarium_Document_ReadWrite extends Solarium_Document_ReadOnly
$this
->
setField
(
$name
,
$value
);
$this
->
setField
(
$name
,
$value
);
}
}
/**
* Unset field value
*
* Magic method for removing fields by unsetting object properties
*
* @param string $name
* @return void
*/
public
function
__unset
(
$name
)
{
$this
->
removeField
(
$name
);
}
}
}
\ No newline at end of file
tests/Solarium/Document/ReadWriteTest.php
View file @
af7e6f04
...
@@ -212,6 +212,19 @@ class Solarium_Document_ReadWriteTest extends PHPUnit_Framework_TestCase
...
@@ -212,6 +212,19 @@ class Solarium_Document_ReadWriteTest extends PHPUnit_Framework_TestCase
);
);
}
}
public
function
testUnsetFieldByProperty
()
{
unset
(
$this
->
_doc
->
name
);
$expectedFields
=
$this
->
_fields
;
unset
(
$expectedFields
[
'name'
]);
$this
->
assertEquals
(
$expectedFields
,
$this
->
_doc
->
getFields
()
);
}
public
function
testSetFieldAsArray
()
public
function
testSetFieldAsArray
()
{
{
$this
->
_doc
[
'name'
]
=
'newname'
;
$this
->
_doc
[
'name'
]
=
'newname'
;
...
...
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