Unverified Commit fa1e2888 authored by larowlan's avatar larowlan
Browse files

Issue #3240800 by alexpott: Creating an configuration entity via new...

Issue #3240800 by alexpott: Creating an configuration entity via new ConfigEntityClass() triggers deprecations in PHP 8.1, use ConfigEntityClass::create() instead
parent 4b6a3abf
...@@ -22,7 +22,7 @@ class LocaleConfigurableLanguageManagerTest extends KernelTestBase { ...@@ -22,7 +22,7 @@ class LocaleConfigurableLanguageManagerTest extends KernelTestBase {
public function testGetLanguages() { public function testGetLanguages() {
$this->installSchema('locale', ['locales_source', 'locales_target', 'locales_location']); $this->installSchema('locale', ['locales_source', 'locales_target', 'locales_location']);
$default_language = new ConfigurableLanguage(['label' => $this->randomMachineName(), 'id' => 'default', 'weight' => 0], 'configurable_language'); $default_language = ConfigurableLanguage::create(['label' => $this->randomMachineName(), 'id' => 'default', 'weight' => 0]);
$default_language->save(); $default_language->save();
// Set new default language. // Set new default language.
...@@ -32,7 +32,7 @@ public function testGetLanguages() { ...@@ -32,7 +32,7 @@ public function testGetLanguages() {
$languages = \Drupal::service('language_manager')->getLanguages(LanguageInterface::STATE_ALL); $languages = \Drupal::service('language_manager')->getLanguages(LanguageInterface::STATE_ALL);
$this->assertEquals(['default', 'und', 'zxx'], array_keys($languages)); $this->assertEquals(['default', 'und', 'zxx'], array_keys($languages));
$configurableLanguage = new ConfigurableLanguage(['label' => $this->randomMachineName(), 'id' => 'test', 'weight' => 1], 'configurable_language'); $configurableLanguage = ConfigurableLanguage::create(['label' => $this->randomMachineName(), 'id' => 'test', 'weight' => 1]);
// Simulate a configuration sync by setting the flag otherwise the locked // Simulate a configuration sync by setting the flag otherwise the locked
// language weights would be updated whilst saving. // language weights would be updated whilst saving.
// @see \Drupal\language\Entity\ConfigurableLanguage::postSave() // @see \Drupal\language\Entity\ConfigurableLanguage::postSave()
......
...@@ -23,11 +23,11 @@ class ComplexWorkflowTypeTest extends KernelTestBase { ...@@ -23,11 +23,11 @@ class ComplexWorkflowTypeTest extends KernelTestBase {
* @covers \Drupal\workflows\Entity\Workflow::loadMultipleByType * @covers \Drupal\workflows\Entity\Workflow::loadMultipleByType
*/ */
public function testLoadMultipleByType() { public function testLoadMultipleByType() {
$workflow1 = new Workflow(['id' => 'test1', 'type' => 'workflow_type_complex_test'], 'workflow'); $workflow1 = Workflow::create(['id' => 'test1', 'type' => 'workflow_type_complex_test']);
$workflow1->save(); $workflow1->save();
$workflow2 = new Workflow(['id' => 'test2', 'type' => 'workflow_type_complex_test'], 'workflow'); $workflow2 = Workflow::create(['id' => 'test2', 'type' => 'workflow_type_complex_test']);
$workflow2->save(); $workflow2->save();
$workflow3 = new Workflow(['id' => 'test3', 'type' => 'workflow_type_test'], 'workflow'); $workflow3 = Workflow::create(['id' => 'test3', 'type' => 'workflow_type_test']);
$workflow3->save(); $workflow3->save();
$this->assertEquals(['test1', 'test2'], array_keys(Workflow::loadMultipleByType('workflow_type_complex_test'))); $this->assertEquals(['test1', 'test2'], array_keys(Workflow::loadMultipleByType('workflow_type_complex_test')));
......
...@@ -25,10 +25,10 @@ class RequiredStatesTest extends KernelTestBase { ...@@ -25,10 +25,10 @@ class RequiredStatesTest extends KernelTestBase {
* @covers ::__construct * @covers ::__construct
*/ */
public function testGetRequiredStates() { public function testGetRequiredStates() {
$workflow = new Workflow([ $workflow = Workflow::create([
'id' => 'test', 'id' => 'test',
'type' => 'workflow_type_required_state_test', 'type' => 'workflow_type_required_state_test',
], 'workflow'); ]);
$workflow->save(); $workflow->save();
$this->assertEquals(['fresh', 'rotten'], $workflow->getTypePlugin() $this->assertEquals(['fresh', 'rotten'], $workflow->getTypePlugin()
->getRequiredStates()); ->getRequiredStates());
...@@ -43,10 +43,10 @@ public function testGetRequiredStates() { ...@@ -43,10 +43,10 @@ public function testGetRequiredStates() {
* @covers \Drupal\workflows\Entity\Workflow::preSave * @covers \Drupal\workflows\Entity\Workflow::preSave
*/ */
public function testDeleteRequiredStateAPI() { public function testDeleteRequiredStateAPI() {
$workflow = new Workflow([ $workflow = Workflow::create([
'id' => 'test', 'id' => 'test',
'type' => 'workflow_type_required_state_test', 'type' => 'workflow_type_required_state_test',
], 'workflow'); ]);
$workflow->save(); $workflow->save();
// Ensure that required states can't be deleted. // Ensure that required states can't be deleted.
$this->expectException(RequiredStateMissingException::class); $this->expectException(RequiredStateMissingException::class);
...@@ -59,13 +59,13 @@ public function testDeleteRequiredStateAPI() { ...@@ -59,13 +59,13 @@ public function testDeleteRequiredStateAPI() {
* @covers \Drupal\workflows\Entity\Workflow::preSave * @covers \Drupal\workflows\Entity\Workflow::preSave
*/ */
public function testNoStatesRequiredStateAPI() { public function testNoStatesRequiredStateAPI() {
$workflow = new Workflow([ $workflow = Workflow::create([
'id' => 'test', 'id' => 'test',
'type' => 'workflow_type_required_state_test', 'type' => 'workflow_type_required_state_test',
'type_settings' => [ 'type_settings' => [
'states' => [], 'states' => [],
], ],
], 'workflow'); ]);
$this->expectException(RequiredStateMissingException::class); $this->expectException(RequiredStateMissingException::class);
$this->expectExceptionMessage("Required State Type Test' requires states with the ID 'fresh', 'rotten' in workflow 'test'"); $this->expectExceptionMessage("Required State Type Test' requires states with the ID 'fresh', 'rotten' in workflow 'test'");
$workflow->save(); $workflow->save();
...@@ -75,10 +75,10 @@ public function testNoStatesRequiredStateAPI() { ...@@ -75,10 +75,10 @@ public function testNoStatesRequiredStateAPI() {
* Ensures that initialized configuration can be changed. * Ensures that initialized configuration can be changed.
*/ */
public function testChangeRequiredStateAPI() { public function testChangeRequiredStateAPI() {
$workflow = new Workflow([ $workflow = Workflow::create([
'id' => 'test', 'id' => 'test',
'type' => 'workflow_type_required_state_test', 'type' => 'workflow_type_required_state_test',
], 'workflow'); ]);
$workflow->save(); $workflow->save();
// Ensure states added by default configuration can be changed. // Ensure states added by default configuration can be changed.
......
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