コード例 #1
0
 /**
  * Sets pair value. Returns pair with values.
  *
  * @param string $key
  * @param mixed  $value
  *
  * @return DocumentInterface
  */
 public function set($key, $value)
 {
     $pair = $this->repository->find($key);
     if ($pair === null) {
         $pair = new Pair();
         $pair->setId($key);
     }
     $pair->setValue($value);
     $this->save($pair);
     return $pair;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->manager = $this->getServiceContainer()->get('es.manager');
     $this->manager->getConnection()->dropAndCreateIndex();
     // There is something wrong with ElasticsearchTestCase method getDataArray,
     // if we don't create in here all test data, it's not existing when test is run.
     $content = new Pair();
     $content->setId('name0');
     $content->setValue('will not be here');
     $this->manager->persist($content);
     $this->manager->commit();
 }
コード例 #3
0
 /**
  * Test for remove().
  */
 public function testRemove()
 {
     $pair = new Pair();
     $pair->setId('demo');
     $pair->setValue('demo value');
     $ormManagerMock = $this->getOrmManagerMock();
     $repositoryMock = $this->getOrmRepositoryMock();
     $repositoryMock->expects($this->once())->method('find')->willReturn($pair);
     $repositoryMock->expects($this->once())->method('remove')->with($pair->getId());
     $ormManagerMock->expects($this->once())->method('getRepository')->willReturn($repositoryMock);
     $ormManagerMock->expects($this->once())->method('flush');
     $ormManagerMock->expects($this->once())->method('refresh');
     $pairStorage = $this->getPairStorage($ormManagerMock);
     $pairStorage->remove('demo');
 }