Commit e825a16a authored by catch's avatar catch

Issue #2503379 by Mac_Weber, DuaelFr, lluvigne, naveenvalecha, jmolivas:...

Issue #2503379 by Mac_Weber, DuaelFr, lluvigne, naveenvalecha, jmolivas: Replace deprecated usage of entity_create('filter_format') with a direct call to FilterFormat::create()
parent 68b4dde2
......@@ -8,6 +8,7 @@
namespace Drupal\block\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\filter\Entity\FilterFormat;
/**
* Provides setup and helper methods for block module tests.
......@@ -42,7 +43,7 @@ protected function setUp() {
$this->config('system.site')->set('page.front', '/test-page')->save();
// Create Full HTML text format.
$full_html_format = entity_create('filter_format', array(
$full_html_format = FilterFormat::create(array(
'format' => 'full_html',
'name' => 'Full HTML',
));
......
......@@ -11,6 +11,7 @@
use Drupal\editor\Entity\Editor;
use Drupal\filter\FilterFormatInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests administration of CKEditor.
......@@ -37,7 +38,7 @@ protected function setUp() {
parent::setUp();
// Create text format.
$filtered_html_format = entity_create('filter_format', array(
$filtered_html_format = FilterFormat::create(array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
......
......@@ -9,6 +9,7 @@
use Drupal\editor\Entity\Editor;
use Drupal\simpletest\WebTestBase;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests loading of CKEditor.
......@@ -42,7 +43,7 @@ protected function setUp() {
parent::setUp();
// Create text format, associate CKEditor.
$filtered_html_format = entity_create('filter_format', array(
$filtered_html_format = FilterFormat::create(array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
......@@ -57,7 +58,7 @@ protected function setUp() {
// Create a second format without an associated editor so a drop down select
// list is created when selecting formats.
$full_html_format = entity_create('filter_format', array(
$full_html_format = FilterFormat::create(array(
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
......
......@@ -9,6 +9,7 @@
use Drupal\editor\Entity\Editor;
use Drupal\simpletest\KernelTestBase;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests different ways of enabling CKEditor plugins.
......@@ -38,7 +39,7 @@ protected function setUp() {
$this->installSchema('system', 'url_alias');
// Create text format, associate CKEditor.
$filtered_html_format = entity_create('filter_format', array(
$filtered_html_format = FilterFormat::create(array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
......
......@@ -10,6 +10,7 @@
use Drupal\simpletest\KernelTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\editor\Entity\Editor;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests for the 'CKEditor' text editor plugin.
......@@ -46,7 +47,7 @@ protected function setUp() {
$this->installSchema('system', 'url_alias');
// Create text format, associate CKEditor.
$filtered_html_format = entity_create('filter_format', array(
$filtered_html_format = FilterFormat::create(array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
......
......@@ -14,6 +14,7 @@
use Drupal\simpletest\WebTestBase;
use Drupal\shortcut\Entity\ShortcutSet;
use Drupal\contact\Entity\ContactForm;
use Drupal\filter\Entity\FilterFormat;
/**
* Visit all lists.
......@@ -260,7 +261,7 @@ public function doContentTypeListTest() {
public function doFormatsListTest() {
// Create a test format to decouple looking for translate operations
// link so this does not test more than necessary.
$filter_format = entity_create('filter_format', array(
$filter_format = FilterFormat::create(array(
'format' => Unicode::strtolower($this->randomMachineName(16)),
'name' => $this->randomMachineName(),
));
......
......@@ -38,7 +38,7 @@ protected function setUp() {
parent::setUp();
// Add text format.
$filtered_html_format = entity_create('filter_format', array(
$filtered_html_format = FilterFormat::create(array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
......
......@@ -12,6 +12,7 @@
use Drupal\system\Tests\Entity\EntityUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests tracking of file usage by the Text Editor module.
......@@ -35,7 +36,7 @@ protected function setUp() {
$this->installConfig(['node']);
// Add text formats.
$filtered_html_format = entity_create('filter_format', array(
$filtered_html_format = FilterFormat::create(array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
......
......@@ -12,6 +12,7 @@
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests loading of text editors.
......@@ -56,14 +57,14 @@ protected function setUp() {
\Drupal::service('plugin.manager.editor')->clearCachedDefinitions();
// Add text formats.
$filtered_html_format = entity_create('filter_format', array(
$filtered_html_format = FilterFormat::create(array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
'filters' => array(),
));
$filtered_html_format->save();
$full_html_format = entity_create('filter_format', array(
$full_html_format = FilterFormat::create(array(
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
......
......@@ -9,6 +9,7 @@
use Drupal\editor\Entity\Editor;
use Drupal\simpletest\KernelTestBase;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests detection of text editors and correct generation of attachments.
......@@ -38,14 +39,14 @@ protected function setUp() {
$this->installSchema('system', 'url_alias');
// Add text formats.
$filtered_html_format = entity_create('filter_format', array(
$filtered_html_format = FilterFormat::create(array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
'filters' => array(),
));
$filtered_html_format->save();
$full_html_format = entity_create('filter_format', array(
$full_html_format = FilterFormat::create(array(
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
......
......@@ -10,6 +10,7 @@
use Drupal\Component\Serialization\Json;
use Drupal\editor\Entity\Editor;
use Drupal\simpletest\WebTestBase;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests XSS protection for content creators when using text editors.
......@@ -87,7 +88,7 @@ protected function setUp() {
// With text formats 2, 3 and 5, we also associate a text editor that does
// not guarantee XSS safety. "restricted" means the text format has XSS
// filters on output, "unrestricted" means the opposite.
$format = entity_create('filter_format', array(
$format = FilterFormat::create(array(
'format' => 'restricted_without_editor',
'name' => 'Restricted HTML, without text editor',
'weight' => 0,
......@@ -102,7 +103,7 @@ protected function setUp() {
),
));
$format->save();
$format = entity_create('filter_format', array(
$format = FilterFormat::create(array(
'format' => 'restricted_with_editor',
'name' => 'Restricted HTML, with text editor',
'weight' => 1,
......@@ -122,7 +123,7 @@ protected function setUp() {
'editor' => 'unicorn',
]);
$editor->save();
$format = entity_create('filter_format', array(
$format = FilterFormat::create(array(
'format' => 'restricted_plus_dangerous_tag_with_editor',
'name' => 'Restricted HTML, dangerous tag allowed, with text editor',
'weight' => 1,
......@@ -142,14 +143,14 @@ protected function setUp() {
'editor' => 'unicorn',
]);
$editor->save();
$format = entity_create('filter_format', array(
$format = FilterFormat::create(array(
'format' => 'unrestricted_without_editor',
'name' => 'Unrestricted HTML, without text editor',
'weight' => 0,
'filters' => array(),
));
$format->save();
$format = entity_create('filter_format', array(
$format = FilterFormat::create(array(
'format' => 'unrestricted_with_editor',
'name' => 'Unrestricted HTML, with text editor',
'weight' => 1,
......
......@@ -10,6 +10,7 @@
use Drupal\Component\Serialization\Json;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
use Drupal\simpletest\WebTestBase;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests Quick Edit module integration endpoints.
......@@ -36,7 +37,7 @@ protected function setUp() {
parent::setUp();
// Create a text format.
$filtered_html_format = entity_create('filter_format', array(
$filtered_html_format = FilterFormat::create(array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
......
......@@ -18,6 +18,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests Edit module integration (Editor module's inline editing support).
......@@ -87,7 +88,7 @@ protected function setUp() {
);
// Create text format.
$full_html_format = entity_create('filter_format', array(
$full_html_format = FilterFormat::create(array(
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
......@@ -103,7 +104,7 @@ protected function setUp() {
$editor->save();
// Also create a text format without an associated text editor.
entity_create('filter_format', array(
FilterFormat::create(array(
'format' => 'no_editor',
'name' => 'No Text Editor',
'weight' => 2,
......
......@@ -103,7 +103,7 @@ protected function setUp() {
))
->save();
entity_create('filter_format', array(
FilterFormat::create(array(
'format' => 'full_html',
'name' => 'Full HTML',
))->save();
......
......@@ -11,7 +11,8 @@
use Drupal\Core\Session\AnonymousUserSession;
use Drupal\Core\TypedData\OptionsProviderInterface;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\filter\Plugin\DataType\FilterFormat;
use Drupal\filter\Entity\FilterFormat;
use Drupal\filter\Plugin\DataType\FilterFormat as FilterFormatDataType;
use Drupal\filter\Plugin\FilterInterface;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
use Symfony\Component\Validator\ConstraintViolationListInterface;
......@@ -36,7 +37,7 @@ protected function setUp() {
*/
function testCheckMarkupFilterOrder() {
// Create crazy HTML format.
$crazy_format = entity_create('filter_format', array(
$crazy_format = FilterFormat::create(array(
'format' => 'crazy',
'name' => 'Crazy',
'weight' => 1,
......@@ -138,7 +139,7 @@ function testFilterFormatAPI() {
);
// Test on stupid_filtered_html, where nothing is allowed.
$stupid_filtered_html_format = entity_create('filter_format', array(
$stupid_filtered_html_format = FilterFormat::create(array(
'format' => 'stupid_filtered_html',
'name' => 'Stupid Filtered HTML',
'filters' => array(
......@@ -164,7 +165,7 @@ function testFilterFormatAPI() {
// Test on very_restricted_html, where there's two different filters of the
// FilterInterface::TYPE_HTML_RESTRICTOR type, each restricting in different ways.
$very_restricted_html_format = entity_create('filter_format', array(
$very_restricted_html_format = FilterFormat::create(array(
'format' => 'very_restricted_html',
'name' => 'Very Restricted HTML',
'filters' => array(
......@@ -254,7 +255,7 @@ function testFilterFormatAPI() {
* This test focuses solely on those advanced features.
*/
function testProcessedTextElement() {
entity_create('filter_format', array(
FilterFormat::create(array(
'format' => 'element_test',
'name' => 'processed_text element test format',
'filters' => array(
......@@ -401,7 +402,7 @@ function testTypedDataAPI() {
*/
public function testFilterFormatPreSave() {
/** @var \Drupal\filter\FilterFormatInterface $crazy_format */
$crazy_format = entity_create('filter_format', array(
$crazy_format = FilterFormat::create(array(
'format' => 'crazy',
'name' => 'Crazy',
'weight' => 1,
......@@ -451,7 +452,7 @@ public function testFilterFormatPreSave() {
public function assertFilterFormatViolation(ConstraintViolationListInterface $violations, $invalid_value) {
$filter_format_violation_found = FALSE;
foreach ($violations as $violation) {
if ($violation->getRoot() instanceof FilterFormat && $violation->getInvalidValue() === $invalid_value) {
if ($violation->getRoot() instanceof FilterFormatDataType && $violation->getInvalidValue() === $invalid_value) {
$filter_format_violation_found = TRUE;
break;
}
......
......@@ -50,7 +50,7 @@ protected function setUp() {
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
// Set up the filter formats used by this test.
$basic_html_format = entity_create('filter_format', array(
$basic_html_format = FilterFormat::create(array(
'format' => 'basic_html',
'name' => 'Basic HTML',
'filters' => array(
......@@ -63,7 +63,7 @@ protected function setUp() {
),
));
$basic_html_format->save();
$restricted_html_format = entity_create('filter_format', array(
$restricted_html_format = FilterFormat::create(array(
'format' => 'restricted_html',
'name' => 'Restricted HTML',
'filters' => array(
......@@ -89,7 +89,7 @@ protected function setUp() {
),
));
$restricted_html_format->save();
$full_html_format = entity_create('filter_format', array(
$full_html_format = FilterFormat::create(array(
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
......
......@@ -29,14 +29,15 @@ class FilterCrudTest extends KernelTestBase {
*/
function testTextFormatCrud() {
// Add a text format with minimum data only.
$format = entity_create('filter_format');
$format->set('format', 'empty_format');
$format->set('name', 'Empty format');
$format = FilterFormat::create(array(
'format' => 'empty_format',
'name' => 'Empty format',
));
$format->save();
$this->verifyTextFormat($format);
// Add another text format specifying all possible properties.
$format = entity_create('filter_format', array(
$format = FilterFormat::create(array(
'format' => 'custom_format',
'name' => 'Custom format',
));
......
......@@ -10,6 +10,7 @@
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Core\StreamWrapper\PublicStream;
use Drupal\simpletest\WebTestBase;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests restriction of IMG tags in HTML input.
......@@ -38,7 +39,7 @@ protected function setUp() {
parent::setUp();
// Setup Filtered HTML text format.
$filtered_html_format = entity_create('filter_format', array(
$filtered_html_format = FilterFormat::create(array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'filters' => array(
......
......@@ -8,6 +8,7 @@
namespace Drupal\filter\Tests;
use Drupal\simpletest\KernelTestBase;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests filter settings.
......@@ -30,7 +31,7 @@ function testFilterDefaults() {
$filter_info = $this->container->get('plugin.manager.filter')->getDefinitions();
// Create text format using filter default settings.
$filter_defaults_format = entity_create('filter_format', array(
$filter_defaults_format = FilterFormat::create(array(
'format' => 'filter_defaults',
'name' => 'Filter defaults',
));
......
......@@ -10,6 +10,7 @@
use Drupal\quickedit\EditorSelector;
use Drupal\quickedit\MetadataGenerator;
use Drupal\quickedit_test\MockEditEntityFieldAccessCheck;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests in-place field editing metadata.
......@@ -149,7 +150,7 @@ public function testEditorWithCustomMetadata() {
);
// Create a text format.
$full_html_format = entity_create('filter_format', array(
$full_html_format = FilterFormat::create(array(
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
......
......@@ -17,6 +17,7 @@
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\WebTestBase;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests loading of in-place editing functionality and lazy loading of its
......@@ -57,7 +58,7 @@ protected function setUp() {
parent::setUp();
// Create a text format.
$filtered_html_format = entity_create('filter_format', array(
$filtered_html_format = FilterFormat::create(array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
......
......@@ -11,6 +11,7 @@
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\field\Entity\FieldConfig;
use Drupal\user\RoleInterface;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests integration searching comments.
......@@ -59,7 +60,7 @@ class SearchCommentTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$full_html_format = entity_create('filter_format', array(
$full_html_format = FilterFormat::create(array(
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
......@@ -90,7 +91,7 @@ protected function setUp() {
function testSearchResultsComment() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
// Create basic_html format that escapes all HTML.
$basic_html_format = entity_create('filter_format', array(
$basic_html_format = FilterFormat::create(array(
'format' => 'basic_html',
'name' => 'Basic HTML',
'weight' => 1,
......
......@@ -10,6 +10,7 @@
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Core\Url;
use Drupal\filter\Entity\FilterFormat;
/**
* Indexes content and tests ranking factors.
......@@ -203,7 +204,7 @@ public function testRankings() {
* Test rankings of HTML tags.
*/
public function testHTMLRankings() {
$full_html_format = entity_create('filter_format', array(
$full_html_format = FilterFormat::create(array(
'format' => 'full_html',
'name' => 'Full HTML',
));
......
......@@ -16,6 +16,7 @@
use Drupal\form_test\Form\FormTestDisabledElementsForm;
use Drupal\simpletest\WebTestBase;
use Drupal\user\RoleInterface;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests various form element validation mechanisms.
......@@ -34,7 +35,7 @@ class FormTest extends WebTestBase {
protected function setUp() {
parent::setUp();
$filtered_html_format = entity_create('filter_format', array(
$filtered_html_format = FilterFormat::create(array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
));
......
......@@ -46,7 +46,7 @@ class TextFormatterTest extends EntityUnitTestBase {
protected function setUp() {
parent::setUp();
entity_create('filter_format', array(
FilterFormat::create(array(
'format' => 'my_text_format',
'name' => 'My text format',
'filters' => array(
......
......@@ -8,6 +8,7 @@
namespace Drupal\text\Tests;
use Drupal\simpletest\KernelTestBase;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests text_summary() with different strings and lengths.
......@@ -55,7 +56,7 @@ function testLongSentence() {
* Test various summary length edge cases.
*/
function testLength() {
entity_create('filter_format', array(
FilterFormat::create(array(
'format' => 'autop',
'filters' => array(
'filter_autop' => array(
......@@ -63,7 +64,7 @@ function testLength() {
),
),
))->save();
entity_create('filter_format', array(
FilterFormat::create(array(
'format' => 'autop_correct',
'filters' => array(
'filter_autop' => array(
......
......@@ -12,6 +12,7 @@
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\filter\Entity\FilterFormat;
/**
* Tests using entity fields of the text summary field type.
......@@ -49,7 +50,7 @@ protected function setUp() {
// Create the necessary formats.
$this->installConfig(array('filter'));
entity_create('filter_format', array(
FilterFormat::create(array(
'format' => 'no_filters',
'filters' => array(),
))->save();
......
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