all contrib module security updates done

This commit is contained in:
2020-09-24 22:47:32 +02:00
parent 7d87153100
commit 0fbb9c4610
1612 changed files with 116663 additions and 32269 deletions
@@ -0,0 +1,80 @@
<?php
/**
* Tests for legacy field replacement.
*/
class TitleAdminSettingsTestCase extends DrupalWebTestCase {
/**
*
*/
public static function getInfo() {
return array(
'name' => 'Admin settings',
'description' => 'Test the administration settings.',
'group' => 'Title',
);
}
/**
* Use the barebones "testing" installation profile.
*/
protected $profile = 'testing';
/**
* {@inheritdoc}
*/
public function setUp(array $modules = array()) {
// Core.
$modules[] = 'field_test';
$modules[] = 'taxonomy';
// This module.
$modules[] = 'title';
$modules[] = 'title_test';
parent::setUp($modules);
/**
* Reset the permissions cache prior to calling drupalCreateUser.
* @see https://api.drupal.org/comment/28739#comment-28739
*/
$this->checkPermissions(array(), TRUE);
$admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer taxonomy', 'administer fields'));
$this->drupalLogin($admin_user);
}
/**
* Check for automated title_field attachment.
*/
public function testAutomatedFieldAttachment() {
$this->doTestAutomatedFieldAttachment(TRUE);
$this->doTestAutomatedFieldAttachment(FALSE);
}
/**
* Check that the fields are replaced or skipped depending on the given value.
*
* @param bool $enabled
* Whether replacement is enabled or not.
*/
public function doTestAutomatedFieldAttachment($enabled) {
$edit = array(
'title_taxonomy_term[auto_attach][name]' => $enabled,
'title_taxonomy_term[auto_attach][description]' => $enabled,
);
$this->drupalPost('admin/config/content/title', $edit, t('Save configuration'));
$edit = array(
'name' => $this->randomName(),
'machine_name' => drupal_strtolower($this->randomName()),
'description' => $this->randomString(16),
);
$this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
$entity_type = 'taxonomy_term';
$bundle = $edit['machine_name'];
field_info_cache_clear();
$this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'name') == $enabled, 'Name field correctly processed.');
$this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'description') == $enabled, 'Description field correctly processed.');
}
}
@@ -0,0 +1,177 @@
<?php
/**
* Tests for legacy field replacement.
*/
class TitleFieldReplacementTestCase extends DrupalWebTestCase {
/**
*
*/
public static function getInfo() {
return array(
'name' => 'Field replacement',
'description' => 'Test field replacement.',
'group' => 'Title',
'dependencies' => array('entity'),
);
}
/**
* Use the barebones "testing" installation profile.
*/
protected $profile = 'testing';
/**
* {@inheritdoc}
*/
public function setUp(array $modules = array()) {
// Core.
$modules[] = 'comment';
$modules[] = 'field_test';
$modules[] = 'taxonomy';
// Other dependencies.
$modules[] = 'entity';
// This module.
$modules[] = 'title';
$modules[] = 'title_test';
parent::setUp($modules);
}
/**
* Test field replacement API and workflow.
*/
public function testFieldReplacementWorkflow() {
$info = entity_get_info('test_entity');
$label_key = $info['entity keys']['label'];
$field_name = $label_key . '_field';
// Enable field replacement for the test entity.
title_field_replacement_toggle('test_entity', 'test_bundle', $label_key);
$i = 0;
$entity = field_test_create_stub_entity(FALSE, FALSE);
while ($i++ <= 1) {
// The first time the entity gets created the second time gets updated.
title_test_entity_save($entity);
// Check that the replacing field value has been synchronized on save.
$query = db_select('test_entity', 'te');
$query->addJoin('INNER', 'field_data_' . $field_name, 'f', 'te.ftid = f.entity_id');
$record = $query
->fields('te')
->fields('f')
->condition('ftid', $entity->ftid)
->execute()
->fetch();
$phase = $entity->is_new ? 'insert' : 'update';
$this->assertIdentical($record->{$label_key}, $record->{$field_name . '_value'}, t('Field synchronization is correctly performed on %phase.', array('%phase' => $phase)));
unset($entity->is_new);
}
// Store a dummy value in the legacy field.
while (($label = $this->randomName()) == $entity->{$label_key}) {
}
db_update('test_entity')
->fields(array($label_key => $label))
->execute();
$record = db_select('test_entity', 'te')
->fields('te')
->condition('ftid', $entity->ftid)
->execute()
->fetch();
$this->assertNotIdentical($record->{$label_key}, $entity->{$label_key}, t('Entity label has been changed.'));
// Clear field cache so synchronization can be performed on field attach
// load.
cache_clear_all('*', 'cache_field');
drupal_static_reset();
// Check that the replacing field value is correctly synchronized on load
// and view.
$entity = title_test_entity_test_load($entity);
title_test_phase_check('after_load', $entity);
entity_view('test_entity', array($entity->ftid => $entity));
foreach (title_test_phase_store() as $phase => $value) {
$this->assertTrue($value, t('Field synchronization is correctly performed on %phase.', array('%phase' => $phase)));
}
// Change the value stored into the label field to check entity_label().
if (isset($info['label callback'])) {
$label = $this->randomName();
$entity->{$field_name}[LANGUAGE_NONE][0]['value'] = $label;
$this->assertIdentical(entity_label('test_entity', $entity), $label, t('entity_label() returns the expected value.'));
}
}
/**
* Test field replacement UI.
*/
public function testFieldReplacementUI() {
$permissions = array(
'access administration pages',
'view the administration theme',
'administer content types',
'administer taxonomy',
'administer comments',
'administer fields',
);
$admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
foreach (entity_get_info() as $entity_type => $entity_info) {
if (!empty($entity_info['field replacement'])) {
foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
if (isset($bundle_info['admin']['path'])) {
$admin_path = _field_ui_bundle_admin_path($entity_type, $bundle) . '/fields';
foreach ($entity_info['field replacement'] as $legacy_field => $info) {
$path = $admin_path . '/replace/' . $legacy_field;
$xpath = '//a[@href=:url and text()=:label]';
$args = array(':url' => url($path), ':label' => t('replace'));
$targs = array('%legacy_field' => $legacy_field, '%entity_type' => $entity_type, '%bundle' => $bundle);
$field_name = $info['field']['field_name'];
// Check that the current legacy field has a "replace" operation.
$this->drupalGet($admin_path);
$link = $this->xpath($xpath, $args);
$this->assertEqual(count($link), 1, t('Replace link found for the field %legacy_field of the bundle %bundle of the entity %entity_type.', $targs));
// Check that the legacy field has correctly been replaced through
// field replacement UI.
$this->drupalPost($path, array('enabled' => TRUE), t('Save settings'));
_field_info_collate_fields(TRUE);
$link = $this->xpath($xpath, $args);
$this->assertTrue(empty($link) && title_field_replacement_enabled($entity_type, $bundle, $legacy_field), t('%legacy_field successfully replaced for the bundle %bundle of the entity %entity_type.', $targs));
// Check that the enabled status cannot be changed unless the
// field instance is removed.
$this->drupalGet($path);
$this->assertFieldByXPath('//form//input[@name="enabled" and @checked="checked" and @disabled="disabled"]', NULL, t('Field replacement for %legacy_field cannot be disabled unless the replacing field instance is deleted.', array('%legacy_field' => $legacy_field)));
$this->drupalPost($path, array(), t('Save settings'));
_field_info_collate_fields(TRUE);
$this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, $legacy_field), t('Submitting the form does not alter field replacement settings.'));
// Delete the field instance and check that the "replace"
// operation is available again.
$this->drupalPost($admin_path . '/' . $field_name . '/delete', array(), t('Delete'));
$link = $this->xpath($xpath, $args);
$this->assertEqual(count($link), 1, t('Replace link found for the field %legacy_field of the bundle %bundle of the entity %entity_type.', $targs));
// Check that field replacement can be enabled again.
$this->drupalGet($path);
$this->assertFieldByXPath('//form//input[@name="enabled" and not(@checked) and not(@disabled)]', NULL, t('Field replacement for %legacy_field cannot be disabled unless the replacing field instance is deleted.', array('%legacy_field' => $legacy_field)));
}
}
}
}
}
}
}
@@ -1,223 +1,52 @@
<?php
/**
* @file
* Tests for the Title module.
*/
/**
* Tests for legacy field replacement.
*/
class TitleFieldReplacementTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Field replacement',
'description' => 'Test field replacement.',
'group' => 'Title',
);
}
function setUp() {
parent::setUp('entity', 'field_test', 'title', 'title_test');
}
/**
* Test field replacement API and workflow.
*/
function testFieldReplacementWorkflow() {
$info = entity_get_info('test_entity');
$label_key = $info['entity keys']['label'];
$field_name = $label_key . '_field';
// Enable field replacement for the test entity.
title_field_replacement_toggle('test_entity', 'test_bundle', $label_key);
$i = 0;
$entity = field_test_create_stub_entity(FALSE, FALSE);
while ($i++ <= 1) {
// The first time the entity gets created the second time gets updated.
title_test_entity_save($entity);
// Check that the replacing field value has been synchronized on save.
$query = db_select('test_entity', 'te');
$query->addJoin('INNER', 'field_data_' . $field_name, 'f', 'te.ftid = f.entity_id');
$record = $query
->fields('te')
->fields('f')
->condition('ftid', $entity->ftid)
->execute()
->fetch();
$phase = $entity->is_new ? 'insert' : 'update';
$this->assertIdentical($record->{$label_key}, $record->{$field_name . '_value'}, t('Field synchronization is correctly performed on %phase.', array('%phase' => $phase)));
unset($entity->is_new);
}
// Store a dummy value in the legacy field.
while (($label = $this->randomName()) == $entity->{$label_key});
db_update('test_entity')
->fields(array($label_key => $label))
->execute();
$record = db_select('test_entity', 'te')
->fields('te')
->condition('ftid', $entity->ftid)
->execute()
->fetch();
$this->assertNotIdentical($record->{$label_key}, $entity->{$label_key}, t('Entity label has been changed.'));
// Clear field cache so synchronization can be performed on field attach
// load.
cache_clear_all('*', 'cache_field');
drupal_static_reset();
// Check that the replacing field value is correctly synchronized on load
// and view.
$entity = title_test_entity_test_load($entity);
title_test_phase_check('after_load', $entity);
$build = entity_view('test_entity', array($entity->ftid => $entity));
foreach (title_test_phase_store() as $phase => $value) {
$this->assertTrue($value, t('Field synchronization is correctly performed on %phase.', array('%phase' => $phase)));
}
// Change the value stored into the label field to check entity_label().
if (isset($info['label callback'])) {
$label = $this->randomName();
$entity->{$field_name}[LANGUAGE_NONE][0]['value'] = $label;
$this->assertIdentical(entity_label('test_entity', $entity), $label, t('entity_label() returns the expected value.'));
}
}
/**
* Test field replacement UI.
*/
function testFieldReplacementUI() {
$admin_user = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer content types', 'administer taxonomy', 'administer comments'));
$this->drupalLogin($admin_user);
foreach (entity_get_info() as $entity_type => $entity_info) {
if (!empty($entity_info['field replacement'])) {
foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
if (isset($bundle_info['admin']['path'])) {
$admin_path = _field_ui_bundle_admin_path($entity_type, $bundle) . '/fields';
foreach ($entity_info['field replacement'] as $legacy_field => $info) {
$path = $admin_path . '/replace/' . $legacy_field;
$xpath = '//a[@href=:url and text()=:label]';
$args = array(':url' => url($path), ':label' => t('replace'));
$targs = array('%legacy_field' => $legacy_field, '%entity_type' => $entity_type, '%bundle' => $bundle);
$field_name = $info['field']['field_name'];
// Check that the current legacy field has a "replace" operation.
$this->drupalGet($admin_path);
$link = $this->xpath($xpath, $args);
$this->assertEqual(count($link), 1, t('Replace link found for the field %legacy_field of the bundle %bundle of the entity %entity_type.', $targs));
// Check that the legacy field has correctly been replaced through
// field replacement UI.
$this->drupalPost($path, array('enabled' => TRUE), t('Save settings'));
_field_info_collate_fields(TRUE);
$link = $this->xpath($xpath, $args);
$this->assertTrue(empty($link) && title_field_replacement_enabled($entity_type, $bundle, $legacy_field), t('%legacy_field successfully replaced for the bundle %bundle of the entity %entity_type.', $targs));
// Check that the enabled status cannot be changed unless the
// field instance is removed.
$this->drupalGet($path);
$this->assertFieldByXPath('//form//input[@name="enabled" and @checked="checked" and @disabled="disabled"]', NULL, t('Field replacement for %legacy_field cannot be disabled unless the replacing field instance is deleted.', array('%legacy_field' => $legacy_field)));
$this->drupalPost($path, array(), t('Save settings'));
_field_info_collate_fields(TRUE);
$this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, $legacy_field), t('Submitting the form does not alter field replacement settings.'));
// Delete the field instance and check that the "replace"
// operation is available again.
$this->drupalPost($admin_path . '/' . $field_name . '/delete', array(), t('Delete'));
$link = $this->xpath($xpath, $args);
$this->assertEqual(count($link), 1, t('Replace link found for the field %legacy_field of the bundle %bundle of the entity %entity_type.', $targs));
// Check that field replacement can be enabled again.
$this->drupalGet($path);
$this->assertFieldByXPath('//form//input[@name="enabled" and not(@checked) and not(@disabled)]', NULL, t('Field replacement for %legacy_field cannot be disabled unless the replacing field instance is deleted.', array('%legacy_field' => $legacy_field)));
}
}
}
}
}
}
}
/**
* Tests for legacy field replacement.
*/
class TitleAdminSettingsTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Admin settings',
'description' => 'Test the administration settings.',
'group' => 'Title',
);
}
function setUp() {
parent::setUp('field_test', 'title', 'title_test');
$admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer taxonomy'));
$this->drupalLogin($admin_user);
}
/**
* Check for automated title_field attachment.
*/
function testAutomatedFieldAttachement() {
$this->assertAutomatedFieldAttachement(TRUE);
$this->assertAutomatedFieldAttachement(FALSE);
}
/**
* Check that the fields are replaced or skipped depdening on the given value.
*/
function assertAutomatedFieldAttachement($enabled) {
$edit = array(
'title_taxonomy_term[auto_attach][name]' => $enabled,
'title_taxonomy_term[auto_attach][description]' => $enabled,
);
$this->drupalPost('admin/config/content/title', $edit, t('Save configuration'));
$edit = array(
'name' => $this->randomName(),
'machine_name' => drupal_strtolower($this->randomName()),
'description' => $this->randomString(16),
);
$this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
$entity_type = 'taxonomy_term';
$bundle = $edit['machine_name'];
field_info_cache_clear();
$this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'name') == $enabled, 'Name field correctly processed.');
$this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'description') == $enabled, 'Description field correctly processed.');
}
}
/**
* Tests for legacy field replacement.
*/
class TitleTranslationTestCase extends DrupalWebTestCase {
/**
*
*/
public static function getInfo() {
return array(
'name' => 'Replaced fields translation',
'description' => 'Test replaced field translation.',
'group' => 'Title',
'dependencies' => array('entity_translation'),
);
}
protected function setUp() {
parent::setUp('locale', 'entity_translation', 'title', 'field_test', 'title_test');
/**
* Use the barebones "testing" installation profile.
*/
protected $profile = 'testing';
/**
* {@inheritdoc}
*/
public function setUp(array $modules = array()) {
// Core.
$modules[] = 'field_test';
$modules[] = 'locale';
$modules[] = 'taxonomy';
// Other dependencies.
$modules[] = 'entity_translation';
// This module.
$modules[] = 'title';
$modules[] = 'title_test';
parent::setUp($modules);
// Create a power user.
$admin_user = $this->drupalCreateUser(array('administer modules', 'view the administration theme', 'administer languages', 'administer taxonomy', 'administer entity translation', 'translate any entity'));
$permissions = array(
'administer modules',
'view the administration theme',
'administer languages',
'administer taxonomy',
'administer entity translation',
'translate any entity',
);
$admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
// Enable a translation language.
@@ -242,6 +71,7 @@ class TitleTranslationTestCase extends DrupalWebTestCase {
$edit = array(
'name' => $this->randomString(),
'machine_name' => $name,
'entity_translation_taxonomy' => 1,
);
$this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
$this->vocabulary = taxonomy_vocabulary_machine_name_load($name);
@@ -406,6 +236,14 @@ class TitleTranslationTestCase extends DrupalWebTestCase {
/**
* Loads a term using the given language as active language.
*
* @param int $tid
* The term identifier.
* @param string|null $langcode
* (optional) The active language to be set. Defaults to none.
*
* @return object|bool
* A term object.
*/
protected function termLoad($tid, $langcode = NULL) {
drupal_static_reset();
@@ -425,7 +263,10 @@ class TitleTranslationTestCase extends DrupalWebTestCase {
}
/**
* Checks that the field values and optionally the legacy ones match the given values.
* Checks the field values.
*
* Checks that the field values and optionally the legacy ones match the given
* values.
*/
protected function checkFieldValues($term, $values, $langcode, $legacy_match = TRUE) {
foreach ($values as $name => $value) {
@@ -438,7 +279,7 @@ class TitleTranslationTestCase extends DrupalWebTestCase {
}
/**
* Checks that the legacy field values stored in the database match the given values.
* Checks that the legacy field values in the database match the given values.
*/
protected function checkLegacyValues($term, $values) {
$record = db_query('SELECT * FROM {taxonomy_term_data} t WHERE t.tid = :tid', array(':tid' => $term->tid))->fetchAssoc();
@@ -4,12 +4,12 @@ core = 7.x
package = Testing
hidden = TRUE
dependencies[] = title
dependencies[] = taxonomy
dependencies[] = entity
dependencies[] = entity_translation
; Information added by drupal.org packaging script on 2013-04-15
version = "7.x-1.0-alpha7+4-dev"
; Information added by Drupal.org packaging script on 2020-09-21
version = "7.x-1.0-beta3+3-dev"
core = "7.x"
project = "title"
datestamp = "1366034249"
datestamp = "1600677287"
@@ -4,4 +4,3 @@
* @file
* Installation functionality for Title Test module.
*/
@@ -86,7 +86,11 @@ function title_test_phase_check($phase, $entity) {
$info = entity_get_info('test_entity');
$label_key = $info['entity keys']['label'];
$field_name = $label_key . '_field';
$value = $entity->{$label_key} == $entity->{$field_name}[LANGUAGE_NONE][0]['value'];
$langcode = LANGUAGE_NONE;
if (isset($entity->type)) {
$langcode = entity_language($entity->type, $entity);
}
$value = $entity->{$label_key} == $entity->{$field_name}[$langcode][0]['value'];
title_test_phase_store($phase, $value);
return $value;
}