Commit 880f697a authored by alexpott's avatar alexpott

Issue #2093173 by longwave, Cyberschorsch, forbesgraham, sandipmkhairnar,...

Issue #2093173 by longwave, Cyberschorsch, forbesgraham, sandipmkhairnar, damiankloip, rbayliss, grom358, harijari, InternetDevels, dawehner: Remove all calls to drupal_json_decode(), use \Drupal\Component\Utility\Json::decode().
parent 2252ba8e
......@@ -7,6 +7,7 @@
namespace Drupal\block\Tests\Views;
use Drupal\Component\Utility\Json;
use Drupal\Component\Utility\String;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestBase;
......@@ -293,7 +294,7 @@ public function testBlockContextualLinks() {
$post = array('ids[0]' => $id);
$response = $this->drupalPost('contextual/render', 'application/json', $post, array('query' => array('destination' => 'test-page')));
$this->assertResponse(200);
$json = drupal_json_decode($response);
$json = Json::decode($response);
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '">Configure block</a></li><li class="views-uiedit"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>');
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment\Tests;
use Drupal\Component\Utility\Json;
use Drupal\Core\Language\Language;
use Drupal\comment\CommentInterface;
......@@ -116,7 +117,7 @@ public function testCommentNewCommentsIndicator() {
$this->assertIdentical(1, count($this->xpath('//*[@data-history-node-field-name="comment"]')), 'data-history-node-field-name attribute is set to the correct value.');
$response = $this->renderNewCommentsNodeLinks(array($this->node->id()));
$this->assertResponse(200);
$json = drupal_json_decode($response);
$json = Json::decode($response);
$expected = array($this->node->id() => array(
'new_comment_count' => 1,
'first_new_comment_link' => url('node/' . $this->node->id(), array('fragment' => 'new')),
......
......@@ -5,6 +5,7 @@
* Adds contextual links to perform actions related to elements on a page.
*/
use Drupal\Component\Utility\Json;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Template\Attribute;
......@@ -240,7 +241,7 @@ function contextual_pre_render_links($element) {
function contextual_contextual_links_view_alter(&$element, $items) {
if (isset($element['#contextual_links']['contextual'])) {
$encoded_links = $element['#contextual_links']['contextual']['metadata']['contextual-views-field-links'];
$element['#links'] = drupal_json_decode(rawurldecode($encoded_links));
$element['#links'] = Json::decode(rawurldecode($encoded_links));
}
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\contextual\Tests;
use Drupal\Component\Utility\Json;
use Drupal\simpletest\WebTestBase;
use Drupal\Core\Template\Attribute;
......@@ -77,7 +78,7 @@ function testDifferentPermissions() {
$this->assertRaw('No contextual ids specified.');
$response = $this->renderContextualLinks($ids, 'node');
$this->assertResponse(200);
$json = drupal_json_decode($response);
$json = Json::decode($response);
$this->assertIdentical($json[$ids[0]], '<ul class="contextual-links"><li class="nodepage-edit"><a href="' . base_path() . 'node/1/edit">Edit</a></li></ul>');
$this->assertIdentical($json[$ids[1]], '');
$this->assertIdentical($json[$ids[2]], '<ul class="contextual-links"><li class="nodepage-edit"><a href="' . base_path() . 'node/3/edit">Edit</a></li></ul>');
......@@ -94,7 +95,7 @@ function testDifferentPermissions() {
$this->assertRaw('No contextual ids specified.');
$response = $this->renderContextualLinks($ids, 'node');
$this->assertResponse(200);
$json = drupal_json_decode($response);
$json = Json::decode($response);
$this->assertIdentical($json[$ids[0]], '');
$this->assertIdentical($json[$ids[1]], '');
$this->assertIdentical($json[$ids[2]], '');
......
......@@ -7,6 +7,7 @@
namespace Drupal\edit\Tests;
use Drupal\Component\Utility\Json;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
......@@ -142,7 +143,7 @@ public function testAutocompleteEdit() {
$edit_uri = 'edit/form/node/'. $this->node->id() . '/' . $this->field_name . '/und/full';
$post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
$response = $this->drupalPost($edit_uri, 'application/vnd.drupal-ajax', $post);
$ajax_commands = drupal_json_decode($response);
$ajax_commands = Json::decode($response);
// Prepare form values for submission. drupalPostAJAX() is not suitable for
// handling pages with JSON responses, so we need our own solution here.
......@@ -161,7 +162,7 @@ public function testAutocompleteEdit() {
// Submit field form and check response. Should render back all the terms.
$response = $this->drupalPost($edit_uri, 'application/vnd.drupal-ajax', $post);
$this->assertResponse(200);
$ajax_commands = drupal_json_decode($response);
$ajax_commands = Json::decode($response);
$this->drupalSetContent($ajax_commands[0]['data']);
$this->assertLink($this->term1->getName());
$this->assertLink($this->term2->getName());
......@@ -172,7 +173,7 @@ public function testAutocompleteEdit() {
$edit_uri = 'edit/form/node/'. $this->node->id() . '/' . $this->field_name . '/und/full';
$post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
$response = $this->drupalPost($edit_uri, 'application/vnd.drupal-ajax', $post);
$ajax_commands = drupal_json_decode($response);
$ajax_commands = Json::decode($response);
// The AjaxResponse's first command is an InsertCommand which contains
// the form to edit the taxonomy term field, it should contain all three
......
......@@ -7,6 +7,7 @@
namespace Drupal\editor\Tests;
use Drupal\Component\Utility\Json;
use Drupal\simpletest\WebTestBase;
/**
......@@ -113,7 +114,7 @@ public function testUserWithPermission() {
$response = $this->drupalPost('editor/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', array());
$this->assertResponse(200);
$ajax_commands = drupal_json_decode($response);
$ajax_commands = Json::decode($response);
$this->assertIdentical(1, count($ajax_commands), 'The untransformed text POST request results in one AJAX command.');
$this->assertIdentical('editorGetUntransformedText', $ajax_commands[0]['command'], 'The first AJAX command is an editorGetUntransformedText command.');
$this->assertIdentical('<p>Do you also love Drupal?</p><img src="druplicon.png" data-caption="Druplicon" />', $ajax_commands[0]['data'], 'The editorGetUntransformedText command contains the expected data.');
......
......@@ -7,6 +7,7 @@
namespace Drupal\editor\Tests;
use Drupal\Component\Utility\Json;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\String;
......@@ -387,7 +388,7 @@ function testSwitchingSecurity() {
);
$response = $this->drupalPost('editor/filter_xss/' . $format, 'application/json', $post);
$this->assertResponse(200);
$json = drupal_json_decode($response);
$json = Json::decode($response);
$this->assertIdentical($json, $expected_filtered_value, 'The value was correctly filtered for XSS attack vectors.');
}
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\entity_reference\Tests;
use Drupal\Component\Utility\Json;
use Drupal\Component\Utility\Tags;
use Drupal\entity_reference\EntityReferenceController;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
......@@ -130,6 +131,6 @@ protected function getAutocompleteResult($type, $input) {
$entity_reference_controller = EntityReferenceController::create($this->container);
$result = $entity_reference_controller->handleAutocomplete($request, $type, $this->fieldName, $this->entityType, $this->bundle, 'NULL')->getContent();
return drupal_json_decode($result);
return Json::decode($result);
}
}
......@@ -7,6 +7,7 @@
namespace Drupal\history\Tests;
use Drupal\Component\Utility\Json;
use Drupal\simpletest\WebTestBase;
/**
......@@ -117,7 +118,7 @@ function testHistory() {
// Retrieve "last read" timestamp for test node, for the current user.
$response = $this->getNodeReadTimestamps(array($nid));
$this->assertResponse(200);
$json = drupal_json_decode($response);
$json = Json::decode($response);
$this->assertIdentical(array(1 => 0), $json, 'The node has not yet been read.');
// View the node.
......@@ -130,13 +131,13 @@ function testHistory() {
// Simulate JavaScript: perform HTTP request to mark node as read.
$response = $this->markNodeAsRead($nid);
$this->assertResponse(200);
$timestamp = drupal_json_decode($response);
$timestamp = Json::decode($response);
$this->assertTrue(is_numeric($timestamp), 'Node has been marked as read. Timestamp received.');
// Retrieve "last read" timestamp for test node, for the current user.
$response = $this->getNodeReadTimestamps(array($nid));
$this->assertResponse(200);
$json = drupal_json_decode($response);
$json = Json::decode($response);
$this->assertIdentical(array(1 => $timestamp), $json, 'The node has been read.');
// Failing to specify node IDs for the first endpoint should return a 404.
......
......@@ -7,6 +7,8 @@
namespace Drupal\menu\Tests;
use Drupal\Component\Utility\Json;
/**
* Defines a test class for testing menu and menu link functionality.
*/
......@@ -474,7 +476,7 @@ public function testBlockContextualLinks() {
$post = array('ids[0]' => $id);
$response = $this->drupalPost('contextual/render', 'application/json', $post, array('query' => array('destination' => 'test-page')));
$this->assertResponse(200);
$json = drupal_json_decode($response);
$json = Json::decode($response);
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '">Configure block</a></li><li class="menu-edit"><a href="' . base_path() . 'admin/structure/menu/manage/tools">Edit menu</a></li></ul>');
}
......
......@@ -7,6 +7,8 @@
namespace Drupal\rest\Tests;
use Drupal\Component\Utility\Json;
/**
* Tests resource creation on user, node and test entities.
*/
......@@ -105,7 +107,7 @@ public function testCreate() {
$invalid_serialized = $serializer->serialize($entity, $this->defaultFormat);
$response = $this->httpRequest('entity/' . $entity_type, 'POST', $invalid_serialized, $this->defaultMimeType);
$this->assertResponse(422);
$error = drupal_json_decode($response);
$error = Json::decode($response);
$this->assertEqual($error['error'], "Unprocessable Entity: validation failed.\nuuid.0.value: <em class=\"placeholder\">UUID</em>: may not be longer than 128 characters.\n");
// Try to create an entity without proper permissions.
......
......@@ -7,6 +7,7 @@
namespace Drupal\rest\Tests;
use Drupal\Component\Utility\Json;
use Drupal\rest\Tests\RESTTestBase;
/**
......@@ -53,7 +54,7 @@ public function testWatchdog() {
$response = $this->httpRequest("dblog/$id", 'GET', NULL, $this->defaultMimeType);
$this->assertResponse(200);
$this->assertHeader('content-type', $this->defaultMimeType);
$log = drupal_json_decode($response);
$log = Json::decode($response);
$this->assertEqual($log['wid'], $id, 'Log ID is correct.');
$this->assertEqual($log['type'], 'rest_test', 'Type of log message is correct.');
$this->assertEqual($log['message'], 'Test message', 'Log message text is correct.');
......@@ -61,7 +62,7 @@ public function testWatchdog() {
// Request an unknown log entry.
$response = $this->httpRequest("dblog/9999", 'GET', NULL, $this->defaultMimeType);
$this->assertResponse(404);
$decoded = drupal_json_decode($response);
$decoded = Json::decode($response);
$this->assertEqual($decoded['error'], 'Log entry with ID 9999 was not found', 'Response message is correct.');
}
}
......@@ -7,6 +7,7 @@
namespace Drupal\rest\Tests;
use Drupal\Component\Utility\Json;
use Drupal\rest\Tests\RESTTestBase;
/**
......@@ -61,7 +62,7 @@ public function testDelete() {
// Try to delete an entity that does not exist.
$response = $this->httpRequest('entity/' . $entity_type . '/9999', 'DELETE');
$this->assertResponse(404);
$decoded = drupal_json_decode($response);
$decoded = Json::decode($response);
$this->assertEqual($decoded['error'], 'Entity with ID 9999 not found', 'Response message is correct.');
// Try to delete an entity without proper permissions.
......
......@@ -7,6 +7,7 @@
namespace Drupal\rest\Tests;
use Drupal\Component\Utility\Json;
use Drupal\Core\Language\Language;
use Drupal\rest\Tests\RESTTestBase;
......@@ -53,7 +54,7 @@ public function testRead() {
$response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'GET', NULL, $this->defaultMimeType);
$this->assertResponse('200', 'HTTP response code is correct.');
$this->assertHeader('content-type', $this->defaultMimeType);
$data = drupal_json_decode($response);
$data = Json::decode($response);
// Only assert one example property here, other properties should be
// checked in serialization tests.
$this->assertEqual($data['uuid'][0]['value'], $entity->uuid(), 'Entity UUID is correct');
......@@ -65,7 +66,7 @@ public function testRead() {
// Try to read an entity that does not exist.
$response = $this->httpRequest('entity/' . $entity_type . '/9999', 'GET', NULL, $this->defaultMimeType);
$this->assertResponse(404);
$decoded = drupal_json_decode($response);
$decoded = Json::decode($response);
$this->assertEqual($decoded['error'], 'Entity with ID 9999 not found', 'Response message is correct.');
// Make sure that field level access works and that the according field is
......@@ -77,7 +78,7 @@ public function testRead() {
$response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'GET', NULL, $this->defaultMimeType);
$this->assertResponse(200);
$this->assertHeader('content-type', $this->defaultMimeType);
$data = drupal_json_decode($response);
$data = Json::decode($response);
$this->assertFalse(isset($data['field_test_text']), 'Field access protected field is not visible in the response.');
}
......@@ -85,14 +86,14 @@ public function testRead() {
$this->drupalLogout();
$response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'GET', NULL, $this->defaultMimeType);
$this->assertResponse(403);
$this->assertNull(drupal_json_decode($response), 'No valid JSON found.');
$this->assertNull(Json::decode($response), 'No valid JSON found.');
}
// Try to read a resource which is not REST API enabled.
$account = $this->drupalCreateUser();
$this->drupalLogin($account);
$response = $this->httpRequest('entity/user/' . $account->id(), 'GET', NULL, $this->defaultMimeType);
$this->assertResponse(404);
$this->assertNull(drupal_json_decode($response), 'No valid JSON found.');
$this->assertNull(Json::decode($response), 'No valid JSON found.');
}
/**
......
......@@ -7,6 +7,7 @@
namespace Drupal\rest\Tests;
use Drupal\Component\Utility\Json;
use Drupal\rest\Tests\RESTTestBase;
/**
......@@ -148,7 +149,7 @@ public function testPatchUpdate() {
$invalid_serialized = $serializer->serialize($entity, $this->defaultFormat);
$response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $invalid_serialized, $this->defaultMimeType);
$this->assertResponse(422);
$error = drupal_json_decode($response);
$error = Json::decode($response);
$this->assertEqual($error['error'], "Unprocessable Entity: validation failed.\nuuid.0.value: <em class=\"placeholder\">UUID</em>: may not be longer than 128 characters.\n");
// Try to update an entity without proper permissions.
......
......@@ -8,6 +8,7 @@
namespace Drupal\simpletest;
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Json;
use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\String;
use Drupal\Core\DrupalKernel;
......@@ -1422,7 +1423,7 @@ protected function drupalGet($path, array $options = array(), array $headers = a
*/
protected function drupalGetJSON($path, array $options = array(), array $headers = array()) {
$headers[] = 'Accept: application/json';
return drupal_json_decode($this->drupalGet($path, $options, $headers));
return Json::decode($this->drupalGet($path, $options, $headers));
}
/**
......@@ -1430,7 +1431,7 @@ protected function drupalGetJSON($path, array $options = array(), array $headers
*/
protected function drupalGetAJAX($path, array $options = array(), array $headers = array()) {
$headers[] = 'Accept: application/vnd.drupal-ajax';
return drupal_json_decode($this->drupalGet($path, $options, $headers));
return Json::decode($this->drupalGet($path, $options, $headers));
}
/**
......@@ -1703,7 +1704,7 @@ protected function drupalPostAjaxForm($path, $edit, $triggering_element, $ajax_p
}
// Submit the POST request.
$return = drupal_json_decode($this->drupalPostForm(NULL, $edit, array('path' => $ajax_path, 'triggering_element' => $triggering_element), $options, $headers, $form_html_id, $extra_post));
$return = Json::decode($this->drupalPostForm(NULL, $edit, array('path' => $ajax_path, 'triggering_element' => $triggering_element), $options, $headers, $form_html_id, $extra_post));
// Change the page content by applying the returned commands.
if (!empty($ajax_settings) && !empty($return)) {
......@@ -2583,7 +2584,7 @@ protected function drupalSetContent($content, $url = 'internal:') {
$this->elements = FALSE;
$this->drupalSettings = array();
if (preg_match('/var drupalSettings = (.*?);$/m', $content, $matches)) {
$this->drupalSettings = drupal_json_decode($matches[1]);
$this->drupalSettings = Json::decode($matches[1]);
}
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Common;
use Drupal\Component\Utility\Json;
use Drupal\simpletest\DrupalUnitTestBase;
use Drupal\Component\Utility\Crypt;
......@@ -242,7 +243,7 @@ function testHeaderSetting() {
$start = strpos($javascript, $startToken) + strlen($startToken);
$end = strrpos($javascript, $endToken);
$json = drupal_substr($javascript, $start, $end - $start + 1);
$parsed_settings = drupal_json_decode($json);
$parsed_settings = Json::decode($json);
// Test whether the two real world cases are handled correctly.
$settings_two['moduleName']['thingiesOnPage']['id1'] = array();
......
......@@ -8,6 +8,7 @@
namespace Drupal\system\Tests\Common;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Json;
use Drupal\simpletest\DrupalUnitTestBase;
/**
......@@ -1008,7 +1009,7 @@ protected function parseDrupalSettings($html) {
$start = strpos($html, $startToken) + strlen($startToken);
$end = strrpos($html, $endToken);
$json = drupal_substr($html, $start, $end - $start + 1);
$parsed_settings = drupal_json_decode($json);
$parsed_settings = Json::decode($json);
return $parsed_settings;
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Form;
use Drupal\Component\Utility\Json;
use Drupal\simpletest\WebTestBase;
/**
......@@ -44,14 +45,14 @@ function testFormEmail() {
$edit = array();
$edit['email_required'] = ' foo.bar@example.com ';
$values = drupal_json_decode($this->drupalPostForm('form-test/email', $edit, 'Submit'));
$values = Json::decode($this->drupalPostForm('form-test/email', $edit, 'Submit'));
$this->assertIdentical($values['email'], '');
$this->assertEqual($values['email_required'], 'foo.bar@example.com');
$edit = array();
$edit['email'] = 'foo@example.com';
$edit['email_required'] = 'example@drupal.org';
$values = drupal_json_decode($this->drupalPostForm('form-test/email', $edit, 'Submit'));
$values = Json::decode($this->drupalPostForm('form-test/email', $edit, 'Submit'));
$this->assertEqual($values['email'], 'foo@example.com');
$this->assertEqual($values['email_required'], 'example@drupal.org');
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Form;
use Drupal\Component\Utility\Json;
use Drupal\Component\Utility\String;
use Drupal\simpletest\WebTestBase;
......@@ -273,7 +274,7 @@ function testCheckboxProcessing() {
$this->assertRaw(t('!name field is required.', array('!name' => 'required_checkbox')), 'A required checkbox is actually mandatory');
// Now try to submit the form correctly.
$values = drupal_json_decode($this->drupalPostForm(NULL, array('required_checkbox' => 1), t('Submit')));
$values = Json::decode($this->drupalPostForm(NULL, array('required_checkbox' => 1), t('Submit')));
$expected_values = array(
'disabled_checkbox_on' => 'disabled_checkbox_on',
'disabled_checkbox_off' => '',
......@@ -327,7 +328,7 @@ function testSelect() {
'multiple_no_default_required[]' => 'three',
);
$this->drupalPostForm(NULL, $edit, 'Submit');
$values = drupal_json_decode($this->drupalGetContent());
$values = Json::decode($this->drupalGetContent());
// Verify expected values.
$expected = array(
......@@ -507,7 +508,7 @@ function testDisabledElements() {
// Submit the form with no input, as the browser does for disabled elements,
// and fetch the $form_state['values'] that is passed to the submit handler.
$this->drupalPostForm('form-test/disabled-elements', array(), t('Submit'));
$returned_values['normal'] = drupal_json_decode($this->content);
$returned_values['normal'] = Json::decode($this->content);
// Do the same with input, as could happen if JavaScript un-disables an
// element. drupalPostForm() emulates a browser by not submitting input for
......@@ -529,7 +530,7 @@ function testDisabledElements() {
)));
$this->drupalPostForm(NULL, $edit, t('Submit'));
$returned_values['hijacked'] = drupal_json_decode($this->content);
$returned_values['hijacked'] = Json::decode($this->content);
// Ensure that the returned values match the form's default values in both
// cases.
......
......@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Form;
use Drupal\Component\Utility\Json;
use Drupal\simpletest\WebTestBase;
use Drupal\Core\Language\Language;
......@@ -89,7 +90,7 @@ function testHiddenLanguageSelectElement() {
// field elements.
$edit = array();
$this->drupalPostForm(NULL, $edit, t('Submit'));
$values = drupal_json_decode($this->drupalGetContent());
$values = Json::decode($this->drupalGetContent());
$this->assertEqual($values['languages_all'], 'xx');
$this->assertEqual($values['languages_configurable'], 'en');
$this->assertEqual($values['languages_locked'], Language::LANGCODE_NOT_SPECIFIED);
......
......@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Form;
use Drupal\Component\Utility\Json;
use Drupal\simpletest\WebTestBase;
/**
......@@ -33,7 +34,7 @@ public static function getInfo() {
* Tests form_state_values_clean().
*/
function testFormStateValuesClean() {
$values = drupal_json_decode($this->drupalPostForm('form_test/form-state-values-clean', array(), t('Submit')));
$values = Json::decode($this->drupalPostForm('form_test/form-state-values-clean', array(), t('Submit')));
// Setup the expected result.
$result = array(
......
......@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Form;
use Drupal\Component\Utility\Json;
use Drupal\simpletest\WebTestBase;
/**
......@@ -45,14 +46,14 @@ function testFormUrl() {
$edit = array();
$edit['url'] = "\n";
$edit['url_required'] = 'http://example.com/ ';
$values = drupal_json_decode($this->drupalPostForm('form-test/url', $edit, 'Submit'));
$values = Json::decode($this->drupalPostForm('form-test/url', $edit, 'Submit'));
$this->assertIdentical($values['url'], '');
$this->assertEqual($values['url_required'], 'http://example.com/');
$edit = array();
$edit['url'] = 'http://foo.bar.example.com/';
$edit['url_required'] = 'http://drupal.org/node/1174630?page=0&foo=bar#new';
$values = drupal_json_decode($this->drupalPostForm('form-test/url', $edit, 'Submit'));
$values = Json::decode($this->drupalPostForm('form-test/url', $edit, 'Submit'));
$this->assertEqual($values['url'], $edit['url']);
$this->assertEqual($values['url_required'], $edit['url_required']);
}
......
......@@ -263,7 +263,7 @@ function testTermAutocompletion() {
$path = 'taxonomy/autocomplete/node/taxonomy_' . $this->vocabulary->id();
// The result order is not guaranteed, so check each term separately.
$result = $this->drupalGet($path, array('query' => array('q' => $input)));
$data = drupal_json_decode($result);
$data = Json::decode($result);
$this->assertEqual($data[0]['label'], String::checkPlain($first_term->getName()), 'Autocomplete returned the first matching term');
$this->assertEqual($data[1]['label'], String::checkPlain($second_term->getName()), 'Autocomplete returned the second matching term');
......
......@@ -7,6 +7,7 @@
namespace Drupal\views_ui\Tests;
use Drupal\Component\Utility\Json;
use Drupal\Component\Utility\String;
use Drupal\views\Views;
......@@ -188,7 +189,7 @@ public function testPageContextualLinks() {
$post = array('ids[0]' => $id);
$response = $this->drupalPost('contextual/render', 'application/json', $post, array('query' => array('destination' => 'test-display')));
$this->assertResponse(200);
$json = drupal_json_decode($response);
$json = Json::decode($response);
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="views-uiedit"><a href="' . base_path() . 'admin/structure/views/view/test_display/edit/page_1">Edit view</a></li></ul>');
}
......
......@@ -7,6 +7,8 @@
namespace Drupal\views_ui\Tests;
use Drupal\Component\Utility\Json;
/**
* Tests the preview form in the UI.
*/
......@@ -235,7 +237,7 @@ protected function clickPreviewLinkAJAX($url, $row_count) {
);
$url = $this->getAbsoluteUrl($url);
$post = array('js' => 'true') + $this->getAjaxPageStatePostData();
$result = drupal_json_decode($this->drupalPost($url, 'application/vnd.drupal-ajax', $post));
$result = Json::decode($this->drupalPost($url, 'application/vnd.drupal-ajax', $post));
if (!empty($result)) {
$this->drupalProcessAjaxResponse($content, $result, $ajax_settings, $drupal_settings);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment