setSerializer() public method

Sets the serializer callable used in addObject.
See also: Elastica\Type::addObject
public setSerializer ( array | string $serializer )
$serializer array | string @see \Elastica\Type::_serializer
Beispiel #1
0
 /**
  * @group functional
  */
 public function testAddObject()
 {
     $index = $this->_createIndex();
     $type = new Type($index, 'user');
     $type->setSerializer('get_object_vars');
     $userObject = new \stdClass();
     $userObject->username = '******';
     $userObject->test = array('2', '3', '5');
     $type->addObject($userObject);
     $index->refresh();
     $resultSet = $type->search('hans');
     $this->assertEquals(1, $resultSet->count());
     // Test if source is returned
     $result = $resultSet->current();
     $data = $result->getData();
     $this->assertEquals('hans', $data['username']);
 }