Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176

This commit is contained in:
Pantheon Automation 2015-08-17 17:00:26 -07:00 committed by Greg Anderson
commit 9921556621
13277 changed files with 1459781 additions and 0 deletions

View file

@ -0,0 +1,10 @@
name: 'Content translation tests'
type: module
description: 'Provides content translation tests.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- content_translation
- language
- entity_test

View file

@ -0,0 +1,32 @@
<?php
/**
* @file
* Contains \Drupal\content_translation_test\Entity\EntityTestTranslatableNoUISkip.
*/
namespace Drupal\content_translation_test\Entity;
use Drupal\entity_test\Entity\EntityTest;
/**
* Defines the test entity class.
*
* @ContentEntityType(
* id = "entity_test_translatable_no_skip",
* label = @Translation("Test entity - Translatable check UI"),
* base_table = "entity_test_mul",
* data_table = "entity_test_mul_property_data",
* entity_keys = {
* "id" = "id",
* "uuid" = "uuid",
* "bundle" = "type",
* "label" = "name",
* "langcode" = "langcode",
* },
* translatable = TRUE,
* )
*/
class EntityTestTranslatableNoUISkip extends EntityTest {
}

View file

@ -0,0 +1,33 @@
<?php
/**
* @file
* Contains \Drupal\content_translation_test\Entity\EntityTestTranslatableUISkip.
*/
namespace Drupal\content_translation_test\Entity;
use Drupal\entity_test\Entity\EntityTest;
/**
* Defines the test entity class.
*
* @ContentEntityType(
* id = "entity_test_translatable_UI_skip",
* label = @Translation("Test entity - Translatable skip UI check"),
* base_table = "entity_test_mul",
* data_table = "entity_test_mul_property_data",
* entity_keys = {
* "id" = "id",
* "uuid" = "uuid",
* "bundle" = "type",
* "label" = "name",
* "langcode" = "langcode",
* },
* translatable = TRUE,
* content_translation_ui_skip = TRUE,
* )
*/
class EntityTestTranslatableUISkip extends EntityTest {
}

View file

@ -0,0 +1,9 @@
name: 'Content translation test views'
type: module
description: 'Provides default views for views content translation tests.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- content_translation
- views

View file

@ -0,0 +1,112 @@
langcode: en
status: true
dependencies:
module:
- content_translation
- user
id: test_entity_translations_link
label: People
module: views
description: ''
tag: ''
base_table: users_field_data
base_field: uid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: null
display_options:
access:
type: none
cache:
type: tag
query:
type: views_query
exposed_form:
type: basic
options:
submit_button: Filter
reset_button: true
reset_button_label: Reset
pager:
type: full
options:
items_per_page: 50
style:
type: table
options:
columns:
name: name
translation_link: translation_link
default: created
row:
type: fields
fields:
name:
id: name
table: users_field_data
field: name
label: Username
plugin_id: field
type: user_name
entity_type: user
entity_field: name
translation_link:
id: translation_link
table: users
field: translation_link
label: 'Translation link'
exclude: false
alter:
alter_text: false
element_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
text: Translate
plugin_id: content_translation_link
entity_type: user
filters:
uid_raw:
id: uid_raw
table: users_field_data
field: uid_raw
operator: '!='
value:
value: '0'
group: 1
exposed: false
plugin_id: numeric
entity_type: user
sorts:
created:
id: created
table: users_field_data
field: created
order: DESC
plugin_id: date
entity_type: user
entity_field: created
title: People
empty:
area:
id: area
table: views
field: area
empty: true
content:
value: 'No people available.'
format: plain_text
plugin_id: text
page_1:
display_plugin: page
id: page_1
display_title: Page
position: null
display_options:
path: test-entity-translations-link

View file

