Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPENEUROPA-1781: Do not lock source language value to default language. #58

Merged
merged 2 commits into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions oe_multilingual.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ services:
oe_multilingual.content_language_switcher_provider:
class: Drupal\oe_multilingual\ContentLanguageSwitcherProvider
arguments: ['@language_manager', '@path.matcher', '@oe_multilingual.helper']
oe_multilingual.content_language_settings:
class: Drupal\oe_multilingual\MultilingualConfigOverride
tags:
- {name: config.factory.override, priority: 5}
57 changes: 0 additions & 57 deletions src/MultilingualConfigOverride.php

This file was deleted.

35 changes: 5 additions & 30 deletions tests/Behat/DrupalContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,44 +124,19 @@ public function iAmVisitingTheCreationPage(string $content_type_name): void {
}

/**
* Check that the field is not present.
* Check that the field is present.
*
* @param string $field
* Input id, name or label.
*
* @Then I should not see the field :field
* @Then I should see the field :field
*/
public function iShouldNotSeeTheField(string $field): void {
public function iShouldSeeTheField(string $field): void {
$element = $this->getSession()
->getPage()
->findField($field);
if ($element) {
throw new \RuntimeException("Field '{$field}' is present.");
}
}

/**
* Check that we have the correct language for initial translation.
*
* @param string $title
* Title of node.
*
* @Then The only available translation for :title is in the site's default language
*/
public function assertOnlyDefaultLanguageTranslationExist(string $title): void {
$node = $this->getEntityByLabel('node', $title);
if (!$node) {
throw new \RuntimeException("Node '{$title}' doesn't exist.");
}

$node_translation_languages = $node->getTranslationLanguages();
if (count($node_translation_languages) !== 1) {
throw new \RuntimeException("The node should have only one translation.");
}

$node_language = key($node_translation_languages);
if ($node_language != \Drupal::languageManager()->getDefaultLanguage()->getId()) {
throw new \RuntimeException("Original translation language of the '{$title}' node is not the site's default language.");
if (empty($element)) {
throw new \RuntimeException("Field '{$field}' is not present.");
}
}

Expand Down
15 changes: 4 additions & 11 deletions tests/features/content-default-language.feature
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
@api
Feature: Content initial language.
In order to create content
As a editor
I want to make sure that it is not possible for a content editor to create a node's initial version in any language
other than the site's default language
As a content editor
I can create an initial version of a node in any language

Scenario: As an editor, when I create a node I can not select the initial node language
Scenario: As an editor, when I create a node I can select the initial node language
Given I am logged in as a user with the "create oe_demo_translatable_page content" permission
And I visit the "Demo translatable page" creation page
Then I should not see the field "Language"

When I fill in "Title" with "Title Default value"
And I fill in "Body" with "Body Default value"
And I press "Save"
Then I should see the success message "Demo translatable page Title Default value has been created."
And The only available translation for "Title Default value" is in the site's default language
Then I should see the field "Language"