Issue #3097749 by kim.pepper, martin107: Remove all @deprecated code in the image module
parent
b1ca6b9d2a
commit
40dc7dbd7f
|
@ -15,51 +15,6 @@ use Drupal\field\FieldStorageConfigInterface;
|
|||
use Drupal\file\FileInterface;
|
||||
use Drupal\image\Entity\ImageStyle;
|
||||
|
||||
/**
|
||||
* Image style constant for user presets in the database.
|
||||
*
|
||||
* @deprecated in drupal:8.1.0 and is removed from drupal:9.0.0.
|
||||
*
|
||||
* @see https://www.drupal.org/node/1820974
|
||||
*/
|
||||
const IMAGE_STORAGE_NORMAL = 1;
|
||||
|
||||
/**
|
||||
* Image style constant for user presets that override module-defined presets.
|
||||
*
|
||||
* @deprecated in drupal:8.1.0 and is removed from drupal:9.0.0.
|
||||
*
|
||||
* @see https://www.drupal.org/node/1820974
|
||||
*/
|
||||
const IMAGE_STORAGE_OVERRIDE = 2;
|
||||
|
||||
/**
|
||||
* Image style constant for module-defined presets in code.
|
||||
*
|
||||
* @deprecated in drupal:8.1.0 and is removed from drupal:9.0.0.
|
||||
*
|
||||
* @see https://www.drupal.org/node/1820974
|
||||
*/
|
||||
const IMAGE_STORAGE_DEFAULT = 4;
|
||||
|
||||
/**
|
||||
* Image style constant to represent an editable preset.
|
||||
*
|
||||
* @deprecated in drupal:8.1.0 and is removed from drupal:9.0.0.
|
||||
*
|
||||
* @see https://www.drupal.org/node/1820974
|
||||
*/
|
||||
define('IMAGE_STORAGE_EDITABLE', IMAGE_STORAGE_NORMAL | IMAGE_STORAGE_OVERRIDE);
|
||||
|
||||
/**
|
||||
* Image style constant to represent any module-based preset.
|
||||
*
|
||||
* @deprecated in drupal:8.1.0 and is removed from drupal:9.0.0.
|
||||
*
|
||||
* @see https://www.drupal.org/node/1820974
|
||||
*/
|
||||
define('IMAGE_STORAGE_MODULE', IMAGE_STORAGE_OVERRIDE | IMAGE_STORAGE_DEFAULT);
|
||||
|
||||
/**
|
||||
* The name of the query parameter for image derivative tokens.
|
||||
*/
|
||||
|
|
|
@ -505,51 +505,6 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity
|
|||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a wrapper for file_uri_scheme() to allow unit testing.
|
||||
*
|
||||
* Returns the scheme of a URI (e.g. a stream).
|
||||
*
|
||||
* @param string $uri
|
||||
* A stream, referenced as "scheme://target" or "data:target".
|
||||
*
|
||||
* @return string
|
||||
* A string containing the name of the scheme, or FALSE if none. For
|
||||
* example, the URI "public://example.txt" would return "public".
|
||||
*
|
||||
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
|
||||
* \Drupal\Core\StreamWrapper\StreamWrapperManager::getTarget() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3035273
|
||||
*/
|
||||
protected function fileUriScheme($uri) {
|
||||
@trigger_error('fileUriTarget() is deprecated in drupal:8.8.0. It will be removed from drupal:9.0.0. See https://www.drupal.org/node/3035273', E_USER_DEPRECATED);
|
||||
return StreamWrapperManager::getScheme($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a wrapper for file_uri_target() to allow unit testing.
|
||||
*
|
||||
* Returns the part of a URI after the schema.
|
||||
*
|
||||
* @param string $uri
|
||||
* A stream, referenced as "scheme://target" or "data:target".
|
||||
*
|
||||
* @return string|bool
|
||||
* A string containing the target (path), or FALSE if none.
|
||||
* For example, the URI "public://sample/test.txt" would return
|
||||
* "sample/test.txt".
|
||||
*
|
||||
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
|
||||
* \Drupal\Core\StreamWrapper\StreamWrapperManager::getUriTarget() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3035273
|
||||
*/
|
||||
protected function fileUriTarget($uri) {
|
||||
@trigger_error('fileUriTarget() is deprecated in drupal:8.8.0. It will be removed from drupal:9.0.0. See https://www.drupal.org/node/3035273', E_USER_DEPRECATED);
|
||||
return StreamWrapperManager::getTarget($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a wrapper to allow unit testing.
|
||||
*
|
||||
|
|
|
@ -9,20 +9,6 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface;
|
|||
*/
|
||||
interface ImageStyleInterface extends ConfigEntityInterface {
|
||||
|
||||
/**
|
||||
* Returns the replacement ID.
|
||||
*
|
||||
* @return string|null
|
||||
* The replacement image style ID or NULL if no replacement has been
|
||||
* selected.
|
||||
*
|
||||
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use
|
||||
* \Drupal\image\ImageStyleStorageInterface::getReplacementId() instead.
|
||||
*
|
||||
* @see \Drupal\image\ImageStyleStorageInterface::getReplacementId()
|
||||
*/
|
||||
public function getReplacementID();
|
||||
|
||||
/**
|
||||
* Returns the image style.
|
||||
*
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\image\Tests;
|
||||
|
||||
@trigger_error('The ' . __NAMESPACE__ . '\ImageFieldTestBase class is deprecated in Drupal 8.5.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;
|
||||
|
||||
/**
|
||||
* TODO: Test the following functions.
|
||||
*
|
||||
* In file:
|
||||
* - image.effects.inc:
|
||||
* image_style_generate()
|
||||
* \Drupal\image\ImageStyleInterface::createDerivative()
|
||||
*
|
||||
* - image.module:
|
||||
* image_style_options()
|
||||
* \Drupal\image\ImageStyleInterface::flush()
|
||||
* image_filter_keyword()
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides methods specifically for testing Image's field handling.
|
||||
*
|
||||
* @deprecated in drupal:8.?.? and is removed from drupal:9.0.0.
|
||||
* Use \Drupal\Tests\image\Functional\ImageFieldTestBase instead.
|
||||
*/
|
||||
abstract class ImageFieldTestBase extends WebTestBase {
|
||||
|
||||
use ImageFieldCreationTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['node', 'image', 'field_ui', 'image_module_test'];
|
||||
|
||||
/**
|
||||
* An user with permissions to administer content types and image styles.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $adminUser;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Create Basic page and Article node types.
|
||||
if ($this->profile != 'standard') {
|
||||
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
|
||||
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
|
||||
}
|
||||
|
||||
$this->adminUser = $this->drupalCreateUser(['access content', 'access administration pages', 'administer site configuration', 'administer content types', 'administer node fields', 'administer nodes', 'create article content', 'edit any article content', 'delete any article content', 'administer image styles', 'administer node display']);
|
||||
$this->drupalLogin($this->adminUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview an image in a node.
|
||||
*
|
||||
* @param \Drupal\Core\Image\ImageInterface $image
|
||||
* A file object representing the image to upload.
|
||||
* @param string $field_name
|
||||
* Name of the image field the image should be attached to.
|
||||
* @param string $type
|
||||
* The type of node to create.
|
||||
*/
|
||||
public function previewNodeImage($image, $field_name, $type) {
|
||||
$edit = [
|
||||
'title[0][value]' => $this->randomMachineName(),
|
||||
];
|
||||
$edit['files[' . $field_name . '_0]'] = \Drupal::service('file_system')->realpath($image->uri);
|
||||
$this->drupalPostForm('node/add/' . $type, $edit, t('Preview'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload an image to a node.
|
||||
*
|
||||
* @param $image
|
||||
* A file object representing the image to upload.
|
||||
* @param $field_name
|
||||
* Name of the image field the image should be attached to.
|
||||
* @param $type
|
||||
* The type of node to create.
|
||||
* @param $alt
|
||||
* The alt text for the image. Use if the field settings require alt text.
|
||||
*/
|
||||
public function uploadNodeImage($image, $field_name, $type, $alt = '') {
|
||||
$edit = [
|
||||
'title[0][value]' => $this->randomMachineName(),
|
||||
];
|
||||
$edit['files[' . $field_name . '_0]'] = \Drupal::service('file_system')->realpath($image->uri);
|
||||
$this->drupalPostForm('node/add/' . $type, $edit, t('Save'));
|
||||
if ($alt) {
|
||||
// Add alt text.
|
||||
$this->drupalPostForm(NULL, [$field_name . '[0][alt]' => $alt], t('Save'));
|
||||
}
|
||||
|
||||
// Retrieve ID of the newly created node from the current URL.
|
||||
$matches = [];
|
||||
preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches);
|
||||
return isset($matches[1]) ? $matches[1] : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the fid of the last inserted file.
|
||||
*/
|
||||
protected function getLastFileId() {
|
||||
return (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max'];
|
||||
}
|
||||
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\image\Unit\Plugin\migrate\field\d7;
|
||||
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\image\Plugin\migrate\field\d7\ImageField;
|
||||
use Prophecy\Argument;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\image\Plugin\migrate\field\d7\ImageField
|
||||
* @group image
|
||||
* @group legacy
|
||||
*/
|
||||
class ImageFieldTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateFieldInterface
|
||||
*/
|
||||
protected $plugin;
|
||||
|
||||
/**
|
||||
* @var \Drupal\migrate\Plugin\MigrationInterface
|
||||
*/
|
||||
protected $migration;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->plugin = new ImageField([], 'image', []);
|
||||
|
||||
$migration = $this->prophesize(MigrationInterface::class);
|
||||
|
||||
// The plugin's processFieldValues() method will call
|
||||
// mergeProcessOfProperty() and return nothing. So, in order to examine the
|
||||
// process pipeline created by the plugin, we need to ensure that
|
||||
// getProcess() always returns the last input to mergeProcessOfProperty().
|
||||
$migration->mergeProcessOfProperty(Argument::type('string'), Argument::type('array'))
|
||||
->will(function ($arguments) use ($migration) {
|
||||
$migration->getProcess()->willReturn($arguments[1]);
|
||||
});
|
||||
$this->migration = $migration->reveal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::processFieldValues
|
||||
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.
|
||||
*/
|
||||
public function testProcessFieldValues() {
|
||||
$this->plugin->processFieldValues($this->migration, 'somefieldname', []);
|
||||
|
||||
$expected = [
|
||||
'plugin' => 'sub_process',
|
||||
'source' => 'somefieldname',
|
||||
'process' => [
|
||||
'target_id' => 'fid',
|
||||
'alt' => 'alt',
|
||||
'title' => 'title',
|
||||
'width' => 'width',
|
||||
'height' => 'height',
|
||||
],
|
||||
];
|
||||
$this->assertSame($expected, $this->migration->getProcess());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue