/**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     // Create a config mock which does not mock the clear(), set() and get() methods.
     $methods = get_class_methods('Drupal\\Core\\Config\\Config');
     unset($methods[array_search('set', $methods)]);
     unset($methods[array_search('get', $methods)]);
     unset($methods[array_search('clear', $methods)]);
     $config_mock = $this->getMockBuilder('Drupal\\Core\\Config\\Config')->disableOriginalConstructor()->setMethods($methods)->getMock();
     // Create the config factory we use in the submitForm() function.
     $this->configFactory = $this->getMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
     $this->configFactory->expects($this->any())->method('getEditable')->will($this->returnValue($config_mock));
     // Create a MailsystemManager mock.
     $this->mailManager = $this->getMock('\\Drupal\\mailsystem\\MailsystemManager', array(), array(), '', FALSE);
     $this->mailManager->expects($this->any())->method('getDefinition')->will($this->returnValueMap(array(array('mailsystem_test', TRUE, array('label' => 'Test Mail-Plugin')), array('mailsystem_demo', TRUE, array('label' => 'Demo Mail-Plugin')))));
     $this->mailManager->expects($this->any())->method('getDefinitions')->will($this->returnValue(array(array('id' => 'mailsystem_test', 'label' => 'Test Mail-Plugin'), array('id' => 'mailsystem_demo', 'label' => 'Demo Mail-Plugin'))));
     // Create a module handler mock.
     $this->moduleHandler = $this->getMock('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
     $this->moduleHandler->expects($this->any())->method('getImplementations')->with('mail')->will($this->returnValue(array('mailsystem_test', 'mailsystem_demo')));
     $this->moduleHandler->expects($this->any())->method('moduleExists')->withAnyParameters()->will($this->returnValue(FALSE));
     // Create a theme handler mock.
     $this->themeHandler = $this->getMock('\\Drupal\\Core\\Extension\\ThemeHandlerInterface');
     $this->themeHandler->expects($this->any())->method('listInfo')->will($this->returnValue(array('test_theme' => (object) array('status' => 1, 'info' => array('name' => 'test theme name')), 'demo_theme' => (object) array('status' => 1, 'info' => array('name' => 'test theme name demo')), 'inactive_theme' => (object) array('status' => 0, 'info' => array('name' => 'inactive test theme')))));
     // Inject a language-manager into \Drupal.
     $this->languageManager = $this->getMock('\\Drupal\\Core\\StringTranslation\\TranslationInterface');
     $this->languageManager->expects($this->any())->method('translate')->withAnyParameters()->will($this->returnArgument(0));
     $container = new ContainerBuilder();
     $container->set('string_translation', $this->languageManager);
     \Drupal::setContainer($container);
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->directoryList = array('system' => 'core/modules/system');
     $this->themeHandler = $this->getMock('Drupal\\Core\\Extension\\ThemeHandlerInterface');
     $theme = new Extension('theme', DRUPAL_ROOT . '/core/themes/bartik', 'bartik.info.yml');
     $theme->status = 1;
     $theme->info = array('name' => 'bartik');
     $this->themeHandler->expects($this->any())->method('listInfo')->will($this->returnValue(array('bartik' => $theme)));
     $this->container->set('theme_handler', $this->themeHandler);
 }