/** * @group unit */ public function testSetIndex() { $document = new Document(); $document->setIndex('index2'); $document->setType('type2'); $this->assertEquals('index2', $document->getIndex()); $this->assertEquals('type2', $document->getType()); $index = new Index($this->_getClient(), 'index'); $document->setIndex($index); $this->assertEquals('index', $document->getIndex()); $this->assertEquals('type2', $document->getType()); }
/** * DocumentFactory constructor. * * @param Document $prototype */ public function __construct(Document $prototype) { if ($prototype->getIndex() === '' || $prototype->getType() === '') { throw new \InvalidArgumentException('prototype not properly inited'); } $this->docPrototype = $prototype; $fieldValuePairs = get_object_vars(new User()); array_walk($fieldValuePairs, function ($value, $field) { $this->fieldList[$field] = gettype($value); }); }