/**
  * Helper function to add expectations to the mock entity query object.
  *
  * @param int $count
  *   The number of deduplications to be set up.
  */
 protected function entityQueryExpects($count)
 {
     $this->entityQuery->expects($this->exactly($count + 1))->method('condition')->will($this->returnValue($this->entityQuery));
     $this->entityQuery->expects($this->exactly($count + 1))->method('count')->will($this->returnValue($this->entityQuery));
     $this->entityQuery->expects($this->exactly($count + 1))->method('execute')->will($this->returnCallback(function () use(&$count) {
         return $count--;
     }));
 }
 /**
  * Tests the getDefaultSearchPage() method when the default is inactive.
  */
 public function testGetDefaultSearchPageWithInactiveDefault()
 {
     $this->query->expects($this->once())->method('condition')->with('status', TRUE)->will($this->returnValue($this->query));
     $this->query->expects($this->once())->method('execute')->will($this->returnValue(array('test' => 'test')));
     $config = $this->getMockBuilder('Drupal\\Core\\Config\\Config')->disableOriginalConstructor()->getMock();
     $config->expects($this->once())->method('get')->with('default_page')->will($this->returnValue('other_test'));
     $this->configFactory->expects($this->once())->method('get')->with('search.settings')->will($this->returnValue($config));
     $this->assertSame('test', $this->searchPageRepository->getDefaultSearchPage());
 }
 /**
  * @covers ::save()
  * @covers ::doSave()
  *
  * @expectedException \Drupal\Core\Config\ConfigDuplicateUUIDException
  * @expectedExceptionMessage when this entity already exists with UUID
  */
 public function testSaveChangedUuid()
 {
     $config_object = $this->getMockBuilder('Drupal\\Core\\Config\\Config')->disableOriginalConstructor()->getMock();
     $config_object->expects($this->atLeastOnce())->method('isNew')->will($this->returnValue(FALSE));
     $config_object->expects($this->never())->method('save');
     $config_object->expects($this->exactly(2))->method('get')->will($this->returnValueMap(array(array('', array('id' => 'foo')), array('id', 'foo'))));
     $this->cacheBackend->expects($this->never())->method('invalidateTags');
     $this->configFactory->expects($this->at(1))->method('loadMultiple')->with(array('the_config_prefix.foo'))->will($this->returnValue(array()));
     $this->configFactory->expects($this->at(2))->method('loadMultiple')->with(array('the_config_prefix.foo'))->will($this->returnValue(array($config_object)));
     $this->configFactory->expects($this->once())->method('get')->with('the_config_prefix.foo')->will($this->returnValue($config_object));
     $this->configFactory->expects($this->never())->method('rename')->will($this->returnValue($config_object));
     $this->moduleHandler->expects($this->exactly(2))->method('getImplementations')->will($this->returnValue(array()));
     $this->entityQuery->expects($this->once())->method('condition')->will($this->returnSelf());
     $this->entityQuery->expects($this->once())->method('execute')->will($this->returnValue(array('foo')));
     $entity = $this->getMockEntity(array('id' => 'foo'));
     $entity->set('uuid', 'baz');
     $this->entityStorage->save($entity);
 }