Merge remote-tracking branch 'upstream/8.x' into kernel
commit
1c6379e1db
|
@ -140,8 +140,13 @@ class Schema extends DatabaseSchema {
|
|||
protected function createFieldSql($name, $spec) {
|
||||
$sql = "`" . $name . "` " . $spec['mysql_type'];
|
||||
|
||||
if (in_array($spec['mysql_type'], array('VARCHAR', 'CHAR', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'TEXT')) && isset($spec['length'])) {
|
||||
$sql .= '(' . $spec['length'] . ')';
|
||||
if (in_array($spec['mysql_type'], array('VARCHAR', 'CHAR', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'TEXT'))) {
|
||||
if (isset($spec['length'])) {
|
||||
$sql .= '(' . $spec['length'] . ')';
|
||||
}
|
||||
if (!empty($spec['binary'])) {
|
||||
$sql .= ' BINARY';
|
||||
}
|
||||
}
|
||||
elseif (isset($spec['precision']) && isset($spec['scale'])) {
|
||||
$sql .= '(' . $spec['precision'] . ', ' . $spec['scale'] . ')';
|
||||
|
|
|
@ -80,6 +80,10 @@ use Drupal\Core\Database\Query\PlaceholderInterface;
|
|||
* the precision (total number of significant digits) and scale
|
||||
* (decimal digits right of the decimal point). Both values are
|
||||
* mandatory. Ignored for other field types.
|
||||
* - 'binary': A boolean indicating that MySQL should force 'char',
|
||||
* 'varchar' or 'text' fields to use case-sensitive binary collation.
|
||||
* This has no effect on other database types for which case sensitivity
|
||||
* is already the default behavior.
|
||||
* All parameters apart from 'type' are optional except that type
|
||||
* 'numeric' columns must specify 'precision' and 'scale', and type
|
||||
* 'varchar' must specify the 'length' parameter.
|
||||
|
|
|
@ -18,7 +18,7 @@ use Iterator;
|
|||
* database. Calling code can then treat it the same as if it were an actual
|
||||
* result set that happens to contain no records.
|
||||
*
|
||||
* @see SearchQuery
|
||||
* @see Drupal\search\SearchQuery
|
||||
*/
|
||||
class StatementEmpty implements Iterator, StatementInterface {
|
||||
|
||||
|
|
|
@ -396,6 +396,7 @@ function aggregator_block_view($delta = '') {
|
|||
if (user_access('access news feeds')) {
|
||||
$block = array();
|
||||
list($type, $id) = explode('-', $delta);
|
||||
$result = FALSE;
|
||||
switch ($type) {
|
||||
case 'feed':
|
||||
if ($feed = db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(':fid' => $id))->fetchObject()) {
|
||||
|
@ -413,9 +414,12 @@ function aggregator_block_view($delta = '') {
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$items = array();
|
||||
foreach ($result as $item) {
|
||||
$items[] = theme('aggregator_block_item', array('item' => $item));
|
||||
if (!empty($result)) {
|
||||
foreach ($result as $item) {
|
||||
$items[] = theme('aggregator_block_item', array('item' => $item));
|
||||
}
|
||||
}
|
||||
|
||||
// Only display the block if there are items to show.
|
||||
|
|
|
@ -887,6 +887,16 @@ class AggregatorRenderingTestCase extends AggregatorTestCase {
|
|||
$this->drupalGet($href);
|
||||
$correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', array(':title' => $feed->title));
|
||||
$this->assertFalse(empty($correct_titles), t('Aggregator feed page is available and has the correct title.'));
|
||||
|
||||
// Set the number of news items to 0 to test that the block does not show
|
||||
// up.
|
||||
$feed->block = 0;
|
||||
aggregator_save_feed((array) $feed);
|
||||
// It is nescessary to flush the cache after saving the number of items.
|
||||
drupal_flush_all_caches();
|
||||
// Check that the block is no longer displayed.
|
||||
$this->drupalGet('node');
|
||||
$this->assertNoText(t($block['title']), 'Feed block is not displayed on the page when number of items is set to 0.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -264,7 +264,7 @@ function comment_confirm_delete_page($cid) {
|
|||
/**
|
||||
* Form constructor for the confirmation form for comment deletion.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* The comment that is about to be deleted.
|
||||
*
|
||||
* @ingroup forms
|
||||
|
@ -272,7 +272,7 @@ function comment_confirm_delete_page($cid) {
|
|||
* @see comment_confirm_delete_submit()
|
||||
* @see confirm_form()
|
||||
*/
|
||||
function comment_confirm_delete($form, &$form_state, $comment) {
|
||||
function comment_confirm_delete($form, &$form_state, Comment $comment) {
|
||||
$form['#comment'] = $comment;
|
||||
// Always provide entity id in the same form key as in the entity edit form.
|
||||
$form['cid'] = array('#type' => 'value', '#value' => $comment->cid);
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
* This hook is invoked from comment_save() before the comment is saved to the
|
||||
* database.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* The comment object.
|
||||
*/
|
||||
function hook_comment_presave($comment) {
|
||||
function hook_comment_presave(Comment $comment) {
|
||||
// Remove leading & trailing spaces from the comment subject.
|
||||
$comment->subject = trim($comment->subject);
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ function hook_comment_presave($comment) {
|
|||
/**
|
||||
* Respond to creation of a new comment.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* The comment object.
|
||||
*/
|
||||
function hook_comment_insert($comment) {
|
||||
function hook_comment_insert(Comment $comment) {
|
||||
// Reindex the node when comments are added.
|
||||
search_touch_node($comment->nid);
|
||||
}
|
||||
|
@ -38,10 +38,10 @@ function hook_comment_insert($comment) {
|
|||
/**
|
||||
* Respond to updates to a comment.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* The comment object.
|
||||
*/
|
||||
function hook_comment_update($comment) {
|
||||
function hook_comment_update(Comment $comment) {
|
||||
// Reindex the node when comments are updated.
|
||||
search_touch_node($comment->nid);
|
||||
}
|
||||
|
@ -49,10 +49,10 @@ function hook_comment_update($comment) {
|
|||
/**
|
||||
* Act on comments being loaded from the database.
|
||||
*
|
||||
* @param $comments
|
||||
* @param array $comments
|
||||
* An array of comment objects indexed by cid.
|
||||
*/
|
||||
function hook_comment_load($comments) {
|
||||
function hook_comment_load(Comment $comments) {
|
||||
$result = db_query('SELECT cid, foo FROM {mytable} WHERE cid IN (:cids)', array(':cids' => array_keys($comments)));
|
||||
foreach ($result as $record) {
|
||||
$comments[$record->cid]->foo = $record->foo;
|
||||
|
@ -62,7 +62,7 @@ function hook_comment_load($comments) {
|
|||
/**
|
||||
* Act on a comment that is being assembled before rendering.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* Passes in the comment the action is being performed on.
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full', 'teaser'...
|
||||
|
@ -71,7 +71,7 @@ function hook_comment_load($comments) {
|
|||
*
|
||||
* @see hook_entity_view()
|
||||
*/
|
||||
function hook_comment_view($comment, $view_mode, $langcode) {
|
||||
function hook_comment_view(Comment $comment, $view_mode, $langcode) {
|
||||
// how old is the comment
|
||||
$comment->time_ago = time() - $comment->changed;
|
||||
}
|
||||
|
@ -108,20 +108,20 @@ function hook_comment_view_alter(&$build) {
|
|||
/**
|
||||
* Respond to a comment being published by a moderator.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* The comment the action is being performed on.
|
||||
*/
|
||||
function hook_comment_publish($comment) {
|
||||
function hook_comment_publish(Comment $comment) {
|
||||
drupal_set_message(t('Comment: @subject has been published', array('@subject' => $comment->subject)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond to a comment being unpublished by a moderator.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* The comment the action is being performed on.
|
||||
*/
|
||||
function hook_comment_unpublish($comment) {
|
||||
function hook_comment_unpublish(Comment $comment) {
|
||||
drupal_set_message(t('Comment: @subject has been unpublished', array('@subject' => $comment->subject)));
|
||||
}
|
||||
|
||||
|
@ -132,14 +132,14 @@ function hook_comment_unpublish($comment) {
|
|||
* field_attach_delete() is called and before the comment is actually removed
|
||||
* from the database.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* The comment object for the comment that is about to be deleted.
|
||||
*
|
||||
* @see hook_comment_delete()
|
||||
* @see comment_delete_multiple()
|
||||
* @see entity_delete_multiple()
|
||||
*/
|
||||
function hook_comment_predelete($comment) {
|
||||
function hook_comment_predelete(Comment $comment) {
|
||||
// Delete a record associated with the comment in a custom table.
|
||||
db_delete('example_comment_table')
|
||||
->condition('cid', $comment->cid)
|
||||
|
@ -153,14 +153,14 @@ function hook_comment_predelete($comment) {
|
|||
* field_attach_delete() has called and after the comment has been removed from
|
||||
* the database.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* The comment object for the comment that has been deleted.
|
||||
*
|
||||
* @see hook_comment_predelete()
|
||||
* @see comment_delete_multiple()
|
||||
* @see entity_delete_multiple()
|
||||
*/
|
||||
function hook_comment_delete($comment) {
|
||||
function hook_comment_delete(Comment $comment) {
|
||||
drupal_set_message(t('Comment: @subject has been deleted', array('@subject' => $comment->subject)));
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ function comment_node_type_load($name) {
|
|||
/**
|
||||
* Entity uri callback.
|
||||
*/
|
||||
function comment_uri($comment) {
|
||||
function comment_uri(Comment $comment) {
|
||||
return array(
|
||||
'path' => 'comment/' . $comment->cid,
|
||||
'options' => array('fragment' => 'comment-' . $comment->cid),
|
||||
|
@ -935,7 +935,7 @@ function comment_prepare_thread(&$comments) {
|
|||
/**
|
||||
* Generates an array for rendering a comment.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* The comment object.
|
||||
* @param $node
|
||||
* The node the comment is attached to.
|
||||
|
@ -948,7 +948,7 @@ function comment_prepare_thread(&$comments) {
|
|||
* @return
|
||||
* An array as expected by drupal_render().
|
||||
*/
|
||||
function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) {
|
||||
function comment_view(Comment $comment, $node, $view_mode = 'full', $langcode = NULL) {
|
||||
if (!isset($langcode)) {
|
||||
$langcode = $GLOBALS['language_content']->langcode;
|
||||
}
|
||||
|
@ -1005,7 +1005,7 @@ function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) {
|
|||
* The content built for the comment (field values, comments, file attachments
|
||||
* or other comment components) will vary depending on the $view_mode parameter.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* A comment object.
|
||||
* @param $node
|
||||
* The node the comment is attached to.
|
||||
|
@ -1015,7 +1015,7 @@ function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) {
|
|||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
*/
|
||||
function comment_build_content($comment, $node, $view_mode = 'full', $langcode = NULL) {
|
||||
function comment_build_content(Comment $comment, $node, $view_mode = 'full', $langcode = NULL) {
|
||||
if (!isset($langcode)) {
|
||||
$langcode = $GLOBALS['language_content']->langcode;
|
||||
}
|
||||
|
@ -1049,7 +1049,7 @@ function comment_build_content($comment, $node, $view_mode = 'full', $langcode =
|
|||
/**
|
||||
* Adds reply, edit, delete, etc. links, depending on user permissions.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* The comment object.
|
||||
* @param $node
|
||||
* The node the comment is attached to.
|
||||
|
@ -1057,7 +1057,7 @@ function comment_build_content($comment, $node, $view_mode = 'full', $langcode =
|
|||
* @return
|
||||
* A structured array of links.
|
||||
*/
|
||||
function comment_links($comment, $node) {
|
||||
function comment_links(Comment $comment, $node) {
|
||||
$links = array();
|
||||
if ($node->comment == COMMENT_NODE_OPEN) {
|
||||
if (user_access('administer comments') && user_access('post comments')) {
|
||||
|
@ -1451,13 +1451,13 @@ function comment_user_predelete($account) {
|
|||
* @param $op
|
||||
* The operation that is to be performed on the comment. Only 'edit' is
|
||||
* recognized now.
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* The comment object.
|
||||
*
|
||||
* @return
|
||||
* TRUE if the current user has acces to the comment, FALSE otherwise.
|
||||
*/
|
||||
function comment_access($op, $comment) {
|
||||
function comment_access($op, Comment $comment) {
|
||||
global $user;
|
||||
|
||||
if ($op == 'edit') {
|
||||
|
@ -1468,10 +1468,10 @@ function comment_access($op, $comment) {
|
|||
/**
|
||||
* Accepts a submission of new or changed comment content.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* A comment object.
|
||||
*/
|
||||
function comment_save($comment) {
|
||||
function comment_save(Comment $comment) {
|
||||
$comment->save();
|
||||
}
|
||||
|
||||
|
@ -1644,12 +1644,12 @@ function comment_get_display_page($cid, $node_type) {
|
|||
/**
|
||||
* Page callback: Displays the comment editing form.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* The comment object representing the comment to be edited.
|
||||
*
|
||||
* @see comment_menu()
|
||||
*/
|
||||
function comment_edit_page($comment) {
|
||||
function comment_edit_page(Comment $comment) {
|
||||
drupal_set_title(t('Edit comment %comment', array('%comment' => $comment->subject)), PASS_THROUGH);
|
||||
$node = node_load($comment->nid);
|
||||
return drupal_get_form("comment_node_{$node->type}_form", $comment);
|
||||
|
@ -1674,7 +1674,7 @@ function comment_forms() {
|
|||
* @see comment_form_build_preview()
|
||||
* @ingroup forms
|
||||
*/
|
||||
function comment_form($form, &$form_state, $comment) {
|
||||
function comment_form($form, &$form_state, Comment $comment) {
|
||||
global $user, $language_content;
|
||||
|
||||
// During initial form build, add the comment entity to the form state for
|
||||
|
@ -1888,9 +1888,11 @@ function comment_form_build_preview($form, &$form_state) {
|
|||
/**
|
||||
* Generates a comment preview.
|
||||
*
|
||||
* @param Comment $comment
|
||||
*
|
||||
* @see comment_form_build_preview()
|
||||
*/
|
||||
function comment_preview($comment) {
|
||||
function comment_preview(Comment $comment) {
|
||||
global $user;
|
||||
|
||||
drupal_set_title(t('Preview comment'), PASS_THROUGH);
|
||||
|
@ -1987,8 +1989,11 @@ function comment_form_validate($form, &$form_state) {
|
|||
|
||||
/**
|
||||
* Prepare a comment for submission.
|
||||
*
|
||||
* @param Comment $comment
|
||||
*
|
||||
*/
|
||||
function comment_submit($comment) {
|
||||
function comment_submit(Comment $comment) {
|
||||
if (empty($comment->date)) {
|
||||
$comment->date = 'now';
|
||||
}
|
||||
|
@ -2328,15 +2333,15 @@ function comment_action_info() {
|
|||
/**
|
||||
* Publishes a comment.
|
||||
*
|
||||
* @param $comment
|
||||
* An optional comment object.
|
||||
* @param Comment $comment
|
||||
* (optional) A comment object to publish.
|
||||
* @param array $context
|
||||
* Array with components:
|
||||
* - 'cid': Comment ID. Required if $comment is not given.
|
||||
*
|
||||
* @ingroup actions
|
||||
*/
|
||||
function comment_publish_action($comment, $context = array()) {
|
||||
function comment_publish_action(Comment $comment = NULL, $context = array()) {
|
||||
if (isset($comment->subject)) {
|
||||
$subject = $comment->subject;
|
||||
$comment->status = COMMENT_PUBLISHED;
|
||||
|
@ -2355,15 +2360,15 @@ function comment_publish_action($comment, $context = array()) {
|
|||
/**
|
||||
* Unpublishes a comment.
|
||||
*
|
||||
* @param $comment
|
||||
* An optional comment object.
|
||||
* @param Comment|null $comment
|
||||
* (optional) A comment object to unpublish.
|
||||
* @param array $context
|
||||
* Array with components:
|
||||
* - 'cid': Comment ID. Required if $comment is not given.
|
||||
*
|
||||
* @ingroup actions
|
||||
*/
|
||||
function comment_unpublish_action($comment, $context = array()) {
|
||||
function comment_unpublish_action(Comment $comment = NULL, $context = array()) {
|
||||
if (isset($comment->subject)) {
|
||||
$subject = $comment->subject;
|
||||
$comment->status = COMMENT_NOT_PUBLISHED;
|
||||
|
@ -2382,7 +2387,7 @@ function comment_unpublish_action($comment, $context = array()) {
|
|||
/**
|
||||
* Unpublishes a comment if it contains certain keywords.
|
||||
*
|
||||
* @param $comment
|
||||
* @param Comment $comment
|
||||
* Comment object to modify.
|
||||
* @param array $context
|
||||
* Array with components:
|
||||
|
@ -2393,7 +2398,7 @@ function comment_unpublish_action($comment, $context = array()) {
|
|||
* @see comment_unpublish_by_keyword_action_form()
|
||||
* @see comment_unpublish_by_keyword_action_submit()
|
||||
*/
|
||||
function comment_unpublish_by_keyword_action($comment, $context) {
|
||||
function comment_unpublish_by_keyword_action(Comment $comment, $context) {
|
||||
foreach ($context['keywords'] as $keyword) {
|
||||
$text = drupal_render($comment);
|
||||
if (strpos($text, $keyword) !== FALSE) {
|
||||
|
@ -2434,9 +2439,11 @@ function comment_unpublish_by_keyword_action_submit($form, $form_state) {
|
|||
/**
|
||||
* Saves a comment.
|
||||
*
|
||||
* @param Comment $comment
|
||||
*
|
||||
* @ingroup actions
|
||||
*/
|
||||
function comment_save_action($comment) {
|
||||
function comment_save_action(Comment $comment) {
|
||||
comment_save($comment);
|
||||
cache_clear_all();
|
||||
watchdog('action', 'Saved comment %title', array('%title' => $comment->subject));
|
||||
|
|
|
@ -47,12 +47,9 @@ function comment_reply($node, $pid = NULL) {
|
|||
// $pid indicates that this is a reply to a comment.
|
||||
if ($pid) {
|
||||
if (user_access('access comments')) {
|
||||
// Load the comment whose cid = $pid
|
||||
$comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data FROM {comment} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = :cid AND c.status = :status', array(
|
||||
':cid' => $pid,
|
||||
':status' => COMMENT_PUBLISHED,
|
||||
))->fetchObject();
|
||||
if ($comment) {
|
||||
// Load the parent comment.
|
||||
$comment = comment_load($pid);
|
||||
if ($comment->status = COMMENT_PUBLISHED) {
|
||||
// If that comment exists, make sure that the current comment and the
|
||||
// parent comment both belong to the same parent node.
|
||||
if ($comment->nid != $node->nid) {
|
||||
|
|
|
@ -96,7 +96,7 @@ class CommentHelperCase extends DrupalWebTestCase {
|
|||
/**
|
||||
* Checks current page for specified comment.
|
||||
*
|
||||
* @param object $comment
|
||||
* @param Comment $comment
|
||||
* The comment object.
|
||||
* @param boolean $reply
|
||||
* Boolean indicating whether the comment is a reply to another comment.
|
||||
|
@ -104,8 +104,8 @@ class CommentHelperCase extends DrupalWebTestCase {
|
|||
* @return boolean
|
||||
* Boolean indicating whether the comment was found.
|
||||
*/
|
||||
function commentExists($comment, $reply = FALSE) {
|
||||
if ($comment && is_object($comment)) {
|
||||
function commentExists(Comment $comment = NULL, $reply = FALSE) {
|
||||
if ($comment) {
|
||||
$regex = '/' . ($reply ? '<div class="indented">(.*?)' : '');
|
||||
$regex .= '<a id="comment-' . $comment->id . '"(.*?)'; // Comment anchor.
|
||||
$regex .= '<div(.*?)'; // Begin in comment div.
|
||||
|
@ -123,10 +123,10 @@ class CommentHelperCase extends DrupalWebTestCase {
|
|||
/**
|
||||
* Deletes a comment.
|
||||
*
|
||||
* @param object $comment
|
||||
* @param Comment $comment
|
||||
* Comment to delete.
|
||||
*/
|
||||
function deleteComment($comment) {
|
||||
function deleteComment(Comment $comment) {
|
||||
$this->drupalPost('comment/' . $comment->id . '/delete', array(), t('Delete'));
|
||||
$this->assertText(t('The comment and all its replies have been deleted.'), t('Comment deleted.'));
|
||||
}
|
||||
|
|
|
@ -92,6 +92,60 @@ interface EntityInterface {
|
|||
*/
|
||||
public function uri();
|
||||
|
||||
/**
|
||||
* Returns the default language of a language-specific entity.
|
||||
*
|
||||
* @return
|
||||
* The language object of the entity's default language, or FALSE if the
|
||||
* entity is not language-specific.
|
||||
*
|
||||
* @see EntityInterface::translations()
|
||||
*/
|
||||
public function language();
|
||||
|
||||
/**
|
||||
* Returns the languages the entity is translated to.
|
||||
*
|
||||
* @return
|
||||
* An array of language objects, keyed by language codes.
|
||||
*
|
||||
* @see EntityInterface::language()
|
||||
*/
|
||||
public function translations();
|
||||
|
||||
/**
|
||||
* Returns the value of an entity property.
|
||||
*
|
||||
* @param $property_name
|
||||
* The name of the property to return; e.g., 'title'.
|
||||
* @param $langcode
|
||||
* (optional) If the property is translatable, the language code of the
|
||||
* language that should be used for getting the property. If set to NULL,
|
||||
* the entity's default language is being used.
|
||||
*
|
||||
* @return
|
||||
* The property value, or NULL if it is not defined.
|
||||
*
|
||||
* @see EntityInterface::language()
|
||||
*/
|
||||
public function get($property_name, $langcode = NULL);
|
||||
|
||||
/**
|
||||
* Sets the value of an entity property.
|
||||
*
|
||||
* @param $property_name
|
||||
* The name of the property to set; e.g., 'title'.
|
||||
* @param $value
|
||||
* The value to set, or NULL to unset the property.
|
||||
* @param $langcode
|
||||
* (optional) If the property is translatable, the language code of the
|
||||
* language that should be used for getting the property. If set to
|
||||
* NULL, the entity's default language is being used.
|
||||
*
|
||||
* @see EntityInterface::language()
|
||||
*/
|
||||
public function set($property_name, $value, $langcode = NULL);
|
||||
|
||||
/**
|
||||
* Saves an entity permanently.
|
||||
*
|
||||
|
@ -138,6 +192,13 @@ interface EntityInterface {
|
|||
*/
|
||||
class Entity implements EntityInterface {
|
||||
|
||||
/**
|
||||
* The language code of the entity's default language.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $langcode = LANGUAGE_NOT_SPECIFIED;
|
||||
|
||||
/**
|
||||
* The entity type.
|
||||
*
|
||||
|
@ -246,6 +307,92 @@ class Entity implements EntityInterface {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements EntityInterface::language().
|
||||
*/
|
||||
public function language() {
|
||||
// @todo: Check for language.module instead, once Field API language
|
||||
// handling depends upon it too.
|
||||
return module_exists('locale') ? language_load($this->langcode) : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements EntityInterface::translations().
|
||||
*/
|
||||
public function translations() {
|
||||
$languages = array();
|
||||
$entity_info = $this->entityInfo();
|
||||
if ($entity_info['fieldable'] && ($default_language = $this->language())) {
|
||||
// Go through translatable properties and determine all languages for
|
||||
// which translated values are available.
|
||||
foreach (field_info_instances($this->entityType, $this->bundle()) as $field_name => $instance) {
|
||||
$field = field_info_field($field_name);
|
||||
if (field_is_translatable($this->entityType, $field) && isset($this->$field_name)) {
|
||||
foreach ($this->$field_name as $langcode => $value) {
|
||||
$languages[$langcode] = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove the default language from the translations.
|
||||
unset($languages[$default_language->langcode]);
|
||||
$languages = array_intersect_key(language_list(), $languages);
|
||||
}
|
||||
return $languages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements EntityInterface::get().
|
||||
*/
|
||||
public function get($property_name, $langcode = NULL) {
|
||||
// Handle fields.
|
||||
$entity_info = $this->entityInfo();
|
||||
if ($entity_info['fieldable'] && field_info_instance($this->entityType, $property_name, $this->bundle())) {
|
||||
$field = field_info_field($property_name);
|
||||
$langcode = $this->getFieldLangcode($field, $langcode);
|
||||
return isset($this->{$property_name}[$langcode]) ? $this->{$property_name}[$langcode] : NULL;
|
||||
}
|
||||
else {
|
||||
// Handle properties being not fields.
|
||||
// @todo: Add support for translatable properties being not fields.
|
||||
return isset($this->{$property_name}) ? $this->{$property_name} : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements EntityInterface::set().
|
||||
*/
|
||||
public function set($property_name, $value, $langcode = NULL) {
|
||||
// Handle fields.
|
||||
$entity_info = $this->entityInfo();
|
||||
if ($entity_info['fieldable'] && field_info_instance($this->entityType, $property_name, $this->bundle())) {
|
||||
$field = field_info_field($property_name);
|
||||
$langcode = $this->getFieldLangcode($field, $langcode);
|
||||
$this->{$property_name}[$langcode] = $value;
|
||||
}
|
||||
else {
|
||||
// Handle properties being not fields.
|
||||
// @todo: Add support for translatable properties being not fields.
|
||||
$this->{$property_name} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the language code to use for accessing a field value in a certain language.
|
||||
*/
|
||||
protected function getFieldLangcode($field, $langcode = NULL) {
|
||||
// Only apply the given langcode if the entity is language-specific.
|
||||
// Otherwise translatable fields are handled as non-translatable fields.
|
||||
if (field_is_translatable($this->entityType, $field) && ($default_language = $this->language())) {
|
||||
// For translatable fields the values in default language are stored using
|
||||
// the language code of the default language.
|
||||
return isset($langcode) ? $langcode : $default_language->langcode;
|
||||
}
|
||||
else {
|
||||
// Non-translatable fields always use LANGUAGE_NOT_SPECIFIED.
|
||||
return LANGUAGE_NOT_SPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements EntityInterface::save().
|
||||
*/
|
||||
|
|
|
@ -65,6 +65,138 @@ class EntityAPITestCase extends DrupalWebTestCase {
|
|||
$all = entity_test_load_multiple(FALSE);
|
||||
$this->assertTrue(empty($all), 'Deleted all entities.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Entity getters/setters.
|
||||
*/
|
||||
function testEntityGettersSetters() {
|
||||
$entity = entity_create('entity_test', array('name' => 'test', 'uid' => NULL));
|
||||
$this->assertNull($entity->get('uid'), 'Property is not set.');
|
||||
|
||||
$entity->set('uid', $GLOBALS['user']->uid);
|
||||
$this->assertEqual($entity->uid, $GLOBALS['user']->uid, 'Property has been set.');
|
||||
|
||||
$value = $entity->get('uid');
|
||||
$this->assertEqual($value, $entity->uid, 'Property has been retrieved.');
|
||||
|
||||
// Make sure setting/getting translations boils down to setting/getting the
|
||||
// regular value as the entity and property are not translatable.
|
||||
$entity->set('uid', NULL, 'en');
|
||||
$this->assertNull($entity->uid, 'Language neutral property has been set.');
|
||||
|
||||
$value = $entity->get('uid', 'en');
|
||||
$this->assertNull($value, 'Language neutral property has been retrieved.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests entity translation.
|
||||
*/
|
||||
class EntityTranslationTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Entity Translation',
|
||||
'description' => 'Tests entity translation functionality.',
|
||||
'group' => 'Entity API',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
// Enable translations for the test entity type. We cannot use
|
||||
// variable_set() here as variables are cleared by parent::setUp();
|
||||
$GLOBALS['entity_test_translation'] = TRUE;
|
||||
parent::setUp('entity_test', 'language', 'locale');
|
||||
|
||||
// Create a translatable test field.
|
||||
$this->field_name = drupal_strtolower($this->randomName() . '_field_name');
|
||||
$field = array(
|
||||
'field_name' => $this->field_name,
|
||||
'type' => 'text',
|
||||
'cardinality' => 4,
|
||||
'translatable' => TRUE,
|
||||
);
|
||||
field_create_field($field);
|
||||
$this->field = field_read_field($this->field_name);
|
||||
|
||||
$instance = array(
|
||||
'field_name' => $this->field_name,
|
||||
'entity_type' => 'entity_test',
|
||||
'bundle' => 'entity_test',
|
||||
);
|
||||
field_create_instance($instance);
|
||||
$this->instance = field_read_instance('entity_test', $this->field_name, 'entity_test');
|
||||
|
||||
// Create test languages.
|
||||
$this->langcodes = array();
|
||||
for ($i = 0; $i < 3; ++$i) {
|
||||
$language = (object) array(
|
||||
'langcode' => 'l' . $i,
|
||||
'name' => $this->randomString(),
|
||||
);
|
||||
$this->langcodes[$i] = $language->langcode;
|
||||
language_save($language);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests language related methods of the Entity class.
|
||||
*/
|
||||
function testEntityLanguageMethods() {
|
||||
$entity = entity_create('entity_test', array(
|
||||
'name' => 'test',
|
||||
'uid' => $GLOBALS['user']->uid,
|
||||
));
|
||||
$this->assertFalse($entity->language(), 'No entity language has been specified.');
|
||||
$this->assertFalse($entity->translations(), 'No translations are available');
|
||||
|
||||
// Set the value in default language.
|
||||
$entity->set($this->field_name, array(0 => array('value' => 'default value')));
|
||||
// Get the value.
|
||||
$value = $entity->get($this->field_name);
|
||||
$this->assertEqual($value, array(0 => array('value' => 'default value')), 'Untranslated value retrieved.');
|
||||
|
||||
// Set the value in a certain language. As the entity is not
|
||||
// language-specific it should use the default language and so ignore the
|
||||
// specified language.
|
||||
$entity->set($this->field_name, array(0 => array('value' => 'default value2')), $this->langcodes[1]);
|
||||
$value = $entity->get($this->field_name);
|
||||
$this->assertEqual($value, array(0 => array('value' => 'default value2')), 'Untranslated value updated.');
|
||||
$this->assertFalse($entity->translations(), 'No translations are available');
|
||||
|
||||
// Test getting a field value using the default language for a not
|
||||
// language-specific entity.
|
||||
$value = $entity->get($this->field_name, $this->langcodes[1]);
|
||||
$this->assertEqual($value, array(0 => array('value' => 'default value2')), 'Untranslated value retrieved.');
|
||||
|
||||
// Now, make the entity language-specific by assigning a language and test
|
||||
// translating it.
|
||||
$entity->langcode = $this->langcodes[0];
|
||||
$entity->{$this->field_name} = array();
|
||||
$this->assertEqual($entity->language(), language_load($this->langcodes[0]), 'Entity language retrieved.');
|
||||
$this->assertFalse($entity->translations(), 'No translations are available');
|
||||
|
||||
// Set the value in default language.
|
||||
$entity->set($this->field_name, array(0 => array('value' => 'default value')));
|
||||
// Get the value.
|
||||
$value = $entity->get($this->field_name);
|
||||
$this->assertEqual($value, array(0 => array('value' => 'default value')), 'Untranslated value retrieved.');
|
||||
|
||||
// Set a translation.
|
||||
$entity->set($this->field_name, array(0 => array('value' => 'translation 1')), $this->langcodes[1]);
|
||||
$value = $entity->get($this->field_name, $this->langcodes[1]);
|
||||
$this->assertEqual($value, array(0 => array('value' => 'translation 1')), 'Translated value set.');
|
||||
// Make sure the untranslated value stays.
|
||||
$value = $entity->get($this->field_name);
|
||||
$this->assertEqual($value, array(0 => array('value' => 'default value')), 'Untranslated value stays.');
|
||||
|
||||
$translations[$this->langcodes[1]] = language_load($this->langcodes[1]);
|
||||
$this->assertEqual($entity->translations(), $translations, 'Translations retrieved.');
|
||||
|
||||
// Try to get a not available translation.
|
||||
$value = $entity->get($this->field_name, $this->langcodes[2]);
|
||||
$this->assertNull($value, 'A translation that is not available is NULL.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,6 +57,13 @@ function entity_test_schema() {
|
|||
'default' => NULL,
|
||||
'description' => "The {users}.uid of the associated user.",
|
||||
),
|
||||
'langcode' => array(
|
||||
'description' => 'The {language}.langcode of the test entity.',
|
||||
'type' => 'varchar',
|
||||
'length' => 12,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'uid' => array('uid'),
|
|
@ -9,19 +9,21 @@
|
|||
* Implements hook_entity_info().
|
||||
*/
|
||||
function entity_test_entity_info() {
|
||||
$return = array(
|
||||
'entity_test' => array(
|
||||
'label' => t('Test entity'),
|
||||
'entity class' => 'Entity',
|
||||
'controller class' => 'EntityDatabaseStorageController',
|
||||
'base table' => 'entity_test',
|
||||
'fieldable' => TRUE,
|
||||
'entity keys' => array(
|
||||
'id' => 'id',
|
||||
),
|
||||
$items['entity_test'] = array(
|
||||
'label' => t('Test entity'),
|
||||
'entity class' => 'Entity',
|
||||
'controller class' => 'EntityDatabaseStorageController',
|
||||
'base table' => 'entity_test',
|
||||
'fieldable' => TRUE,
|
||||
'entity keys' => array(
|
||||
'id' => 'id',
|
||||
),
|
||||
);
|
||||
return $return;
|
||||
// Optionally specify a translation handler for testing translations.
|
||||
if (!empty($GLOBALS['entity_test_translation'])) {
|
||||
$items['entity_test']['translation']['entity_test'] = TRUE;
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
|
@ -1725,7 +1725,7 @@ function node_search_admin() {
|
|||
*/
|
||||
function node_search_execute($keys = NULL, $conditions = NULL) {
|
||||
// Build matching conditions
|
||||
$query = db_select('search_index', 'i', array('target' => 'slave'))->extend('SearchQuery')->extend('PagerDefault');
|
||||
$query = db_select('search_index', 'i', array('target' => 'slave'))->extend('Drupal\search\SearchQuery')->extend('PagerDefault');
|
||||
$query->join('node', 'n', 'n.nid = i.sid');
|
||||
$query
|
||||
->condition('n.status', 1)
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of Drupal\search\SearchQuery.
|
||||
*/
|
||||
|
||||
namespace Drupal\search;
|
||||
|
||||
use Drupal\Core\Database\Query\SelectExtender;
|
||||
use Drupal\Core\Database\StatementEmpty;
|
||||
|
|
@ -162,10 +162,10 @@ function hook_search_admin() {
|
|||
*
|
||||
* If your module uses hook_update_index() and search_index() to index its
|
||||
* items, use table 'search_index' aliased to 'i' as the main table in your
|
||||
* query, with the 'SearchQuery' extension. You can join to your module's table
|
||||
* using the 'i.sid' field, which will contain the $sid values you provided to
|
||||
* search_index(). Add the main keywords to the query by using method
|
||||
* searchExpression(). The functions search_expression_extract() and
|
||||
* query, with the 'Drupal\search\SearchQuery' extension. You can join to your
|
||||
* module's table using the 'i.sid' field, which will contain the $sid values
|
||||
* you provided to search_index(). Add the main keywords to the query by using
|
||||
* method searchExpression(). The functions search_expression_extract() and
|
||||
* search_expression_insert() may also be helpful for adding custom search
|
||||
* parameters to the search expression.
|
||||
*
|
||||
|
@ -195,7 +195,7 @@ function hook_search_admin() {
|
|||
*/
|
||||
function hook_search_execute($keys = NULL, $conditions = NULL) {
|
||||
// Build matching conditions
|
||||
$query = db_select('search_index', 'i', array('target' => 'slave'))->extend('SearchQuery')->extend('PagerDefault');
|
||||
$query = db_select('search_index', 'i', array('target' => 'slave'))->extend('Drupal\search\SearchQuery')->extend('PagerDefault');
|
||||
$query->join('node', 'n', 'n.nid = i.sid');
|
||||
$query
|
||||
->condition('n.status', 1)
|
||||
|
|
|
@ -3,7 +3,6 @@ description = Enables site-wide keyword searching.
|
|||
package = Core
|
||||
version = VERSION
|
||||
core = 8.x
|
||||
files[] = search.extender.inc
|
||||
files[] = search.test
|
||||
configure = admin/config/search/settings
|
||||
stylesheets[all][] = search.theme.css
|
||||
|
|
|
@ -159,7 +159,7 @@ class SearchMatchTestCase extends SearchWebTestCase {
|
|||
);
|
||||
foreach ($queries as $query => $results) {
|
||||
$result = db_select('search_index', 'i')
|
||||
->extend('SearchQuery')
|
||||
->extend('Drupal\search\SearchQuery')
|
||||
->searchExpression($query, SEARCH_TYPE)
|
||||
->execute();
|
||||
|
||||
|
@ -179,7 +179,7 @@ class SearchMatchTestCase extends SearchWebTestCase {
|
|||
);
|
||||
foreach ($queries as $query => $results) {
|
||||
$result = db_select('search_index', 'i')
|
||||
->extend('SearchQuery')
|
||||
->extend('Drupal\search\SearchQuery')
|
||||
->searchExpression($query, SEARCH_TYPE_2)
|
||||
->execute();
|
||||
|
||||
|
@ -202,7 +202,7 @@ class SearchMatchTestCase extends SearchWebTestCase {
|
|||
);
|
||||
foreach ($queries as $query => $results) {
|
||||
$result = db_select('search_index', 'i')
|
||||
->extend('SearchQuery')
|
||||
->extend('Drupal\search\SearchQuery')
|
||||
->searchExpression($query, SEARCH_TYPE_JPN)
|
||||
->execute();
|
||||
|
||||
|
|
|
@ -6,41 +6,3 @@ core = 8.x
|
|||
files[] = simpletest.test
|
||||
files[] = drupal_web_test_case.php
|
||||
configure = admin/config/development/testing/settings
|
||||
|
||||
; Tests in tests directory.
|
||||
files[] = tests/actions.test
|
||||
files[] = tests/ajax.test
|
||||
files[] = tests/batch.test
|
||||
files[] = tests/bootstrap.test
|
||||
files[] = tests/cache.test
|
||||
files[] = tests/common.test
|
||||
files[] = tests/database_test.test
|
||||
files[] = tests/error.test
|
||||
files[] = tests/file.test
|
||||
files[] = tests/filetransfer.test
|
||||
files[] = tests/form.test
|
||||
files[] = tests/graph.test
|
||||
files[] = tests/image.test
|
||||
files[] = tests/installer.test
|
||||
files[] = tests/lock.test
|
||||
files[] = tests/mail.test
|
||||
files[] = tests/menu.test
|
||||
files[] = tests/module.test
|
||||
files[] = tests/pager.test
|
||||
files[] = tests/password.test
|
||||
files[] = tests/path.test
|
||||
files[] = tests/queue.test
|
||||
files[] = tests/registry.test
|
||||
files[] = tests/schema.test
|
||||
files[] = tests/session.test
|
||||
files[] = tests/symfony.test
|
||||
files[] = tests/tablesort.test
|
||||
files[] = tests/theme.test
|
||||
files[] = tests/unicode.test
|
||||
files[] = tests/update.test
|
||||
files[] = tests/uuid.test
|
||||
files[] = tests/xmlrpc.test
|
||||
files[] = tests/upgrade/upgrade.test
|
||||
files[] = tests/upgrade/upgrade_bare.test
|
||||
files[] = tests/upgrade/upgrade_filled.test
|
||||
files[] = tests/upgrade/upgrade.language.test
|
||||
|
|
|
@ -86,9 +86,9 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
|
|||
function testUserAgentValidation() {
|
||||
if (!$this->inCURL()) {
|
||||
global $base_url;
|
||||
$simpletest_path = $base_url . '/' . drupal_get_path('module', 'simpletest');
|
||||
$HTTP_path = $simpletest_path .'/tests/http.php?q=node';
|
||||
$https_path = $simpletest_path .'/tests/https.php?q=node';
|
||||
$system_path = $base_url . '/' . drupal_get_path('module', 'system');
|
||||
$HTTP_path = $system_path .'/tests/http.php?q=node';
|
||||
$https_path = $system_path .'/tests/https.php?q=node';
|
||||
// Generate a valid simpletest User-Agent to pass validation.
|
||||
$this->assertTrue(preg_match('/simpletest\d+/', $this->databasePrefix, $matches), t('Database prefix contains simpletest prefix.'));
|
||||
$test_ua = drupal_generate_test_ua($matches[0]);
|
||||
|
|
|
@ -6,3 +6,40 @@ core = 8.x
|
|||
files[] = system.test
|
||||
required = TRUE
|
||||
configure = admin/config/system
|
||||
|
||||
; Tests in tests directory.
|
||||
files[] = tests/actions.test
|
||||
files[] = tests/ajax.test
|
||||
files[] = tests/batch.test
|
||||
files[] = tests/bootstrap.test
|
||||
files[] = tests/cache.test
|
||||
files[] = tests/common.test
|
||||
files[] = tests/database_test.test
|
||||
files[] = tests/error.test
|
||||
files[] = tests/file.test
|
||||
files[] = tests/filetransfer.test
|
||||
files[] = tests/form.test
|
||||
files[] = tests/image.test
|
||||
files[] = tests/installer.test
|
||||
files[] = tests/lock.test
|
||||
files[] = tests/mail.test
|
||||
files[] = tests/menu.test
|
||||
files[] = tests/module.test
|
||||
files[] = tests/pager.test
|
||||
files[] = tests/password.test
|
||||
files[] = tests/path.test
|
||||
files[] = tests/queue.test
|
||||
files[] = tests/registry.test
|
||||
files[] = tests/schema.test
|
||||
files[] = tests/session.test
|
||||
files[] = tests/symfony.test
|
||||
files[] = tests/tablesort.test
|
||||
files[] = tests/theme.test
|
||||
files[] = tests/unicode.test
|
||||
files[] = tests/update.test
|
||||
files[] = tests/uuid.test
|
||||
files[] = tests/xmlrpc.test
|
||||
files[] = tests/upgrade/upgrade.test
|
||||
files[] = tests/upgrade/upgrade_bare.test
|
||||
files[] = tests/upgrade/upgrade_filled.test
|
||||
files[] = tests/upgrade/upgrade.language.test
|
||||
|
|
|
@ -615,14 +615,14 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
|
|||
// Verify common_test.css in a STYLE media="all" tag.
|
||||
$elements = $this->xpath('//style[@media=:media and contains(text(), :filename)]', array(
|
||||
':media' => 'all',
|
||||
':filename' => 'tests/common_test.css',
|
||||
':filename' => 'tests/modules/common_test/common_test.css',
|
||||
));
|
||||
$this->assertTrue(count($elements), "Stylesheet with media 'all' in module .info file found.");
|
||||
|
||||
// Verify common_test.print.css in a STYLE media="print" tag.
|
||||
$elements = $this->xpath('//style[@media=:media and contains(text(), :filename)]', array(
|
||||
':media' => 'print',
|
||||
':filename' => 'tests/common_test.print.css',
|
||||
':filename' => 'tests/modules/common_test/common_test.print.css',
|
||||
));
|
||||
$this->assertTrue(count($elements), "Stylesheet with media 'print' in module .info file found.");
|
||||
}
|
||||
|
@ -767,23 +767,22 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
|
|||
*/
|
||||
function testRenderOverride() {
|
||||
$system = drupal_get_path('module', 'system');
|
||||
$simpletest = drupal_get_path('module', 'simpletest');
|
||||
|
||||
drupal_add_css($system . '/system.base.css');
|
||||
drupal_add_css($simpletest . '/tests/system.base.css');
|
||||
drupal_add_css($system . '/tests/system.base.css');
|
||||
|
||||
// The dummy stylesheet should be the only one included.
|
||||
$styles = drupal_get_css();
|
||||
$this->assert(strpos($styles, $simpletest . '/tests/system.base.css') !== FALSE, t('The overriding CSS file is output.'));
|
||||
$this->assert(strpos($styles, $system . '/tests/system.base.css') !== FALSE, t('The overriding CSS file is output.'));
|
||||
$this->assert(strpos($styles, $system . '/system.base.css') === FALSE, t('The overridden CSS file is not output.'));
|
||||
|
||||
drupal_add_css($simpletest . '/tests/system.base.css');
|
||||
drupal_add_css($system . '/tests/system.base.css');
|
||||
drupal_add_css($system . '/system.base.css');
|
||||
|
||||
// The standard stylesheet should be the only one included.
|
||||
$styles = drupal_get_css();
|
||||
$this->assert(strpos($styles, $system . '/system.base.css') !== FALSE, t('The overriding CSS file is output.'));
|
||||
$this->assert(strpos($styles, $simpletest . '/tests/system.base.css') === FALSE, t('The overridden CSS file is not output.'));
|
||||
$this->assert(strpos($styles, $system . '/tests/system.base.css') === FALSE, t('The overridden CSS file is not output.'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2316,7 +2315,7 @@ class CommonDrupalParseInfoFileTestCase extends DrupalUnitTestCase {
|
|||
* Parse an example .info file an verify the results.
|
||||
*/
|
||||
function testParseInfoFile() {
|
||||
$info_values = drupal_parse_info_file(drupal_get_path('module', 'simpletest') . '/tests/common_test_info.txt');
|
||||
$info_values = drupal_parse_info_file(drupal_get_path('module', 'system') . '/tests/common_test_info.txt');
|
||||
$this->assertEqual($info_values['simple_string'], 'A simple string', t('Simple string value was parsed correctly.'), t('System'));
|
||||
$this->assertEqual($info_values['simple_constant'], WATCHDOG_INFO, t('Constant value was parsed correctly.'), t('System'));
|
||||
$this->assertEqual($info_values['double_colon'], 'dummyClassName::', t('Value containing double-colon was parsed correctly.'), t('System'));
|
||||
|
@ -2346,14 +2345,14 @@ class CommonDrupalSystemListingTestCase extends DrupalWebTestCase {
|
|||
// with Drupal core, the copy in the core modules directory takes
|
||||
// precedence.
|
||||
'drupal_system_listing_incompatible_test' => array(
|
||||
'core/modules/simpletest/tests',
|
||||
'core/modules/system/tests/modules',
|
||||
'profiles/testing/modules',
|
||||
),
|
||||
// When both copies of the module are compatible with Drupal core, the
|
||||
// copy in the profile directory takes precedence.
|
||||
'drupal_system_listing_compatible_test' => array(
|
||||
'profiles/testing/modules',
|
||||
'core/modules/simpletest/tests',
|
||||
'core/modules/system/tests/modules',
|
||||
),
|
||||
);
|
||||
|
|
@ -24,19 +24,19 @@ class DrupalErrorHandlerUnitTest extends DrupalWebTestCase {
|
|||
'%type' => 'Notice',
|
||||
'!message' => 'Undefined variable: bananas',
|
||||
'%function' => 'error_test_generate_warnings()',
|
||||
'%file' => drupal_realpath('core/modules/simpletest/tests/error_test.module'),
|
||||
'%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
|
||||
);
|
||||
$error_warning = array(
|
||||
'%type' => 'Warning',
|
||||
'!message' => 'Division by zero',
|
||||
'%function' => 'error_test_generate_warnings()',
|
||||
'%file' => drupal_realpath('core/modules/simpletest/tests/error_test.module'),
|
||||
'%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
|
||||
);
|
||||
$error_user_notice = array(
|
||||
'%type' => 'User warning',
|
||||
'!message' => 'Drupal is awesome',
|
||||
'%function' => 'error_test_generate_warnings()',
|
||||
'%file' => drupal_realpath('core/modules/simpletest/tests/error_test.module'),
|
||||
'%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
|
||||
);
|
||||
|
||||
// Set error reporting to collect notices.
|
||||
|
@ -73,14 +73,14 @@ class DrupalErrorHandlerUnitTest extends DrupalWebTestCase {
|
|||
'!message' => 'Drupal is awesome',
|
||||
'%function' => 'error_test_trigger_exception()',
|
||||
'%line' => 57,
|
||||
'%file' => drupal_realpath('core/modules/simpletest/tests/error_test.module'),
|
||||
'%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
|
||||
);
|
||||
$error_pdo_exception = array(
|
||||
'%type' => 'PDOException',
|
||||
'!message' => 'SELECT * FROM bananas_are_awesome',
|
||||
'%function' => 'error_test_trigger_pdo_exception()',
|
||||
'%line' => 65,
|
||||
'%file' => drupal_realpath('core/modules/simpletest/tests/error_test.module'),
|
||||
'%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
|
||||
);
|
||||
|
||||
$this->drupalGet('error-test/trigger-exception');
|
|
@ -12,7 +12,7 @@ $is_http_mock = !empty($_SERVER['HTTPS']);
|
|||
$_SERVER['HTTPS'] = NULL;
|
||||
ini_set('session.cookie_secure', FALSE);
|
||||
foreach ($_SERVER as $key => $value) {
|
||||
$_SERVER[$key] = str_replace('core/modules/simpletest/tests/http.php', 'index.php', $value);
|
||||
$_SERVER[$key] = str_replace('core/modules/system/tests/http.php', 'index.php', $value);
|
||||
$_SERVER[$key] = str_replace('https://', 'http://', $_SERVER[$key]);
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ $is_https_mock = empty($_SERVER['HTTPS']);
|
|||
// Change to https.
|
||||
$_SERVER['HTTPS'] = 'on';
|
||||
foreach ($_SERVER as $key => $value) {
|
||||
$_SERVER[$key] = str_replace('core/modules/simpletest/tests/https.php', 'index.php', $value);
|
||||
$_SERVER[$key] = str_replace('core/modules/system/tests/https.php', 'index.php', $value);
|
||||
$_SERVER[$key] = str_replace('http://', 'https://', $_SERVER[$key]);
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ function ajax_test_menu() {
|
|||
* Implements hook_system_theme_info().
|
||||
*/
|
||||
function ajax_test_system_theme_info() {
|
||||
$themes['test_theme'] = drupal_get_path('module', 'ajax_test') . '/themes/test_theme/test_theme.info';
|
||||
$themes['test_theme'] = drupal_get_path('module', 'system') . '/tests/themes/test_theme/test_theme.info';
|
||||
return $themes;
|
||||
}
|
||||
|
|
@ -28,6 +28,7 @@ function database_test_schema() {
|
|||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'binary' => TRUE,
|
||||
),
|
||||
'age' => array(
|
||||
'description' => "The person's age",
|
|
@ -3133,6 +3133,39 @@ class DatabaseBasicSyntaxTestCase extends DatabaseTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case sensitivity handling.
|
||||
*/
|
||||
class DatabaseCaseSensitivityTestCase extends DatabaseTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Case sensitivity',
|
||||
'description' => 'Test handling case sensitive collation.',
|
||||
'group' => 'Database',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test BINARY collation in MySQL.
|
||||
*/
|
||||
function testCaseSensitiveInsert() {
|
||||
$num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
|
||||
|
||||
$john = db_insert('test')
|
||||
->fields(array(
|
||||
'name' => 'john', // <- A record already exists with name 'John'.
|
||||
'age' => 2,
|
||||
'job' => 'Baby',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$num_records_after = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
|
||||
$this->assertIdentical($num_records_before + 1, (int) $num_records_after, t('Record inserts correctly.'));
|
||||
$saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'john'))->fetchField();
|
||||
$this->assertIdentical($saved_age, '2', t('Can retrieve after inserting.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test invalid data handling.
|
||||
*/
|
|
@ -1972,7 +1972,7 @@ function form_test_load_include_custom($form, &$form_state) {
|
|||
// Specify the include file and enable form caching. That way the form is
|
||||
// cached when it is submitted, but needs to find the specified submit handler
|
||||
// in the include.
|
||||
// Filename is a bit weird here: modules/simpletest/tests/form_test.file.inc
|
||||
// Filename is a bit weird here: modules/system/tests/form_test.file.inc
|
||||
form_load_include($form_state, 'inc', 'form_test', 'form_test.file');
|
||||
$form_state['cache'] = TRUE;
|
||||
return $form;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue