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 {
public function testGetLanguages() {
$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();
// Set new default language.
......@@ -32,7 +32,7 @@ public function testGetLanguages() {
$languages = \Drupal::service('language_manager')->getLanguages(LanguageInterface::STATE_ALL);
$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
// language weights would be updated whilst saving.
// @see \Drupal\language\Entity\ConfigurableLanguage::postSave()
......
......@@ -23,11 +23,11 @@ class ComplexWorkflowTypeTest extends KernelTestBase {
* @covers \Drupal\workflows\Entity\Workflow::loadMultipleByType
*/
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();
$workflow2 = new Workflow(['id' => 'test2', 'type' => 'workflow_type_complex_test'], 'workflow');
$workflow2 = Workflow::create(['id' => 'test2', 'type' => 'workflow_type_complex_test']);
$workflow2->save();
$workflow3 = new Workflow(['id' => 'test3', 'type' => 'workflow_type_test'], 'workflow');
$workflow3 = Workflow::create(['id' => 'test3', 'type' => 'workflow_type_test']);
$workflow3->save();
$this->assertEquals(['test1', 'test2'], array_keys(Workflow::loadMultipleByType('workflow_type_complex_test')));
......
......@@ -25,10 +25,10 @@ class RequiredStatesTest extends KernelTestBase {
* @covers ::__construct
*/
public function testGetRequiredStates() {
$workflow = new Workflow([
$workflow = Workflow::create([
'id' => 'test',
'type' => 'workflow_type_required_state_test',
], 'workflow');
]);
$workflow->save();
$this->assertEquals(['fresh', 'rotten'], $workflow->getTypePlugin()
->getRequiredStates());
......@@ -43,10 +43,10 @@ public function testGetRequiredStates() {
* @covers \Drupal\workflows\Entity\Workflow::preSave
*/
public function testDeleteRequiredStateAPI() {
$workflow = new Workflow([
$workflow = Workflow::create([
'id' => 'test',
'type' => 'workflow_type_required_state_test',
], 'workflow');
]);
$workflow->save();
// Ensure that required states can't be deleted.
$this->expectException(RequiredStateMissingException::class);
......@@ -59,13 +59,13 @@ public function testDeleteRequiredStateAPI() {
* @covers \Drupal\workflows\Entity\Workflow::preSave
*/
public function testNoStatesRequiredStateAPI() {
$workflow = new Workflow([
$workflow = Workflow::create([
'id' => 'test',
'type' => 'workflow_type_required_state_test',
'type_settings' => [
'states' => [],
],
], 'workflow');
]);
$this->expectException(RequiredStateMissingException::class);
$this->expectExceptionMessage("Required State Type Test' requires states with the ID 'fresh', 'rotten' in workflow 'test'");
$workflow->save();
......@@ -75,10 +75,10 @@ public function testNoStatesRequiredStateAPI() {
* Ensures that initialized configuration can be changed.
*/
public function testChangeRequiredStateAPI() {
$workflow = new Workflow([
$workflow = Workflow::create([
'id' => 'test',
'type' => 'workflow_type_required_state_test',
], 'workflow');
]);
$workflow->save();
// 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