Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
|
@ -2,61 +2,9 @@
|
|||
|
||||
namespace Drupal\quickedit\Access;
|
||||
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
use Drupal\Core\Routing\Access\AccessInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
||||
/**
|
||||
* Access check for editing entity fields.
|
||||
* @deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0.
|
||||
*/
|
||||
class EditEntityFieldAccessCheck implements AccessInterface, EditEntityFieldAccessCheckInterface {
|
||||
|
||||
/**
|
||||
* Checks Quick Edit access to the field.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity containing the field.
|
||||
* @param string $field_name
|
||||
* The field name.
|
||||
* @param string $langcode
|
||||
* The langcode.
|
||||
* @param \Drupal\Core\Session\AccountInterface $account
|
||||
* The currently logged in account.
|
||||
*
|
||||
* @return \Drupal\Core\Access\AccessResultInterface
|
||||
* The access result.
|
||||
*
|
||||
* @todo Use the $account argument: https://www.drupal.org/node/2266809.
|
||||
*/
|
||||
public function access(EntityInterface $entity, $field_name, $langcode, AccountInterface $account) {
|
||||
if (!$this->validateRequestAttributes($entity, $field_name, $langcode)) {
|
||||
return AccessResult::forbidden();
|
||||
}
|
||||
|
||||
return $this->accessEditEntityField($entity, $field_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function accessEditEntityField(EntityInterface $entity, $field_name) {
|
||||
return $entity->access('update', NULL, TRUE)->andIf($entity->get($field_name)->access('edit', NULL, TRUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates request attributes.
|
||||
*/
|
||||
protected function validateRequestAttributes(EntityInterface $entity, $field_name, $langcode) {
|
||||
// Validate the field name and language.
|
||||
if (!$field_name || !$entity->hasField($field_name)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (!$langcode || !$entity->hasTranslation($langcode)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
class EditEntityFieldAccessCheck extends QuickEditEntityFieldAccessCheck {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,24 +2,9 @@
|
|||
|
||||
namespace Drupal\quickedit\Access;
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
||||
/**
|
||||
* Access check for editing entity fields.
|
||||
* @deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0.
|
||||
*/
|
||||
interface EditEntityFieldAccessCheckInterface {
|
||||
|
||||
/**
|
||||
* Checks access to edit the requested field of the requested entity.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity.
|
||||
* @param string $field_name
|
||||
* The field name.
|
||||
*
|
||||
* @return \Drupal\Core\Access\AccessResultInterface
|
||||
* The access result.
|
||||
*/
|
||||
public function accessEditEntityField(EntityInterface $entity, $field_name);
|
||||
interface EditEntityFieldAccessCheckInterface extends QuickEditEntityFieldAccessCheckInterface {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\quickedit\Access;
|
||||
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
use Drupal\Core\Routing\Access\AccessInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
||||
/**
|
||||
* Access check for in-place editing entity fields.
|
||||
*/
|
||||
class QuickEditEntityFieldAccessCheck implements AccessInterface, QuickEditEntityFieldAccessCheckInterface {
|
||||
|
||||
/**
|
||||
* Checks Quick Edit access to the field.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity containing the field.
|
||||
* @param string $field_name
|
||||
* The field name.
|
||||
* @param string $langcode
|
||||
* The langcode.
|
||||
* @param \Drupal\Core\Session\AccountInterface $account
|
||||
* The currently logged in account.
|
||||
*
|
||||
* @return \Drupal\Core\Access\AccessResultInterface
|
||||
* The access result.
|
||||
*
|
||||
* @todo Use the $account argument: https://www.drupal.org/node/2266809.
|
||||
*/
|
||||
public function access(EntityInterface $entity, $field_name, $langcode, AccountInterface $account) {
|
||||
if (!$this->validateRequestAttributes($entity, $field_name, $langcode)) {
|
||||
return AccessResult::forbidden();
|
||||
}
|
||||
|
||||
return $this->accessEditEntityField($entity, $field_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function accessEditEntityField(EntityInterface $entity, $field_name) {
|
||||
return $entity->access('update', NULL, TRUE)->andIf($entity->get($field_name)->access('edit', NULL, TRUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates request attributes.
|
||||
*/
|
||||
protected function validateRequestAttributes(EntityInterface $entity, $field_name, $langcode) {
|
||||
// Validate the field name and language.
|
||||
if (!$field_name || !$entity->hasField($field_name)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (!$langcode || !$entity->hasTranslation($langcode)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\quickedit\Access;
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
||||
/**
|
||||
* Access check for in-place editing entity fields.
|
||||
*/
|
||||
interface QuickEditEntityFieldAccessCheckInterface {
|
||||
|
||||
/**
|
||||
* Checks access to edit the requested field of the requested entity.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity.
|
||||
* @param string $field_name
|
||||
* The field name.
|
||||
*
|
||||
* @return \Drupal\Core\Access\AccessResultInterface
|
||||
* The access result.
|
||||
*/
|
||||
public function accessEditEntityField(EntityInterface $entity, $field_name);
|
||||
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ class EditorSelector implements EditorSelectorInterface {
|
|||
/**
|
||||
* The manager for formatter plugins.
|
||||
*
|
||||
* @var \Drupal\Core\Field\FormatterPluginManager.
|
||||
* @var \Drupal\Core\Field\FormatterPluginManager
|
||||
*/
|
||||
protected $formatterManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,19 +10,20 @@ use Drupal\Core\Form\FormBase;
|
|||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Render\Element;
|
||||
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
||||
use Drupal\user\PrivateTempStoreFactory;
|
||||
use Drupal\Core\TempStore\PrivateTempStoreFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
/**
|
||||
* Builds and process a form for editing a single entity field.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class QuickEditFieldForm extends FormBase {
|
||||
|
||||
/**
|
||||
* Stores the tempstore factory.
|
||||
*
|
||||
* @var \Drupal\user\PrivateTempStoreFactory
|
||||
* @var \Drupal\Core\TempStore\PrivateTempStoreFactory
|
||||
*/
|
||||
protected $tempStoreFactory;
|
||||
|
||||
|
|
@ -40,30 +41,20 @@ class QuickEditFieldForm extends FormBase {
|
|||
*/
|
||||
protected $nodeTypeStorage;
|
||||
|
||||
/**
|
||||
* The typed data validator.
|
||||
*
|
||||
* @var \Symfony\Component\Validator\Validator\ValidatorInterface
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* Constructs a new EditFieldForm.
|
||||
*
|
||||
* @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory
|
||||
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
|
||||
* The tempstore factory.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler.
|
||||
* @param \Drupal\Core\Entity\EntityStorageInterface $node_type_storage
|
||||
* The node type storage.
|
||||
* @param \Symfony\Component\Validator\Validator\ValidatorInterface $validator
|
||||
* The typed data validator service.
|
||||
*/
|
||||
public function __construct(PrivateTempStoreFactory $temp_store_factory, ModuleHandlerInterface $module_handler, EntityStorageInterface $node_type_storage, ValidatorInterface $validator) {
|
||||
public function __construct(PrivateTempStoreFactory $temp_store_factory, ModuleHandlerInterface $module_handler, EntityStorageInterface $node_type_storage) {
|
||||
$this->moduleHandler = $module_handler;
|
||||
$this->nodeTypeStorage = $node_type_storage;
|
||||
$this->tempStoreFactory = $temp_store_factory;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -71,10 +62,9 @@ class QuickEditFieldForm extends FormBase {
|
|||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('user.private_tempstore'),
|
||||
$container->get('tempstore.private'),
|
||||
$container->get('module_handler'),
|
||||
$container->get('entity.manager')->getStorage('node_type'),
|
||||
$container->get('typed_data_manager')->getValidator()
|
||||
$container->get('entity.manager')->getStorage('node_type')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -114,6 +104,10 @@ class QuickEditFieldForm extends FormBase {
|
|||
'#attributes' => ['class' => ['quickedit-form-submit']],
|
||||
];
|
||||
|
||||
// Use the non-inline form error display for Quick Edit forms, because in
|
||||
// this case the errors are already near the form element.
|
||||
$form['#disable_inline_form_errors'] = TRUE;
|
||||
|
||||
// Simplify it for optimal in-place use.
|
||||
$this->simplify($form, $form_state);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace Drupal\quickedit;
|
|||
use Drupal\Component\Plugin\PluginManagerInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface;
|
||||
use Drupal\quickedit\Access\QuickEditEntityFieldAccessCheckInterface;
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
|
||||
/**
|
||||
|
|
@ -16,7 +16,7 @@ class MetadataGenerator implements MetadataGeneratorInterface {
|
|||
/**
|
||||
* An object that checks if a user has access to edit a given entity field.
|
||||
*
|
||||
* @var \Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface
|
||||
* @var \Drupal\quickedit\Access\QuickEditEntityFieldAccessCheckInterface
|
||||
*/
|
||||
protected $accessChecker;
|
||||
|
||||
|
|
@ -37,14 +37,14 @@ class MetadataGenerator implements MetadataGeneratorInterface {
|
|||
/**
|
||||
* Constructs a new MetadataGenerator.
|
||||
*
|
||||
* @param \Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface $access_checker
|
||||
* @param \Drupal\quickedit\Access\QuickEditEntityFieldAccessCheckInterface $access_checker
|
||||
* An object that checks if a user has access to edit a given field.
|
||||
* @param \Drupal\quickedit\EditorSelectorInterface $editor_selector
|
||||
* An object that determines which editor to attach to a given field.
|
||||
* @param \Drupal\Component\Plugin\PluginManagerInterface $editor_manager
|
||||
* The manager for editor plugins.
|
||||
*/
|
||||
public function __construct(EditEntityFieldAccessCheckInterface $access_checker, EditorSelectorInterface $editor_selector, PluginManagerInterface $editor_manager) {
|
||||
public function __construct(QuickEditEntityFieldAccessCheckInterface $access_checker, EditorSelectorInterface $editor_selector, PluginManagerInterface $editor_manager) {
|
||||
$this->accessChecker = $access_checker;
|
||||
$this->editorSelector = $editor_selector;
|
||||
$this->editorManager = $editor_manager;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace Drupal\quickedit;
|
|||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\Core\Render\RendererInterface;
|
||||
use Drupal\user\PrivateTempStoreFactory;
|
||||
use Drupal\Core\TempStore\PrivateTempStoreFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
@ -25,7 +25,7 @@ class QuickEditController extends ControllerBase {
|
|||
/**
|
||||
* The PrivateTempStore factory.
|
||||
*
|
||||
* @var \Drupal\user\PrivateTempStoreFactory
|
||||
* @var \Drupal\Core\TempStore\PrivateTempStoreFactory
|
||||
*/
|
||||
protected $tempStoreFactory;
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ class QuickEditController extends ControllerBase {
|
|||
/**
|
||||
* Constructs a new QuickEditController.
|
||||
*
|
||||
* @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory
|
||||
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
|
||||
* The PrivateTempStore factory.
|
||||
* @param \Drupal\quickedit\MetadataGeneratorInterface $metadata_generator
|
||||
* The in-place editing metadata generator.
|
||||
|
|
@ -74,7 +74,7 @@ class QuickEditController extends ControllerBase {
|
|||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('user.private_tempstore'),
|
||||
$container->get('tempstore.private'),
|
||||
$container->get('quickedit.metadata.generator'),
|
||||
$container->get('quickedit.editor.selector'),
|
||||
$container->get('renderer')
|
||||
|
|
@ -221,7 +221,7 @@ class QuickEditController extends ControllerBase {
|
|||
$errors = $form_state->getErrors();
|
||||
if (count($errors)) {
|
||||
$status_messages = [
|
||||
'#type' => 'status_messages'
|
||||
'#type' => 'status_messages',
|
||||
];
|
||||
$response->addCommand(new FieldFormValidationErrorsCommand($this->renderer->renderRoot($status_messages)));
|
||||
}
|
||||
|
|
@ -293,7 +293,7 @@ class QuickEditController extends ControllerBase {
|
|||
// to identify it.
|
||||
$output = [
|
||||
'entity_type' => $entity->getEntityTypeId(),
|
||||
'entity_id' => $entity->id()
|
||||
'entity_id' => $entity->id(),
|
||||
];
|
||||
|
||||
// Respond to client that the entity was saved properly.
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ use Drupal\Component\Serialization\Json;
|
|||
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\Tests\field\Traits\EntityReferenceTestTrait;
|
||||
|
||||
/**
|
||||
* Tests in-place editing of autocomplete tags.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace Drupal\quickedit\Tests;
|
||||
|
||||
use Drupal\Component\Serialization\Json;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\block_content\Entity\BlockContent;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
|
@ -42,6 +41,13 @@ class QuickEditLoadingTest extends WebTestBase {
|
|||
*/
|
||||
protected $authorUser;
|
||||
|
||||
/**
|
||||
* A test node.
|
||||
*
|
||||
* @var \Drupal\node\NodeInterface
|
||||
*/
|
||||
protected $testNode;
|
||||
|
||||
/**
|
||||
* A author user with permissions to access in-place editor.
|
||||
*
|
||||
|
|
@ -74,13 +80,13 @@ class QuickEditLoadingTest extends WebTestBase {
|
|||
$node_type->save();
|
||||
|
||||
// Create one node of the above node type using the above text format.
|
||||
$this->drupalCreateNode([
|
||||
$this->testNode = $this->drupalCreateNode([
|
||||
'type' => 'article',
|
||||
'body' => [
|
||||
0 => [
|
||||
'value' => '<p>How are you?</p>',
|
||||
'format' => 'filtered_html',
|
||||
]
|
||||
],
|
||||
],
|
||||
'revision_log' => $this->randomString(),
|
||||
]);
|
||||
|
|
@ -115,12 +121,12 @@ class QuickEditLoadingTest extends WebTestBase {
|
|||
$this->assertIdentical(Json::encode(['message' => "The 'access in-place editing' permission is required."]), $response);
|
||||
$this->assertResponse(403);
|
||||
|
||||
// Quick Edit's JavaScript would SearchRankingTestnever hit these endpoints if the metadata
|
||||
// Quick Edit's JavaScript would never hit these endpoints if the metadata
|
||||
// was empty as above, but we need to make sure that malicious users aren't
|
||||
// able to use any of the other endpoints either.
|
||||
$post = ['editors[0]' => 'form'] + $this->getAjaxPageStatePostData();
|
||||
$response = $this->drupalPost('quickedit/attachments', '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
|
||||
$message = Json::encode(['message' => "A fatal error occurred: The 'access in-place editing' permission is required."]);
|
||||
$message = Json::encode(['message' => "The 'access in-place editing' permission is required."]);
|
||||
$this->assertIdentical($message, $response);
|
||||
$this->assertResponse(403);
|
||||
$post = ['nocssjs' => 'true'] + $this->getAjaxPageStatePostData();
|
||||
|
|
@ -181,7 +187,7 @@ class QuickEditLoadingTest extends WebTestBase {
|
|||
'label' => 'Body',
|
||||
'access' => TRUE,
|
||||
'editor' => 'form',
|
||||
]
|
||||
],
|
||||
];
|
||||
$this->assertIdentical(Json::decode($response), $expected, 'The metadata HTTP request answers with the correct JSON response.');
|
||||
// Restore drupalSettings to build the next requests; simpletest wipes them
|
||||
|
|
@ -209,7 +215,7 @@ class QuickEditLoadingTest extends WebTestBase {
|
|||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
|
||||
$this->assertIdentical('quickeditFieldForm', $ajax_commands[0]['command'], 'The first AJAX command is a quickeditFieldForm command.');
|
||||
$this->assertIdentical('<form ', Unicode::substr($ajax_commands[0]['data'], 0, 6), 'The quickeditFieldForm command contains a form.');
|
||||
$this->assertIdentical('<form ', mb_substr($ajax_commands[0]['data'], 0, 6), 'The quickeditFieldForm command contains a form.');
|
||||
|
||||
// Prepare form values for submission. drupalPostAjaxForm() is not suitable
|
||||
// for handling pages with JSON responses, so we need our own solution here.
|
||||
|
|
@ -279,7 +285,7 @@ class QuickEditLoadingTest extends WebTestBase {
|
|||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
|
||||
$this->assertIdentical('quickeditFieldForm', $ajax_commands[0]['command'], 'The first AJAX command is a quickeditFieldForm command.');
|
||||
$this->assertIdentical('<form ', Unicode::substr($ajax_commands[0]['data'], 0, 6), 'The quickeditFieldForm command contains a form.');
|
||||
$this->assertIdentical('<form ', mb_substr($ajax_commands[0]['data'], 0, 6), 'The quickeditFieldForm command contains a form.');
|
||||
|
||||
// Submit field form.
|
||||
preg_match('/\sname="form_token" value="([^"]+)"/', $ajax_commands[0]['data'], $token_match);
|
||||
|
|
@ -317,6 +323,34 @@ class QuickEditLoadingTest extends WebTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test quickedit does not appear for entities with pending revisions.
|
||||
*/
|
||||
public function testWithPendingRevision() {
|
||||
$this->drupalLogin($this->editorUser);
|
||||
|
||||
// Verify that the preview is loaded correctly.
|
||||
$this->drupalPostForm('node/add/article', ['title[0][value]' => 'foo'], 'Preview');
|
||||
$this->assertResponse(200);
|
||||
// Verify that quickedit is not active on preview.
|
||||
$this->assertNoRaw('data-quickedit-entity-id="node/' . $this->testNode->id() . '"');
|
||||
$this->assertNoRaw('data-quickedit-field-id="node/' . $this->testNode->id() . '/title/' . $this->testNode->language()->getId() . '/full"');
|
||||
|
||||
$this->drupalGet('node/' . $this->testNode->id());
|
||||
$this->assertRaw('data-quickedit-entity-id="node/' . $this->testNode->id() . '"');
|
||||
$this->assertRaw('data-quickedit-field-id="node/' . $this->testNode->id() . '/title/' . $this->testNode->language()->getId() . '/full"');
|
||||
|
||||
$this->testNode->title = 'Updated node';
|
||||
$this->testNode->setNewRevision(TRUE);
|
||||
$this->testNode->isDefaultRevision(FALSE);
|
||||
$this->testNode->save();
|
||||
|
||||
$this->drupalGet('node/' . $this->testNode->id());
|
||||
$this->assertResponse(200);
|
||||
$this->assertNoRaw('data-quickedit-entity-id="node/' . $this->testNode->id() . '"');
|
||||
$this->assertNoRaw('data-quickedit-field-id="node/' . $this->testNode->id() . '/title/' . $this->testNode->language()->getId() . '/full"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the loading of Quick Edit for the title base field.
|
||||
*/
|
||||
|
|
@ -339,7 +373,7 @@ class QuickEditLoadingTest extends WebTestBase {
|
|||
'label' => 'Title',
|
||||
'access' => TRUE,
|
||||
'editor' => 'plain_text',
|
||||
]
|
||||
],
|
||||
];
|
||||
$this->assertIdentical(Json::decode($response), $expected, 'The metadata HTTP request answers with the correct JSON response.');
|
||||
// Restore drupalSettings to build the next requests; simpletest wipes them
|
||||
|
|
@ -354,7 +388,7 @@ class QuickEditLoadingTest extends WebTestBase {
|
|||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
|
||||
$this->assertIdentical('quickeditFieldForm', $ajax_commands[0]['command'], 'The first AJAX command is a quickeditFieldForm command.');
|
||||
$this->assertIdentical('<form ', Unicode::substr($ajax_commands[0]['data'], 0, 6), 'The quickeditFieldForm command contains a form.');
|
||||
$this->assertIdentical('<form ', mb_substr($ajax_commands[0]['data'], 0, 6), 'The quickeditFieldForm command contains a form.');
|
||||
|
||||
// Prepare form values for submission. drupalPostAjaxForm() is not suitable
|
||||
// for handling pages with JSON responses, so we need our own solution
|
||||
|
|
@ -567,7 +601,7 @@ class QuickEditLoadingTest extends WebTestBase {
|
|||
$response = $this->drupalPost('quickedit/form/node/1/field_image/en/full', '', ['nocssjs' => 'true'] + $this->getAjaxPageStatePostData(), ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
|
||||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical('<form ', Unicode::substr($ajax_commands[0]['data'], 0, 6), 'The quickeditFieldForm command contains a form.');
|
||||
$this->assertIdentical('<form ', mb_substr($ajax_commands[0]['data'], 0, 6), 'The quickeditFieldForm command contains a form.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue