Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
e3d9711e
Commit
e3d9711e
authored
Nov 27, 2012
by
webchick
Browse files
Issue
#1848904
by andypost, tim.plunkett: Bundles cannot be specified in Entity Translation tests.
parent
f13c337b
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php
View file @
e3d9711e
...
...
@@ -19,6 +19,13 @@ class TermTranslationUITest extends EntityTranslationUITest {
*/
protected
$name
;
/**
* The vocabulary used for creating terms.
*
* @var \Drupal\taxonomy\Plugin\Core\Entity\Vocabulary
*/
protected
$vocabulary
;
/**
* Modules to enable.
*
...
...
@@ -51,7 +58,7 @@ protected function setupBundle() {
parent
::
setupBundle
();
// Create a vocabulary.
$vocabulary
=
entity_create
(
'taxonomy_vocabulary'
,
array
(
$
this
->
vocabulary
=
entity_create
(
'taxonomy_vocabulary'
,
array
(
'name'
=>
$this
->
bundle
,
'description'
=>
$this
->
randomName
(),
'machine_name'
=>
$this
->
bundle
,
...
...
@@ -59,7 +66,7 @@ protected function setupBundle() {
'help'
=>
''
,
'weight'
=>
mt_rand
(
0
,
10
),
));
taxonomy_
vocabulary
_
save
(
$vocabulary
);
$this
->
vocabulary
->
save
();
}
/**
...
...
@@ -72,13 +79,16 @@ function getTranslatorPermissions() {
/**
* Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::createEntity().
*/
protected
function
createEntity
(
$values
,
$langcode
,
$vocabulary_name
=
NULL
)
{
if
(
!
isset
(
$vocabulary_name
))
{
$vocabulary_name
=
$this
->
bundle
;
protected
function
createEntity
(
$values
,
$langcode
,
$bundle_name
=
NULL
)
{
if
(
isset
(
$bundle_name
))
{
$vocabulary
=
taxonomy_vocabulary_machine_name_load
(
$bundle_name
);
}
else
{
$vocabulary
=
$this
->
vocabulary
;
}
$vocabulary
=
taxonomy_vocabulary_machine_name_load
(
$vocabulary_name
);
// Term needs vid to be saved.
$values
[
'vid'
]
=
$vocabulary
->
id
();
return
parent
::
createEntity
(
$values
,
$langcode
);
return
parent
::
createEntity
(
$values
,
$langcode
,
$bundle_name
);
}
/**
...
...
@@ -110,7 +120,7 @@ function testTranslateLinkVocabularyAdminPage() {
$this
->
admin_user
=
$this
->
drupalCreateUser
(
array
(
'access administration pages'
,
'administer taxonomy'
,
'translate any entity'
));
$this
->
drupalLogin
(
$this
->
admin_user
);
$translatable_vocabulary_name
=
taxonomy_
vocabulary
_machine_name_load
(
$this
->
bundle
)
->
name
;
$translatable_vocabulary_name
=
$this
->
vocabulary
->
name
;
$translatable_tid
=
$this
->
createEntity
(
array
(),
$this
->
langcodes
[
0
]);
// Create an untranslatable vocabulary.
...
...
@@ -122,7 +132,7 @@ function testTranslateLinkVocabularyAdminPage() {
'help'
=>
''
,
'weight'
=>
mt_rand
(
0
,
10
),
));
taxonomy_vocabulary_save
(
$untranslatable_vocabulary
);
$untranslatable_vocabulary
->
save
(
);
$untranslatable_vocabulary_name
=
$untranslatable_vocabulary
->
name
;
$untranslatable_tid
=
$this
->
createEntity
(
array
(),
$this
->
langcodes
[
0
],
$untranslatable_vocabulary_name
);
...
...
core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php
View file @
e3d9711e
...
...
@@ -231,16 +231,19 @@ function testTranslationUI() {
* An array of initial values for the entity.
* @param string $langcode
* The initial language code of the entity.
* @param string $bundle_name
* (optional) The entity bundle, if the entity uses bundles. Defaults to
* NULL. If left NULL, $this->bundle will be used.
*
* @return
* The entity id.
*/
protected
function
createEntity
(
$values
,
$langcode
)
{
protected
function
createEntity
(
$values
,
$langcode
,
$bundle_name
=
NULL
)
{
$entity_values
=
$values
;
$entity_values
[
'langcode'
]
=
$langcode
;
$info
=
entity_get_info
(
$this
->
entityType
);
if
(
!
empty
(
$info
[
'entity_keys'
][
'bundle'
]))
{
$entity_values
[
$info
[
'entity_keys'
][
'bundle'
]]
=
$this
->
bundle
;
$entity_values
[
$info
[
'entity_keys'
][
'bundle'
]]
=
$bundle_name
?:
$this
->
bundle
;
}
$controller
=
entity_get_controller
(
$this
->
entityType
);
if
(
!
(
$controller
instanceof
DatabaseStorageControllerNG
))
{
...
...
@@ -280,7 +283,7 @@ protected function getEditValues($values, $langcode, $new = FALSE) {
/**
* Returns the translation object to use to retrieve the translated values.
*
* @param \Drupal\Core\En
i
tity\EntityInterface $entity
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity being tested.
* @param string $langcode
* The language code identifying the translation to be retrieved.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment