Commit 65312647 authored by alexpott's avatar alexpott

Issue #2493557 by pfrenssen: Fatal error when creating a translatable vocabulary type

parent cb451afa
<?php
/**
* @file
* Contains \Drupal\taxonomy\Tests\VocabularyTranslationTest.
*/
namespace Drupal\taxonomy\Tests;
use Drupal\Component\Utility\Unicode;
/**
* Tests content translation for vocabularies.
*
* @group taxonomy
*/
class VocabularyTranslationTest extends TaxonomyTestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('content_translation', 'language');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Create an administrative user.
$this->drupalLogin($this->drupalCreateUser([
'administer taxonomy',
'administer content translation',
]));
}
/**
* Tests language settings for vocabularies.
*/
function testVocabularyLanguage() {
$this->drupalGet('admin/structure/taxonomy/add');
// Check that the field to enable content translation is available.
$this->assertField('edit-default-language-content-translation', 'The content translation checkbox is present on the page.');
// Create the vocabulary.
$vid = Unicode::strtolower($this->randomMachineName());
$edit['name'] = $this->randomMachineName();
$edit['description'] = $this->randomMachineName();
$edit['langcode'] = 'en';
$edit['vid'] = $vid;
$edit['default_language[content_translation]'] = TRUE;
$this->drupalPostForm(NULL, $edit, t('Save'));
// Check if content translation is enabled on the edit page.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vid);
$this->assertFieldChecked('edit-default-language-content-translation', 'The content translation was correctly selected.');
}
}
......@@ -115,26 +115,6 @@ public function form(array $form, FormStateInterface $form_state) {
return parent::form($form, $form_state, $vocabulary);
}
/**
* {@inheritdoc}
*/
protected function actions(array $form, FormStateInterface $form_state) {
// If we are displaying the delete confirmation skip the regular actions.
if (!$form_state->get('confirm_delete')) {
$actions = parent::actions($form, $form_state);
// We cannot leverage the regular submit handler definition because we
// have button-specific ones here. Hence we need to explicitly set it for
// the submit action, otherwise it would be ignored.
if ($this->moduleHandler->moduleExists('content_translation')) {
array_unshift($actions['submit']['#submit'], 'content_translation_language_configuration_element_submit');
}
return $actions;
}
else {
return array();
}
}
/**
* {@inheritdoc}
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment