Merge branch '8.x' of git.drupal.org:project/drupal into 8.x
commit
35f0000e3e
|
@ -8,7 +8,7 @@
|
|||
namespace Drupal\Component\Uuid;
|
||||
|
||||
/**
|
||||
* Generates an UUID v4 using PHP code.
|
||||
* Generates a UUID v4 using PHP code.
|
||||
*
|
||||
* Loosely based on Ruby's UUIDTools generate_random logic.
|
||||
*
|
||||
|
|
|
@ -31,7 +31,7 @@ class Uuid {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generates an universally unique identifier.
|
||||
* Generates a universally unique identifier.
|
||||
*
|
||||
* @see Drupal\Component\Uuid\UuidInterface::generate()
|
||||
*/
|
||||
|
|
|
@ -366,7 +366,7 @@ function comment_update_8002() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generate an UUID for all comments.
|
||||
* Generate a UUID for all comments.
|
||||
*/
|
||||
function comment_update_8003(&$sandbox) {
|
||||
if (!isset($sandbox['progress'])) {
|
||||
|
|
|
@ -191,7 +191,17 @@ function _field_sql_storage_schema($field) {
|
|||
foreach ($field['indexes'] as $index_name => $columns) {
|
||||
$real_name = _field_sql_storage_indexname($field['field_name'], $index_name);
|
||||
foreach ($columns as $column_name) {
|
||||
$current['indexes'][$real_name][] = _field_sql_storage_columnname($field['field_name'], $column_name);
|
||||
// Indexes can be specified as either a column name or an array with
|
||||
// column name and length. Allow for either case.
|
||||
if (is_array($column_name)) {
|
||||
$current['indexes'][$real_name][] = array(
|
||||
_field_sql_storage_columnname($field['field_name'], $column_name[0]),
|
||||
$column_name[1],
|
||||
);
|
||||
}
|
||||
else {
|
||||
$current['indexes'][$real_name][] = _field_sql_storage_columnname($field['field_name'], $column_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,7 +310,17 @@ function field_sql_storage_field_storage_update_field($field, $prior_field, $has
|
|||
$real_name = _field_sql_storage_indexname($field['field_name'], $name);
|
||||
$real_columns = array();
|
||||
foreach ($columns as $column_name) {
|
||||
$real_columns[] = _field_sql_storage_columnname($field['field_name'], $column_name);
|
||||
// Indexes can be specified as either a column name or an array with
|
||||
// column name and length. Allow for either case.
|
||||
if (is_array($column_name)) {
|
||||
$real_columns[] = array(
|
||||
_field_sql_storage_columnname($field['field_name'], $column_name[0]),
|
||||
$column_name[1],
|
||||
);
|
||||
}
|
||||
else {
|
||||
$real_columns[] = _field_sql_storage_columnname($field['field_name'], $column_name);
|
||||
}
|
||||
}
|
||||
db_add_index($table, $real_name, $real_columns);
|
||||
db_add_index($revision_table, $real_name, $real_columns);
|
||||
|
|
|
@ -372,14 +372,14 @@ class FieldSqlStorageTest extends WebTestBase {
|
|||
field_attach_insert('test_entity', $entity);
|
||||
|
||||
// Add an index
|
||||
$field = array('field_name' => $field_name, 'indexes' => array('value' => array('value')));
|
||||
$field = array('field_name' => $field_name, 'indexes' => array('value' => array(array('value', 255))));
|
||||
field_update_field($field);
|
||||
foreach ($tables as $table) {
|
||||
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in $table"));
|
||||
}
|
||||
|
||||
// Add a different index, removing the existing custom one.
|
||||
$field = array('field_name' => $field_name, 'indexes' => array('value_format' => array('value', 'format')));
|
||||
$field = array('field_name' => $field_name, 'indexes' => array('value_format' => array(array('value', 127), array('format', 127))));
|
||||
field_update_field($field);
|
||||
foreach ($tables as $table) {
|
||||
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), t("Index on value_format created in $table"));
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of Drupal\node\Tests\NodeEntityViewModeAlterTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\node\Tests;
|
||||
|
||||
/**
|
||||
* Tests changing view modes for nodes.
|
||||
*/
|
||||
class NodeEntityViewModeAlterTest extends NodeTestBase {
|
||||
|
||||
/**
|
||||
* Enable dummy module that implements hook_node_view().
|
||||
*/
|
||||
public static $modules = array('node_test');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Node entity view mode',
|
||||
'description' => 'Test changing view mode.',
|
||||
'group' => 'Node'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a "Basic page" node and verify its consistency in the database.
|
||||
*/
|
||||
function testNodeViewModeChange() {
|
||||
$web_user = $this->drupalCreateUser(array('create page content', 'edit own page content'));
|
||||
$this->drupalLogin($web_user);
|
||||
|
||||
// Create a node.
|
||||
$edit = array();
|
||||
$langcode = LANGUAGE_NOT_SPECIFIED;
|
||||
$edit["title"] = $this->randomName(8);
|
||||
$edit["body[$langcode][0][value]"] = t('Data that should appear only in the body for the node.');
|
||||
$edit["body[$langcode][0][summary]"] = t('Extra data that should appear only in the teaser for the node.');
|
||||
$this->drupalPost('node/add/page', $edit, t('Save'));
|
||||
|
||||
$node = $this->drupalGetNodeByTitle($edit["title"]);
|
||||
|
||||
// Set the flag to alter the view mode and view the node.
|
||||
variable_set('node_test_change_view_mode', 'teaser');
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
|
||||
// Check that teaser mode is viewed.
|
||||
$this->assertText('Extra data that should appear only in the teaser for the node.', 'Teaser text present');
|
||||
// Make sure body text is not present.
|
||||
$this->assertNoText('Data that should appear only in the body for the node.', 'Body text not present');
|
||||
|
||||
// Test that the correct build mode has been set.
|
||||
$build = node_view($node);
|
||||
$this->assertEqual($build['#view_mode'], 'teaser', 'The view mode has correctly been set to teaser.');
|
||||
}
|
||||
}
|
|
@ -662,7 +662,7 @@ function node_update_8005() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generate an UUID for all nodes.
|
||||
* Generate a UUID for all nodes.
|
||||
*/
|
||||
function node_update_8006(&$sandbox) {
|
||||
if (!isset($sandbox['progress'])) {
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Ajax;
|
|||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Base test system for AJAX tests.
|
||||
* Provides a base class for Ajax tests.
|
||||
*/
|
||||
abstract class AjaxTestBase extends WebTestBase {
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class FormValuesTest extends AjaxTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Submits forms with select and checkbox elements via AJAX.
|
||||
* Submits forms with select and checkbox elements via Ajax.
|
||||
*/
|
||||
function testSimpleAjaxFormValue() {
|
||||
// Verify form values of a select element.
|
||||
|
|
|
@ -69,7 +69,7 @@ class FrameworkTest extends AjaxTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that new JavaScript and CSS files are returned on an AJAX request.
|
||||
* Tests that new JavaScript and CSS files are returned on an Ajax request.
|
||||
*/
|
||||
function testLazyLoad() {
|
||||
$expected = array(
|
||||
|
@ -103,7 +103,7 @@ class FrameworkTest extends AjaxTestBase {
|
|||
$this->assertTrue(!isset($original_settings[$expected['css']]), format_string('Page originally lacks the %css file, as expected.', array('%css' => $expected['css'])));
|
||||
$this->assertTrue(!isset($original_settings[$expected['js']]), format_string('Page originally lacks the %js file, as expected.', array('%js' => $expected['js'])));
|
||||
|
||||
// Submit the AJAX request without triggering files getting added.
|
||||
// Submit the Ajax request without triggering files getting added.
|
||||
$commands = $this->drupalPostAJAX(NULL, array('add_files' => FALSE), array('op' => t('Submit')));
|
||||
$new_settings = $this->drupalGetSettings();
|
||||
|
||||
|
@ -124,7 +124,7 @@ class FrameworkTest extends AjaxTestBase {
|
|||
$this->assertFalse($found_settings_command, format_string('Page state still lacks the %css and %js files, as expected.', array('%css' => $expected['css'], '%js' => $expected['js'])));
|
||||
$this->assertFalse($found_markup_command, format_string('Page still lacks the %css and %js files, as expected.', array('%css' => $expected['css'], '%js' => $expected['js'])));
|
||||
|
||||
// Submit the AJAX request and trigger adding files.
|
||||
// Submit the Ajax request and trigger adding files.
|
||||
$commands = $this->drupalPostAJAX(NULL, array('add_files' => TRUE), array('op' => t('Submit')));
|
||||
$new_settings = $this->drupalGetSettings();
|
||||
$new_css = $new_settings['ajaxPageState']['css'];
|
||||
|
@ -134,12 +134,12 @@ class FrameworkTest extends AjaxTestBase {
|
|||
$this->assertIdentical($new_settings[$expected['setting_name']], $expected['setting_value'], format_string('Page now has the %setting.', array('%setting' => $expected['setting_name'])));
|
||||
|
||||
// Verify the expected CSS file was added, both to Drupal.settings, and as
|
||||
// an AJAX command for inclusion into the HTML.
|
||||
// an Ajax command for inclusion into the HTML.
|
||||
$this->assertEqual($new_css, $original_css + array($expected['css'] => 1), format_string('Page state now has the %css file.', array('%css' => $expected['css'])));
|
||||
$this->assertCommand($commands, array('data' => $expected_css_html), format_string('Page now has the %css file.', array('%css' => $expected['css'])));
|
||||
|
||||
// Verify the expected JS file was added, both to Drupal.settings, and as
|
||||
// an AJAX command for inclusion into the HTML. By testing for an exact HTML
|
||||
// an Ajax command for inclusion into the HTML. By testing for an exact HTML
|
||||
// string containing the SCRIPT tag, we also ensure that unexpected
|
||||
// JavaScript code, such as a jQuery.extend() that would potentially clobber
|
||||
// rather than properly merge settings, didn't accidentally get added.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Drupal\system\Tests\Ajax;
|
||||
|
||||
/**
|
||||
* Tests that Ajax-enabled forms work when multiple instances of the same form are on a page.
|
||||
* Tests Ajax-enabled forms functionality with multiple instances of the form.
|
||||
*/
|
||||
class MultiFormTest extends AjaxTestBase {
|
||||
|
||||
|
@ -53,7 +53,7 @@ class MultiFormTest extends AjaxTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that pages with the 'page_node_form' included twice works correctly.
|
||||
* Tests that pages with the 'page_node_form' included twice work correctly.
|
||||
*/
|
||||
function testMultiForm() {
|
||||
// HTML IDs for elements within the field are potentially modified with
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Batch;
|
|||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests for the Batch API Progress page.
|
||||
* Tests the Batch API Progress page.
|
||||
*/
|
||||
class PageTest extends WebTestBase {
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Batch;
|
|||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests for the Batch API.
|
||||
* Tests the Batch API.
|
||||
*/
|
||||
class ProcessingTest extends WebTestBase {
|
||||
|
||||
|
@ -166,6 +166,7 @@ class ProcessingTest extends WebTestBase {
|
|||
* Array of raw strings to look for .
|
||||
* @param $message
|
||||
* Message to display.
|
||||
*
|
||||
* @return
|
||||
* TRUE on pass, FALSE on fail.
|
||||
*/
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Bundle;
|
|||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Test bundle registration to the DIC.
|
||||
* Tests bundle registration to the DIC.
|
||||
*/
|
||||
class BundleTest extends WebTestBase {
|
||||
|
||||
|
@ -30,7 +30,7 @@ class BundleTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test that services provided by module bundles get registered to the DIC.
|
||||
* Tests that services provided by module bundles get registered to the DIC.
|
||||
*/
|
||||
function testBundleRegistration() {
|
||||
$this->assertTrue(drupal_container()->getDefinition('file.usage')->getClass() == 'Drupal\\bundle_test\\TestFileUsage', 'Class has been changed');
|
||||
|
|
|
@ -41,7 +41,7 @@ abstract class CacheTestBase extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Assert or a cache entry exists.
|
||||
* Asserts that a cache entry exists.
|
||||
*
|
||||
* @param $message
|
||||
* Message to display.
|
||||
|
@ -67,7 +67,7 @@ abstract class CacheTestBase extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Assert or a cache entry has been removed.
|
||||
* Asserts that a cache entry has been removed.
|
||||
*
|
||||
* @param $message
|
||||
* Message to display.
|
||||
|
|
|
@ -22,14 +22,26 @@ class DatabaseBackendUnitTest extends GenericCacheBackendUnitTestBase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of DatabaseBackend.
|
||||
*
|
||||
* @return
|
||||
* A new DatabaseBackend object.
|
||||
*/
|
||||
protected function createCacheBackend($bin) {
|
||||
return new DatabaseBackend($bin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs system schema.
|
||||
*/
|
||||
public function setUpCacheBackend() {
|
||||
drupal_install_schema('system');
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls system schema.
|
||||
*/
|
||||
public function tearDownCacheBackend() {
|
||||
drupal_uninstall_schema('system');
|
||||
}
|
||||
|
|
|
@ -13,8 +13,10 @@ use Drupal\simpletest\UnitTestBase;
|
|||
use stdClass;
|
||||
|
||||
/**
|
||||
* Tests any cache backend.
|
||||
*
|
||||
* Full generic unit test suite for any cache backend. In order to use it for a
|
||||
* cache backend implementation extend this class and override the
|
||||
* cache backend implementation, extend this class and override the
|
||||
* createBackendInstace() method to return an object.
|
||||
*
|
||||
* @see DatabaseBackendUnitTestCase
|
||||
|
@ -44,7 +46,7 @@ abstract class GenericCacheBackendUnitTestBase extends UnitTestBase {
|
|||
protected $defaultValue;
|
||||
|
||||
/**
|
||||
* Get testing bin.
|
||||
* Gets the testing bin.
|
||||
*
|
||||
* Override this method if you want to work on a different bin than the
|
||||
* default one.
|
||||
|
@ -60,7 +62,7 @@ abstract class GenericCacheBackendUnitTestBase extends UnitTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a cache backend to test.
|
||||
* Creates a cache backend to test.
|
||||
*
|
||||
* Override this method to test a CacheBackend.
|
||||
*
|
||||
|
@ -73,21 +75,22 @@ abstract class GenericCacheBackendUnitTestBase extends UnitTestBase {
|
|||
protected abstract function createCacheBackend($bin);
|
||||
|
||||
/**
|
||||
* Allow specific implementation to change the environement before test run.
|
||||
* Allows specific implementation to change the environment before a test run.
|
||||
*/
|
||||
public function setUpCacheBackend() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow specific implementation to alter the environement after test run but
|
||||
* before the real tear down, which will changes things such as the database
|
||||
* prefix.
|
||||
* Allows alteration of environment after a test run but before tear down.
|
||||
*
|
||||
* Used before the real tear down because the tear down will change things
|
||||
* such as the database prefix.
|
||||
*/
|
||||
public function tearDownCacheBackend() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get backend to test, this will get a shared instance set in the object.
|
||||
* Gets a backend to test; this will get a shared instance set in the object.
|
||||
*
|
||||
* @return Drupal\Core\Cache\CacheBackendInterface
|
||||
* Cache backend to test.
|
||||
|
@ -335,7 +338,7 @@ abstract class GenericCacheBackendUnitTestBase extends UnitTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test Drupal\Core\Cache\CacheBackendInterface::flush().
|
||||
* Tests Drupal\Core\Cache\CacheBackendInterface::flush().
|
||||
*/
|
||||
public function testFlush() {
|
||||
$backend = $this->getCacheBackend();
|
||||
|
|
|
@ -22,6 +22,12 @@ class MemoryBackendUnitTest extends GenericCacheBackendUnitTestBase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of MemoryBackend.
|
||||
*
|
||||
* @return
|
||||
* A new MemoryBackend object.
|
||||
*/
|
||||
protected function createCacheBackend($bin) {
|
||||
return new MemoryBackend($bin);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,9 @@ class AddFeedTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check that special characters are correctly escaped. Test for issue #1211668.
|
||||
* Checks that special characters are correctly escaped.
|
||||
*
|
||||
* @see http://drupal.org/node/1211668
|
||||
*/
|
||||
function testFeedIconEscaping() {
|
||||
$variables = array();
|
||||
|
|
|
@ -82,7 +82,7 @@ class CascadingStylesheetsTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Makes sure that reseting the CSS empties the cache.
|
||||
* Makes sure that resetting the CSS empties the cache.
|
||||
*/
|
||||
function testReset() {
|
||||
drupal_static_reset('drupal_add_css');
|
||||
|
|
|
@ -74,7 +74,7 @@ class FormatDateTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests for the format_date() function.
|
||||
* Tests the format_date() function.
|
||||
*/
|
||||
function testFormatDate() {
|
||||
global $user;
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Common;
|
|||
use Drupal\simpletest\UnitTestBase;
|
||||
|
||||
/**
|
||||
* Test for cleaning HTML identifiers.
|
||||
* Tests cleaning HTML identifiers.
|
||||
*/
|
||||
class HtmlIdentifierUnitTest extends UnitTestBase {
|
||||
public static function getInfo() {
|
||||
|
|
|
@ -13,9 +13,10 @@ use Drupal\simpletest\WebTestBase;
|
|||
use Exception;
|
||||
|
||||
/**
|
||||
* Unit tests for the Schema API.
|
||||
* Tests the Schema API.
|
||||
*/
|
||||
class SchemaTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* A global counter for table and field creation.
|
||||
*/
|
||||
|
@ -30,7 +31,7 @@ class SchemaTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Tests database interactions.
|
||||
*/
|
||||
function testSchema() {
|
||||
// Try creating a table.
|
||||
|
@ -144,6 +145,15 @@ class SchemaTest extends WebTestBase {
|
|||
$this->assertTrue(db_table_exists('test_timestamp'), 'Table with database specific datatype was created.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests inserting data into an existing table.
|
||||
*
|
||||
* @param $table
|
||||
* The database table to insert data into.
|
||||
*
|
||||
* @return
|
||||
* TRUE if the insert succeeded, FALSE otherwise.
|
||||
*/
|
||||
function tryInsert($table = 'test_table') {
|
||||
try {
|
||||
db_insert($table)
|
||||
|
@ -209,11 +219,12 @@ class SchemaTest extends WebTestBase {
|
|||
* Tries to insert a negative value into columns defined as unsigned.
|
||||
*
|
||||
* @param $table_name
|
||||
* The table to insert
|
||||
* The table to insert.
|
||||
* @param $column_name
|
||||
* The column to insert
|
||||
* The column to insert.
|
||||
*
|
||||
* @return
|
||||
* TRUE if the insert succeeded, FALSE otherwise
|
||||
* TRUE if the insert succeeded, FALSE otherwise.
|
||||
*/
|
||||
function tryUnsignedInsert($table_name, $column_name) {
|
||||
try {
|
||||
|
@ -228,7 +239,7 @@ class SchemaTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test adding columns to an existing table.
|
||||
* Tests adding columns to an existing table.
|
||||
*/
|
||||
function testSchemaAddField() {
|
||||
// Test varchar types.
|
||||
|
@ -300,7 +311,7 @@ class SchemaTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Assert that a given field can be added and removed from a table.
|
||||
* Asserts that a given field can be added and removed from a table.
|
||||
*
|
||||
* The addition test covers both defining a field of a given specification
|
||||
* when initially creating at table and extending an existing table.
|
||||
|
@ -357,7 +368,7 @@ class SchemaTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Assert that a newly added field has the correct characteristics.
|
||||
* Asserts that a newly added field has the correct characteristics.
|
||||
*/
|
||||
protected function assertFieldCharacteristics($table_name, $field_name, $field_spec) {
|
||||
// Check that the initial value has been registered.
|
||||
|
|
|
@ -61,7 +61,7 @@ class SimpleTestErrorCollectorTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Error handler that collects errors in an array.
|
||||
* Stores errors into an array.
|
||||
*
|
||||
* This test class is trying to verify that simpletest correctly sees errors
|
||||
* and warnings. However, it can't generate errors and warnings that
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Common;
|
|||
use Drupal\simpletest\UnitTestBase;
|
||||
|
||||
/**
|
||||
* Test unicode handling features implemented in unicode.inc.
|
||||
* Tests unicode handling features implemented in unicode.inc.
|
||||
*/
|
||||
class TableSortExtenderUnitTest extends UnitTestBase {
|
||||
|
||||
|
@ -44,7 +44,7 @@ class TableSortExtenderUnitTest extends UnitTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test tablesort_init().
|
||||
* Tests tablesort_init().
|
||||
*/
|
||||
function testTableSortInit() {
|
||||
|
||||
|
|
|
@ -53,6 +53,17 @@ class UrlTest extends WebTestBase {
|
|||
$this->assertTrue($this->hasClass($link, 'active'), format_string('Class @class is present on link to the current page', array('@class' => 'active')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for class existence in link.
|
||||
*
|
||||
* @param $link
|
||||
* URL to search.
|
||||
* @param $class
|
||||
* Element class to search for.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the class is found, FALSE otherwise.
|
||||
*/
|
||||
private function hasClass($link, $class) {
|
||||
return preg_match('|class="([^\"\s]+\s+)*' . $class . '|', $link);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Drupal\system\Tests\Database;
|
||||
|
||||
/**
|
||||
* Delete/Truncate tests.
|
||||
* Tests delete and truncate queries.
|
||||
*
|
||||
* The DELETE tests are not as extensive, as all of the interesting code for
|
||||
* DELETE queries is in the conditional which is identical to the UPDATE and
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Drupal\system\Tests\Database;
|
||||
|
||||
/**
|
||||
* Insert tests using LOB fields, which are weird on some databases.
|
||||
* Tests inserts using LOB fields, which are weird on some databases.
|
||||
*/
|
||||
class InsertLobTest extends DatabaseTestBase {
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ class InsertTest extends DatabaseTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test that inserts return the proper auto-increment ID.
|
||||
* Tests that inserts return the proper auto-increment ID.
|
||||
*/
|
||||
function testInsertLastInsertID() {
|
||||
$id = db_insert('test')
|
||||
|
|
|
@ -98,7 +98,7 @@ class MergeTest extends DatabaseTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Confirms that we can merge-update a record successfully, with alternate replacement.
|
||||
* Confirms that we can merge-update a record, with alternate replacement.
|
||||
*/
|
||||
function testMergeUpdateExplicit() {
|
||||
$num_records_before = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField();
|
||||
|
|
|
@ -204,6 +204,9 @@ class SelectComplexTest extends DatabaseTestBase {
|
|||
$this->assertEqual($record->$age_field, 27, 'Correct data retrieved.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests having queries.
|
||||
*/
|
||||
function testHavingCountQuery() {
|
||||
$query = db_select('test')
|
||||
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Drupal\system\Tests\Database;
|
||||
|
||||
/**
|
||||
* Test case for subselects in a dynamic SELECT query.
|
||||
* Tests for subselects in a dynamic SELECT query.
|
||||
*/
|
||||
class SelectSubqueryTest extends DatabaseTestBase {
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Drupal\system\Tests\Database;
|
||||
|
||||
/**
|
||||
* Tests the tablesort query extender
|
||||
* Tests the tablesort query extender.
|
||||
*/
|
||||
class SelectTableSortDefaultTest extends DatabaseTestBase {
|
||||
|
||||
|
@ -77,7 +77,7 @@ class SelectTableSortDefaultTest extends DatabaseTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Confirms that no error is thrown if a sort is not set in a default tableselect.
|
||||
* Confirms that no error is thrown if no sort is set in a tableselect.
|
||||
*/
|
||||
function testTableSortDefaultSort() {
|
||||
$this->drupalGet('database_test/tablesort_default_sort');
|
||||
|
|
|
@ -368,7 +368,7 @@ class SelectTest extends DatabaseTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that aliases are renamed when duplicates.
|
||||
* Tests that aliases are renamed when they are duplicates.
|
||||
*/
|
||||
function testSelectDuplicateAlias() {
|
||||
$query = db_select('test', 't');
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Drupal\system\Tests\Database;
|
||||
|
||||
/**
|
||||
* Updates builder tests.
|
||||
* Tests the update query builder.
|
||||
*/
|
||||
class UpdateTest extends DatabaseTestBase {
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\system\Tests\System;
|
|||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests for the theme interface functionality.
|
||||
* Tests the theme interface functionality.
|
||||
*/
|
||||
class ThemeTest extends WebTestBase {
|
||||
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains Drupal\system\Tests\Theme\EntityFilteringThemeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\system\Tests\Theme;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests filtering for XSS in rendered entity templates in all themes.
|
||||
*/
|
||||
class EntityFilteringThemeTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Use the standard profile.
|
||||
*
|
||||
* We test entity theming with the default node, user, comment, and taxonomy
|
||||
* configurations at several paths in the standard profile.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $profile = 'standard';
|
||||
|
||||
/**
|
||||
* A list of all available themes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $themes;
|
||||
|
||||
/**
|
||||
* A test user.
|
||||
*
|
||||
* @var Drupal\user\User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
|
||||
/**
|
||||
* A test node.
|
||||
*
|
||||
* @var Drupal\node\Node
|
||||
*/
|
||||
protected $node;
|
||||
|
||||
|
||||
/**
|
||||
* A test taxonomy term.
|
||||
*
|
||||
* @var Drupal\taxonomy\Term
|
||||
*/
|
||||
protected $term;
|
||||
|
||||
|
||||
/**
|
||||
* A test comment.
|
||||
*
|
||||
* @var Drupal\comment\Comment
|
||||
*/
|
||||
protected $comment;
|
||||
|
||||
/**
|
||||
* A string containing markup and JS.
|
||||
*
|
||||
* @string
|
||||
*/
|
||||
protected $xss_label = "string with <em>HTML</em> and <script>alert('JS');</script>";
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Entity filtering theme test',
|
||||
'description' => 'Tests themed output for each entity type in all available themes to ensure entity labels are filtered for XSS.',
|
||||
'group' => 'Theme',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Enable all available themes for testing.
|
||||
$this->themes = array_keys(list_themes());
|
||||
theme_enable($this->themes);
|
||||
|
||||
// Create a test user.
|
||||
$this->user = $this->drupalCreateUser(array('access content', 'access user profiles'));
|
||||
$this->user->name = $this->xss_label;
|
||||
$this->user->save();
|
||||
$this->drupalLogin($this->user);
|
||||
|
||||
// Create a test term.
|
||||
$this->term = entity_create('taxonomy_term', array(
|
||||
'name' => $this->xss_label,
|
||||
'vid' => 1,
|
||||
));
|
||||
taxonomy_term_save($this->term);
|
||||
|
||||
// Create a test node tagged with the test term.
|
||||
$this->node = $this->drupalCreateNode(array(
|
||||
'title' => $this->xss_label,
|
||||
'type' => 'article',
|
||||
'promote' => NODE_PROMOTED,
|
||||
'field_tags' => array(LANGUAGE_NOT_SPECIFIED => array(array('tid' => $this->term->tid))),
|
||||
));
|
||||
|
||||
// Create a test comment on the test node.
|
||||
$this->comment = entity_create('comment', array(
|
||||
'nid' => $this->node->nid,
|
||||
'node_type' => $this->node->type,
|
||||
'status' => COMMENT_PUBLISHED,
|
||||
'subject' => $this->xss_label,
|
||||
'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())),
|
||||
));
|
||||
comment_save($this->comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks each themed entity for XSS filtering in available themes.
|
||||
*/
|
||||
function testThemedEntity() {
|
||||
// Check paths where various view modes of the entities are rendered.
|
||||
$paths = array(
|
||||
'user',
|
||||
'node',
|
||||
'node/' . $this->node->nid,
|
||||
'taxonomy/term/' . $this->term->tid,
|
||||
);
|
||||
|
||||
// Check each path in all available themes.
|
||||
foreach ($this->themes as $theme) {
|
||||
variable_set('theme_default', $theme);
|
||||
foreach ($paths as $path) {
|
||||
$this->drupalGet($path);
|
||||
$this->assertResponse(200);
|
||||
$this->assertNoRaw($this->xss_label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@ use Drupal\simpletest\WebTestBase;
|
|||
use Drupal\Core\Utility\ThemeRegistry;
|
||||
|
||||
/**
|
||||
* Tests for the ThemeRegistry class.
|
||||
* Tests the ThemeRegistry class.
|
||||
*/
|
||||
class RegistryTest extends WebTestBase {
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Update;
|
|||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests for the invocation of hook_update_dependencies().
|
||||
* Tests the invocation of hook_update_dependencies().
|
||||
*/
|
||||
class DependencyHookInvocationTest extends WebTestBase {
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Update;
|
|||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests for the update dependency ordering system.
|
||||
* Tests the update dependency ordering system.
|
||||
*/
|
||||
class DependencyOrderingTest extends WebTestBase {
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Update;
|
|||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests for the update system functionality.
|
||||
* Tests the update system functionality.
|
||||
*/
|
||||
class UpdateScriptTest extends WebTestBase {
|
||||
|
||||
|
|
|
@ -2109,7 +2109,7 @@ function system_update_8023() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generate an UUID for all files.
|
||||
* Generate a UUID for all files.
|
||||
*/
|
||||
function system_update_8024(&$sandbox) {
|
||||
if (!isset($sandbox['progress'])) {
|
||||
|
|
|
@ -335,7 +335,7 @@ function taxonomy_update_8002() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generate an UUID for all terms.
|
||||
* Generate a UUID for all terms.
|
||||
*/
|
||||
function taxonomy_update_8003(&$sandbox) {
|
||||
if (!isset($sandbox['progress'])) {
|
||||
|
|
|
@ -582,7 +582,7 @@ function user_update_8008() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generate an UUID for all users.
|
||||
* Generate a UUID for all users.
|
||||
*/
|
||||
function user_update_8009(&$sandbox) {
|
||||
if (!isset($sandbox['progress'])) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Bartik's theme implementation to display a node.
|
||||
*
|
||||
* Available variables:
|
||||
* - $title: the (sanitized) title of the node.
|
||||
* - $label: the (sanitized) title of the node.
|
||||
* - $content: An array of node items. Use render($content) to print them all,
|
||||
* or print a subset such as render($content['field_example']). Use
|
||||
* hide($content['field_example']) to temporarily suppress the printing of a
|
||||
|
@ -83,7 +83,7 @@
|
|||
<?php print render($title_prefix); ?>
|
||||
<?php if (!$page): ?>
|
||||
<h2<?php print $title_attributes; ?>>
|
||||
<a href="<?php print $node_url; ?>"><?php print $title; ?></a>
|
||||
<a href="<?php print $node_url; ?>"><?php print $label; ?></a>
|
||||
</h2>
|
||||
<?php endif; ?>
|
||||
<?php print render($title_suffix); ?>
|
||||
|
|
Loading…
Reference in New Issue