Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 
  • In Drupal 7, drupalPost() and drupalPostAJAX() both have deeply embedded assumptions that they're being applied to forms.
  • In Drupal 8, we now have POST requests that receive application/json and application/vnd.drupal-ajax responses. (e.g. rendering of AJAXy Views, contextual links, Edit module's metadata, etc.). Hence there is a need to simulate HTTP POST requests that aren't processed by a form controller. These were condemned to use curlExec() directly.
  • A new drupalPost() method, with a different signature than Drupal 7 one, has been introduced in Drupal 8 to deal with these requirements.
  • The former drupalPost() and drupalPostAJAX() methods have been renamed, while retaining the original arguments:
    • drupalPost()drupalPostForm()
    • drupalPostAJAX()drupalPostAjaxForm()

Code example

Before (Drupal 7):
<?php
  
...
  
$this->drupalPost('admin/config/development/logging', $edit, t('Save configuration'));
   ...
?>

After (Drupal 8):
<?php
  
...
 
$this->drupalPostForm('admin/config/development/logging', $edit, t('Save configuration'));
   ...
?>
Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done