Skip to content

Commit

Permalink
set key-field for documents
Browse files Browse the repository at this point in the history
  • Loading branch information
floriansemm committed Jul 24, 2015
1 parent 4e9c38c commit eb6dbea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Doctrine/Mapper/Mapping/AbstractDocumentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public function createDocument(MetaInformationInterface $meta)
{
$document = new Document();

$document->addField('id', $meta->getEntityId());
$document->addField('document_name_s', $meta->getDocumentName());
$key = $meta->getDocumentName() . '_' . $meta->getEntityId();
$document->setKey('id', $key);

$document->setBoost($meta->getBoost());

return $document;
Expand Down
4 changes: 2 additions & 2 deletions Tests/Doctrine/Mapper/Mapping/MapIdentifierCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function testCreateDocument_DocumentHasOnlyIdAndNameField()

$document = $command->createDocument(MetaTestInformationFactory::getMetaInformation());

$this->assertEquals(2, $document->count(), 'fieldcount is two');
$this->assertEquals(2, $document->id, 'id is 2');
$this->assertEquals(1, $document->count(), 'fieldcount is two');
$this->assertEquals('validtestentity_2', $document->id, 'id is 2');

}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Doctrine/Mapper/Mapping/SolrDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

abstract class SolrDocumentTest extends \PHPUnit_Framework_TestCase
{
const FIELDS_ALWAYS_MAPPED = 2;
const FIELDS_ALWAYS_MAPPED = 1;

protected function assertHasDocumentFields(Document $document, $expectedFields)
{
Expand Down

0 comments on commit eb6dbea

Please sign in to comment.