@ -0,0 +1,104 @@
<?php
/**
* @file
* Contains \Drupal\Tests\content_translation\Unit\Access\ContentTranslationManageAccessCheckTest.
*/
namespace Drupal\Tests\content_translation\Unit\Access;
use Drupal\content_translation\Access\ContentTranslationManageAccessCheck;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Language\Language;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\Routing\Route;
/**
* Tests for content translation manage check.
*
* @coversDefaultClass \Drupal\content_translation\Access\ContentTranslationManageAccessCheck
* @group Access
* @group content_translation
*/
class ContentTranslationManageAccessCheckTest extends UnitTestCase {
/**
* Tests the create access method.
*
* @covers ::access
*/
public function testCreateAccess() {
// Set the mock translation handler.
$translation_handler = $this->getMock('\Drupal\content_translation\ContentTranslationHandlerInterface');
$translation_handler->expects($this->once())
->method('getTranslationAccess')
->will($this->returnValue(AccessResult::allowed()));
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
$entity_manager->expects($this->once())
->method('getHandler')
->withAnyParameters()
->will($this->returnValue($translation_handler));
// Set our source and target languages.
$source = 'en';
$target = 'it';
// Set the mock language manager.
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$language_manager->expects($this->at(0))
->method('getLanguage')
->with($this->equalTo($source))
->will($this->returnValue(new Language(array('id' => 'en'))));
$language_manager->expects($this->at(1))
->method('getLanguages')
->will($this->returnValue(array('en' => array(), 'it' => array())));
$language_manager->expects($this->at(2))
->method('getLanguage')
->with($this->equalTo($source))
->will($this->returnValue(new Language(array('id' => 'en'))));
$language_manager->expects($this->at(3))
->method('getLanguage')
->with($this->equalTo($target))
->will($this->returnValue(new Language(array('id' => 'it'))));
// Set the mock entity. We need to use ContentEntityBase for mocking due to
// issues with phpunit and multiple interfaces.
$entity = $this->getMockBuilder('Drupal\Core\Entity\ContentEntityBase')
->disableOriginalConstructor()
->getMock();
$entity->expects($this->once())
->method('getEntityTypeId');
$entity->expects($this->once())
->method('getTranslationLanguages')
->with()
->will($this->returnValue(array()));
$entity->expects($this->once())
->method('getCacheTags')
->will($this->returnValue(array('node:1337')));
// Set the route requirements.
$route = new Route('test_route');
$route->setRequirement('_access_content_translation_manage', 'create');
// Set up the route match.
$route_match = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match->expects($this->once())
->method('getParameter')
->with('node')
->will($this->returnValue($entity));
// Set the mock account.
$account = $this->getMock('Drupal\Core\Session\AccountInterface');
// The access check under test.
$check = new ContentTranslationManageAccessCheck($entity_manager, $language_manager);
// The request params.
$language = 'en';
$entity_type_id = 'node';
$this->assertTrue($check->access($route, $route_match, $account, $source, $target, $language, $entity_type_id)->isAllowed(), "The access check matches");
}
}

View file

@ -0,0 +1,73 @@
<?php
/**
* @file
* Contains \Drupal\Tests\content_translation\Unit\Menu\ContentTranslationLocalTasksTest.
*/
namespace Drupal\Tests\content_translation\Unit\Menu;
use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
/**
* Tests content translation local tasks.
*
* @group content_translation
*/
class ContentTranslationLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
$this->directoryList = array(
'content_translation' => 'core/modules/content_translation',
'node' => 'core/modules/node',
);
parent::setUp();
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type->expects($this->any())
->method('getLinkTemplate')
->will($this->returnValueMap(array(
array('canonical', 'entity.node.canonical'),
array('drupal:content-translation-overview', 'entity.node.content_translation_overview'),
)));
$content_translation_manager = $this->getMock('Drupal\content_translation\ContentTranslationManagerInterface');
$content_translation_manager->expects($this->any())
->method('getSupportedEntityTypes')
->will($this->returnValue(array(
'node' => $entity_type,
)));
\Drupal::getContainer()->set('content_translation.manager', $content_translation_manager);
}
/**
* Tests the block admin display local tasks.
*
* @dataProvider providerTestBlockAdminDisplay
*/
public function testBlockAdminDisplay($route, $expected) {
$this->assertLocalTasks($route, $expected);
}
/**
* Provides a list of routes to test.
*/
public function providerTestBlockAdminDisplay() {
return array(
array('entity.node.canonical', array(array(
'content_translation.local_tasks:entity.node.content_translation_overview',
'entity.node.canonical',
'entity.node.edit_form',
'entity.node.delete_form',
'entity.node.version_history',
))),
array('entity.node.content_translation_overview', array(array(
'content_translation.local_tasks:entity.node.content_translation_overview',
'entity.node.canonical',
'entity.node.edit_form',
'entity.node.delete_form',
'entity.node.version_history',
))),
);
}
}