diff --git a/core/modules/image/src/Tests/ImageFieldTestBase.php b/core/modules/image/src/Tests/ImageFieldTestBase.php
index c023917e36..6ac64b81ec 100644
--- a/core/modules/image/src/Tests/ImageFieldTestBase.php
+++ b/core/modules/image/src/Tests/ImageFieldTestBase.php
@@ -2,6 +2,8 @@
namespace Drupal\image\Tests;
+@trigger_error('The ' . __NAMESPACE__ . '\ImageFieldTestBase is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0. Use \Drupal\Tests\image\Functional\ImageFieldTestBase instead. See https://www.drupal.org/node/2863626.', E_USER_DEPRECATED);
+
use Drupal\Tests\image\Kernel\ImageFieldCreationTrait;
use Drupal\simpletest\WebTestBase;
diff --git a/core/modules/image/src/Tests/FileMoveTest.php b/core/modules/image/tests/src/Functional/FileMoveTest.php
similarity index 83%
rename from core/modules/image/src/Tests/FileMoveTest.php
rename to core/modules/image/tests/src/Functional/FileMoveTest.php
index d9ce27f75d..3cf3be71b8 100644
--- a/core/modules/image/src/Tests/FileMoveTest.php
+++ b/core/modules/image/tests/src/Functional/FileMoveTest.php
@@ -1,17 +1,23 @@
drupalGet("admin/structure/types/manage/article/display");
// Test for existence of link to image styles configuration.
- $this->drupalPostAjaxForm(NULL, [], "{$field_name}_settings_edit");
+ $this->drupalPostForm(NULL, [], "{$field_name}_settings_edit");
$this->assertLinkByHref(\Drupal::url('entity.image_style.collection'), 0, 'Link to image styles configuration is found');
// Remove 'administer image styles' permission from testing admin user.
@@ -65,7 +73,7 @@ public function _testImageFieldFormatters($scheme) {
$this->drupalGet("admin/structure/types/manage/article/display");
// Test for absence of link to image styles configuration.
- $this->drupalPostAjaxForm(NULL, [], "{$field_name}_settings_edit");
+ $this->drupalPostForm(NULL, [], "{$field_name}_settings_edit");
$this->assertNoLinkByHref(\Drupal::url('entity.image_style.collection'), 'Link to image styles configuration is absent when permissions are insufficient');
// Restore 'administer image styles' permission to testing admin user
@@ -258,6 +266,7 @@ public function testImageFieldSettings() {
$nid = $this->uploadNodeImage($test_image, $field_name, 'article', $alt);
$this->drupalGet('node/' . $nid . '/edit');
+ // TODO: result is not "" as expected.
$this->assertFieldByName($field_name . '[0][alt]', '', 'Alt field displayed on article form.');
$this->assertFieldByName($field_name . '[0][title]', '', 'Title field displayed on article form.');
// Verify that the attached image is being previewed using the 'medium'
@@ -324,7 +333,7 @@ public function testImageFieldSettings() {
$edit = [
'files[' . $field_name . '_2][]' => drupal_realpath($test_image->uri),
];
- $this->drupalPostAjaxForm(NULL, $edit, $field_name . '_2_upload_button');
+ $this->drupalPostForm(NULL, $edit, $field_name . '_2_upload_button');
$this->assertNoRaw('');
$this->assertRaw('');
}
diff --git a/core/modules/image/tests/src/Functional/ImageFieldTestBase.php b/core/modules/image/tests/src/Functional/ImageFieldTestBase.php
index 5fa0614040..7a226dc3b3 100644
--- a/core/modules/image/tests/src/Functional/ImageFieldTestBase.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldTestBase.php
@@ -86,11 +86,12 @@ public function uploadNodeImage($image, $field_name, $type, $alt = '') {
$edit = [
'title[0][value]' => $this->randomMachineName(),
];
+
$edit['files[' . $field_name . '_0]'] = drupal_realpath($image->uri);
- $this->drupalPostForm('node/add/' . $type, $edit, t('Save and publish'));
+ $this->drupalPostForm('node/add/' . $type, $edit, t('Save'));
if ($alt) {
// Add alt text.
- $this->drupalPostForm(NULL, [$field_name . '[0][alt]' => $alt], t('Save and publish'));
+ $this->drupalPostForm(NULL, [$field_name . '[0][alt]' => $alt], t('Save'));
}
// Retrieve ID of the newly created node from the current URL.
diff --git a/core/modules/image/src/Tests/ImageFieldValidateTest.php b/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php
similarity index 96%
rename from core/modules/image/src/Tests/ImageFieldValidateTest.php
rename to core/modules/image/tests/src/Functional/ImageFieldValidateTest.php
index e429d0bb20..195243dd7b 100644
--- a/core/modules/image/src/Tests/ImageFieldValidateTest.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php
@@ -1,6 +1,8 @@
drupalGet('quickedit/image/info/node/' . $node->id() . '/' . $this->fieldName . '/' . $node->language()->getId() . '/default');
$this->assertResponse('403');
- $this->drupalPost('quickedit/image/upload/node/' . $node->id() . '/' . $this->fieldName . '/' . $node->language()->getId() . '/default', 'application/json', []);
- $this->assertResponse('403');
+
+ /** @var \Symfony\Component\BrowserKit\Client $client */
+ $client = $this->getSession()->getDriver()->getClient();
+ $client->request('POST', '/quickedit/image/upload/node/' . $node->id() . '/' . $this->fieldName . '/' . $node->language()->getId() . '/default');
+ $this->assertEquals('403', $client->getResponse()->getStatus());
+
}
/**
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index abdedd9c03..727020af5b 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -669,6 +669,43 @@ protected function drupalGet($path, array $options = [], array $headers = []) {
return $out;
}
+ /**
+ * Retrieves a Drupal path or an absolute path and JSON decodes the result.
+ *
+ * @param \Drupal\Core\Url|string $path
+ * Drupal path or URL to request AJAX from.
+ * @param array $options
+ * Array of URL options.
+ * @param array $headers
+ * Array of headers. Eg array('Accept: application/vnd.drupal-ajax').
+ *
+ * @return array
+ * Decoded json.
+ */
+ protected function drupalGetJSON($path, array $options = [], array $headers = []) {
+ return Json::decode($this->drupalGetWithFormat($path, 'json', $options, $headers));
+ }
+
+ /**
+ * Retrieves a Drupal path or an absolute path for a given format.
+ *
+ * @param \Drupal\Core\Url|string $path
+ * Drupal path or URL to request given format from.
+ * @param string $format
+ * The wanted request format.
+ * @param array $options
+ * Array of URL options.
+ * @param array $headers
+ * Array of headers.
+ *
+ * @return mixed
+ * The result of the request.
+ */
+ protected function drupalGetWithFormat($path, $format, array $options = [], array $headers = []) {
+ $options += ['query' => ['_format' => $format]];
+ return $this->drupalGet($path, $options, $headers);
+ }
+
/**
* Takes a path and returns an absolute path.
*