/** * {@inheritdoc} */ public function setUp() { $configuration = []; $plugin_id = $this->randomMachineName(); $this->pluginDefinition = ['cache' => TRUE, 'provider' => $this->randomMachineName()]; $this->cacheContextsManager = $this->getMockBuilder(CacheContextsManager::class)->disableOriginalConstructor()->getMock(); $this->cacheContextsManager->expects($this->any())->method('assertValidTokens')->willReturn(TRUE); $this->exchangeRateProvider = $this->getMock(ExchangeRateProviderInterface::class); $this->input = $this->getMock(InputInterface::class); $this->stringTranslation = $this->getStringTranslationStub(); $container = new Container(); $container->set('cache_contexts_manager', $this->cacheContextsManager); \Drupal::setContainer($container); $this->sut = new CurrencyExchange($configuration, $plugin_id, $this->pluginDefinition, $this->stringTranslation, $this->exchangeRateProvider, $this->input); }
/** * {@inheritdoc} */ public function set($id, $service, $scope = ContainerInterface::SCOPE_CONTAINER) { parent::set($id, $service, $scope); // Ensure that the _serviceId property is set on synthetic services as well. if (isset($this->services[$id]) && is_object($this->services[$id]) && !isset($this->services[$id]->_serviceId)) { $this->services[$id]->_serviceId = $id; } }