Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/config/tests/src/Functional/ConfigEntityTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
58 | 58 |
59 // Verify Entity properties/methods on the newly created empty entity. | 59 // Verify Entity properties/methods on the newly created empty entity. |
60 $this->assertIdentical($empty->getEntityTypeId(), 'config_test'); | 60 $this->assertIdentical($empty->getEntityTypeId(), 'config_test'); |
61 // The URI can only be checked after saving. | 61 // The URI can only be checked after saving. |
62 try { | 62 try { |
63 $empty->urlInfo(); | 63 $empty->toUrl(); |
64 $this->fail('EntityMalformedException was thrown.'); | 64 $this->fail('EntityMalformedException was thrown.'); |
65 } | 65 } |
66 catch (EntityMalformedException $e) { | 66 catch (EntityMalformedException $e) { |
67 $this->pass('EntityMalformedException was thrown.'); | 67 $this->pass('EntityMalformedException was thrown.'); |
68 } | 68 } |
117 catch (EntityMalformedException $e) { | 117 catch (EntityMalformedException $e) { |
118 $this->fail('EntityMalformedException was not thrown.'); | 118 $this->fail('EntityMalformedException was not thrown.'); |
119 } | 119 } |
120 | 120 |
121 // The entity path can only be checked after saving. | 121 // The entity path can only be checked after saving. |
122 $this->assertIdentical($config_test->url(), Url::fromRoute('entity.config_test.edit_form', ['config_test' => $expected['id']])->toString()); | 122 $this->assertIdentical($config_test->toUrl()->toString(), Url::fromRoute('entity.config_test.edit_form', ['config_test' => $expected['id']])->toString()); |
123 | 123 |
124 // Verify that the correct status is returned and properties did not change. | 124 // Verify that the correct status is returned and properties did not change. |
125 $this->assertIdentical($status, SAVED_NEW); | 125 $this->assertIdentical($status, SAVED_NEW); |
126 $this->assertIdentical($config_test->id(), $expected['id']); | 126 $this->assertIdentical($config_test->id(), $expected['id']); |
127 $this->assertIdentical($config_test->uuid(), $expected['uuid']); | 127 $this->assertIdentical($config_test->uuid(), $expected['uuid']); |
314 $message_insert = format_string('%label configuration has been created.', ['%label' => $edit['label']]); | 314 $message_insert = format_string('%label configuration has been created.', ['%label' => $edit['label']]); |
315 $this->assertRaw($message_insert); | 315 $this->assertRaw($message_insert); |
316 $this->assertLinkByHref('admin/structure/config_test/manage/0'); | 316 $this->assertLinkByHref('admin/structure/config_test/manage/0'); |
317 $this->assertLinkByHref('admin/structure/config_test/manage/0/delete'); | 317 $this->assertLinkByHref('admin/structure/config_test/manage/0/delete'); |
318 $this->drupalPostForm('admin/structure/config_test/manage/0/delete', [], 'Delete'); | 318 $this->drupalPostForm('admin/structure/config_test/manage/0/delete', [], 'Delete'); |
319 $this->assertFalse(entity_load('config_test', '0'), 'Test entity deleted'); | 319 $storage = \Drupal::entityTypeManager()->getStorage('config_test'); |
320 $this->assertNull($storage->load(0), 'Test entity deleted'); | |
320 | 321 |
321 // Create a configuration entity with a property that uses AJAX to show | 322 // Create a configuration entity with a property that uses AJAX to show |
322 // extra form elements. Test this scenario in a non-JS case by using a | 323 // extra form elements. Test this scenario in a non-JS case by using a |
323 // 'js-hidden' submit button. | 324 // 'js-hidden' submit button. |
324 // @see \Drupal\Tests\config\FunctionalJavascript\ConfigEntityTest::testAjaxOnAddPage() | 325 // @see \Drupal\Tests\config\FunctionalJavascript\ConfigEntityTest::testAjaxOnAddPage() |
341 // Submit the form with the regular 'Save' button and check that the entity | 342 // Submit the form with the regular 'Save' button and check that the entity |
342 // values are correct. | 343 // values are correct. |
343 $edit += ['size_value' => 'medium']; | 344 $edit += ['size_value' => 'medium']; |
344 $this->drupalPostForm(NULL, $edit, 'Save'); | 345 $this->drupalPostForm(NULL, $edit, 'Save'); |
345 | 346 |
346 $entity = entity_load('config_test', $id); | 347 $entity = $storage->load($id); |
347 $this->assertEqual($entity->get('size'), 'custom'); | 348 $this->assertEqual($entity->get('size'), 'custom'); |
348 $this->assertEqual($entity->get('size_value'), 'medium'); | 349 $this->assertEqual($entity->get('size_value'), 'medium'); |
349 } | 350 } |
350 | 351 |
351 } | 352 } |