Update to Drupal 8.1.5. For more information, see https://www.drupal.org/project/drupal/releases/8.1.5
This commit is contained in:
parent
13b6ca7cc2
commit
38ba7c357d
342 changed files with 7814 additions and 1534 deletions
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\action\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests that uninstalling actions does not remove other module's actions.
|
||||
*
|
||||
* @group action
|
||||
* @see \Drupal\action\Plugin\views\field\BulkForm
|
||||
*/
|
||||
class ActionUninstallTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views', 'action');
|
||||
|
||||
/**
|
||||
* Tests Action uninstall.
|
||||
*/
|
||||
public function testActionUninstall() {
|
||||
\Drupal::service('module_installer')->uninstall(array('action'));
|
||||
|
||||
$this->assertTrue(entity_load('action', 'user_block_user_action', TRUE), 'Configuration entity \'user_block_user_action\' still exists after uninstalling action module.' );
|
||||
|
||||
$admin_user = $this->drupalCreateUser(array('administer users'));
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
$this->drupalGet('admin/people');
|
||||
// Ensure we have the user_block_user_action listed.
|
||||
$this->assertRaw('<option value="user_block_user_action">Block the selected user(s)</option>');
|
||||
|
||||
}
|
||||
|
||||
}
|
156
core/modules/action/tests/src/Functional/BulkFormTest.php
Normal file
156
core/modules/action/tests/src/Functional/BulkFormTest.php
Normal file
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\action\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests the views bulk form test.
|
||||
*
|
||||
* @group action
|
||||
* @see \Drupal\action\Plugin\views\field\BulkForm
|
||||
*/
|
||||
class BulkFormTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('node', 'action_bulk_test');
|
||||
|
||||
/**
|
||||
* Tests the bulk form.
|
||||
*/
|
||||
public function testBulkForm() {
|
||||
$node_storage = $this->container->get('entity.manager')->getStorage('node');
|
||||
|
||||
// First, test an empty bulk form with the default style plugin to make sure
|
||||
// the empty region is rendered correctly.
|
||||
$this->drupalGet('test_bulk_form_empty');
|
||||
$this->assertText(t('This view is empty.'), 'Empty text found on empty bulk form.');
|
||||
|
||||
$nodes = array();
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
// Ensure nodes are sorted in the same order they are inserted in the
|
||||
// array.
|
||||
$timestamp = REQUEST_TIME - $i;
|
||||
$nodes[] = $this->drupalCreateNode(array(
|
||||
'sticky' => FALSE,
|
||||
'created' => $timestamp,
|
||||
'changed' => $timestamp,
|
||||
));
|
||||
}
|
||||
|
||||
$this->drupalGet('test_bulk_form');
|
||||
|
||||
// Test that the views edit header appears first.
|
||||
$first_form_element = $this->xpath('//form/div[1][@id = :id]', array(':id' => 'edit-header'));
|
||||
$this->assertTrue($first_form_element, 'The views form edit header appears first.');
|
||||
|
||||
$this->assertFieldById('edit-action', NULL, 'The action select field appears.');
|
||||
|
||||
// Make sure a checkbox appears on all rows.
|
||||
$edit = array();
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$this->assertFieldById('edit-node-bulk-form-' . $i, NULL, format_string('The checkbox on row @row appears.', array('@row' => $i)));
|
||||
$edit["node_bulk_form[$i]"] = TRUE;
|
||||
}
|
||||
|
||||
// Log in as a user with 'administer nodes' permission to have access to the
|
||||
// bulk operation.
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
$admin_user = $this->drupalCreateUser(['administer nodes', 'edit any page content', 'delete any page content']);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
$this->drupalGet('test_bulk_form');
|
||||
|
||||
// Set all nodes to sticky and check that.
|
||||
$edit += array('action' => 'node_make_sticky_action');
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
$changed_node = $node_storage->load($node->id());
|
||||
$this->assertTrue($changed_node->isSticky(), format_string('Node @nid got marked as sticky.', array('@nid' => $node->id())));
|
||||
}
|
||||
|
||||
$this->assertText('Make content sticky was applied to 10 items.');
|
||||
|
||||
// Unpublish just one node.
|
||||
$node = $node_storage->load($nodes[0]->id());
|
||||
$this->assertTrue($node->isPublished(), 'The node is published.');
|
||||
|
||||
$edit = array('node_bulk_form[0]' => TRUE, 'action' => 'node_unpublish_action');
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
|
||||
$this->assertText('Unpublish content was applied to 1 item.');
|
||||
|
||||
// Load the node again.
|
||||
$node_storage->resetCache(array($node->id()));
|
||||
$node = $node_storage->load($node->id());
|
||||
$this->assertFalse($node->isPublished(), 'A single node has been unpublished.');
|
||||
|
||||
// The second node should still be published.
|
||||
$node_storage->resetCache(array($nodes[1]->id()));
|
||||
$node = $node_storage->load($nodes[1]->id());
|
||||
$this->assertTrue($node->isPublished(), 'An unchecked node is still published.');
|
||||
|
||||
// Set up to include just the sticky actions.
|
||||
$view = Views::getView('test_bulk_form');
|
||||
$display = &$view->storage->getDisplay('default');
|
||||
$display['display_options']['fields']['node_bulk_form']['include_exclude'] = 'include';
|
||||
$display['display_options']['fields']['node_bulk_form']['selected_actions']['node_make_sticky_action'] = 'node_make_sticky_action';
|
||||
$display['display_options']['fields']['node_bulk_form']['selected_actions']['node_make_unsticky_action'] = 'node_make_unsticky_action';
|
||||
$view->save();
|
||||
|
||||
$this->drupalGet('test_bulk_form');
|
||||
$options = $this->xpath('//select[@id=:id]/option', array(':id' => 'edit-action'));
|
||||
$this->assertEqual(count($options), 2);
|
||||
$this->assertOption('edit-action', 'node_make_sticky_action');
|
||||
$this->assertOption('edit-action', 'node_make_unsticky_action');
|
||||
|
||||
// Set up to exclude the sticky actions.
|
||||
$view = Views::getView('test_bulk_form');
|
||||
$display = &$view->storage->getDisplay('default');
|
||||
$display['display_options']['fields']['node_bulk_form']['include_exclude'] = 'exclude';
|
||||
$view->save();
|
||||
|
||||
$this->drupalGet('test_bulk_form');
|
||||
$this->assertNoOption('edit-action', 'node_make_sticky_action');
|
||||
$this->assertNoOption('edit-action', 'node_make_unsticky_action');
|
||||
|
||||
// Check the default title.
|
||||
$this->drupalGet('test_bulk_form');
|
||||
$result = $this->xpath('//label[@for="edit-action"]');
|
||||
$this->assertEqual('With selection', $result[0]->getText());
|
||||
|
||||
// Setup up a different bulk form title.
|
||||
$view = Views::getView('test_bulk_form');
|
||||
$display = &$view->storage->getDisplay('default');
|
||||
$display['display_options']['fields']['node_bulk_form']['action_title'] = 'Test title';
|
||||
$view->save();
|
||||
|
||||
$this->drupalGet('test_bulk_form');
|
||||
$result = $this->xpath('//label[@for="edit-action"]');
|
||||
$this->assertEqual('Test title', $result[0]->getText());
|
||||
|
||||
$this->drupalGet('test_bulk_form');
|
||||
// Call the node delete action.
|
||||
$edit = array();
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$edit["node_bulk_form[$i]"] = TRUE;
|
||||
}
|
||||
$edit += array('action' => 'node_delete_action');
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
// Make sure we don't show an action message while we are still on the
|
||||
// confirmation page.
|
||||
$errors = $this->xpath('//div[contains(@class, "messages--status")]');
|
||||
$this->assertFalse($errors, 'No action message shown.');
|
||||
$this->drupalPostForm(NULL, array(), t('Delete'));
|
||||
$this->assertText(t('Deleted 5 posts.'));
|
||||
// Check if we got redirected to the original page.
|
||||
$this->assertUrl('test_bulk_form');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\action\Functional;
|
||||
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests complex actions configuration by adding, editing, and deleting a
|
||||
* complex action.
|
||||
*
|
||||
* @group action
|
||||
*/
|
||||
class ConfigurationTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('action');
|
||||
|
||||
/**
|
||||
* Tests configuration of advanced actions through administration interface.
|
||||
*/
|
||||
function testActionConfiguration() {
|
||||
// Create a user with permission to view the actions administration pages.
|
||||
$user = $this->drupalCreateUser(array('administer actions'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Make a POST request to admin/config/system/actions.
|
||||
$edit = array();
|
||||
$edit['action'] = Crypt::hashBase64('action_goto_action');
|
||||
$this->drupalPostForm('admin/config/system/actions', $edit, t('Create'));
|
||||
$this->assertResponse(200);
|
||||
|
||||
// Make a POST request to the individual action configuration page.
|
||||
$edit = array();
|
||||
$action_label = $this->randomMachineName();
|
||||
$edit['label'] = $action_label;
|
||||
$edit['id'] = strtolower($action_label);
|
||||
$edit['url'] = 'admin';
|
||||
$this->drupalPostForm('admin/config/system/actions/add/' . Crypt::hashBase64('action_goto_action'), $edit, t('Save'));
|
||||
$this->assertResponse(200);
|
||||
|
||||
// Make sure that the new complex action was saved properly.
|
||||
$this->assertText(t('The action has been successfully saved.'), "Make sure we get a confirmation that we've successfully saved the complex action.");
|
||||
$this->assertText($action_label, "Make sure the action label appears on the configuration page after we've saved the complex action.");
|
||||
|
||||
// Make another POST request to the action edit page.
|
||||
$this->clickLink(t('Configure'));
|
||||
preg_match('|admin/config/system/actions/configure/(.+)|', $this->getUrl(), $matches);
|
||||
$aid = $matches[1];
|
||||
$edit = array();
|
||||
$new_action_label = $this->randomMachineName();
|
||||
$edit['label'] = $new_action_label;
|
||||
$edit['url'] = 'admin';
|
||||
$this->drupalPostForm(NULL, $edit, t('Save'));
|
||||
$this->assertResponse(200);
|
||||
|
||||
// Make sure that the action updated properly.
|
||||
$this->assertText(t('The action has been successfully saved.'), "Make sure we get a confirmation that we've successfully updated the complex action.");
|
||||
$this->assertNoText($action_label, "Make sure the old action label does NOT appear on the configuration page after we've updated the complex action.");
|
||||
$this->assertText($new_action_label, "Make sure the action label appears on the configuration page after we've updated the complex action.");
|
||||
|
||||
$this->clickLink(t('Configure'));
|
||||
$element = $this->xpath('//input[@type="text" and @value="admin"]');
|
||||
$this->assertTrue(!empty($element), 'Make sure the URL appears when re-editing the action.');
|
||||
|
||||
// Make sure that deletions work properly.
|
||||
$this->drupalGet('admin/config/system/actions');
|
||||
$this->clickLink(t('Delete'));
|
||||
$this->assertResponse(200);
|
||||
$edit = array();
|
||||
$this->drupalPostForm("admin/config/system/actions/configure/$aid/delete", $edit, t('Delete'));
|
||||
$this->assertResponse(200);
|
||||
|
||||
// Make sure that the action was actually deleted.
|
||||
$this->assertRaw(t('The action %action has been deleted.', array('%action' => $new_action_label)), 'Make sure that we get a delete confirmation message.');
|
||||
$this->drupalGet('admin/config/system/actions');
|
||||
$this->assertResponse(200);
|
||||
$this->assertNoText($new_action_label, "Make sure the action label does not appear on the overview page after we've deleted the action.");
|
||||
|
||||
$action = entity_load('action', $aid);
|
||||
$this->assertFalse($action, 'Make sure the action is gone after being deleted.');
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue