public function testFind()
 {
     // Easter
     $this->assertEquals('Easter', $this->repo->find('Easter')->name());
     $easter = new Yearwheel('Easter');
     $this->assertTrue($easter->equals($this->repo->find('Easter')));
     // Christmas
     $this->assertEquals('Christmas', $this->repo->find('Christmas')->name());
     // Summer
     $this->assertEquals('Summer', $this->repo->find('Summer')->name());
     // Winter
     $this->assertEquals('Winter', $this->repo->find('Winter')->name());
     $this->assertEquals(new Yearwheel('Winter'), $this->repo->find('Winter'));
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function transform(Document $document)
 {
     try {
         $entity = $document->currentEntity();
     } catch (\RuntimeException $e) {
         $entity = $document->createEntity('entity', 'profile');
         $document->appendEntity($entity);
     }
     if ($this->yearwheel instanceof Yearwheel) {
         $entity->addProperty($document->createProperty('yearwheel', 'string', $this->yearwheel->name()));
     }
     if ($this->tags && $this->tags->count()) {
         $entity->addProperty($document->createProperty('tags', 'string', implode(', ', $this->tags->toArray())));
     }
 }