diff --git a/modules/video_embed_media/src/Tests/BundleTest.php b/modules/video_embed_media/tests/src/Functional/BundleTest.php similarity index 78% rename from modules/video_embed_media/src/Tests/BundleTest.php rename to modules/video_embed_media/tests/src/Functional/BundleTest.php index 2c986ce..b3acc39 100644 --- a/modules/video_embed_media/src/Tests/BundleTest.php +++ b/modules/video_embed_media/tests/src/Functional/BundleTest.php @@ -1,8 +1,8 @@ drupalGet('admin/structure/media/add'); - $this->drupalPostForm(NULL, [ + $this->submitForm([ 'label' => 'Video Bundle', 'id' => 'video_bundle', 'type' => 'video_embed_field', - ], 'Save media bundle'); + ], t('Save media bundle')); $this->assertText('The media bundle Video Bundle has been added.'); // Ensure the video field is added to the media entity. @@ -47,7 +47,7 @@ class BundleTest extends WebTestBase { // Add a media entity with the new field. $this->drupalGet('media/add/video_bundle'); - $this->drupalPostForm(NULL, [ + $this->submitForm([ 'name[0][value]' => 'Drupal video!', 'field_media_video_embed_field[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', ], 'Save'); @@ -55,26 +55,28 @@ class BundleTest extends WebTestBase { $this->assertRaw('video_thumbnails/XgYu7-DQjDQ.jpg'); // Add another field and change the configured media field. - $this->drupalPostForm('admin/structure/media/manage/video_bundle/fields/add-field', array( + $this->drupalGet('admin/structure/media/manage/video_bundle/fields/add-field'); + $this->submitForm([ 'new_storage_type' => 'video_embed_field', 'label' => 'New Video Field', 'field_name' => 'new_video_field', - ), 'Save and continue'); - $this->drupalPostForm(NULL, [], 'Save field settings'); - $this->drupalPostForm(NULL, [], 'Save settings'); + ], 'Save and continue'); + $this->submitForm([], t('Save field settings')); + $this->submitForm([], t('Save settings')); // Update video source field. - $this->drupalPostForm('admin/structure/media/manage/video_bundle', [ + $this->drupalGet('admin/structure/media/manage/video_bundle'); + $this->submitForm([ 'type_configuration[video_embed_field][source_field]' => 'field_new_video_field', - ], 'Save media bundle'); + ], t('Save media bundle')); // Create a video, populating both video URL fields. $this->drupalGet('media/add/video_bundle'); - $this->drupalPostForm(NULL, [ + $this->submitForm([ 'name[0][value]' => 'Another Video!', 'field_media_video_embed_field[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', 'field_new_video_field[0][value]' => 'https://www.youtube.com/watch?v=gnERPdAiuSo', - ], 'Save'); + ], t('Save')); // We should see the newly configured video thumbnail, but not the original. $this->assertRaw('video_thumbnails/gnERPdAiuSo.jpg'); diff --git a/modules/video_embed_media/src/Tests/UpgradePathTest.php b/modules/video_embed_media/tests/src/Functional/UpgradePathTest.php similarity index 59% rename from modules/video_embed_media/src/Tests/UpgradePathTest.php rename to modules/video_embed_media/tests/src/Functional/UpgradePathTest.php index ac68bca..4b64f3c 100644 --- a/modules/video_embed_media/src/Tests/UpgradePathTest.php +++ b/modules/video_embed_media/tests/src/Functional/UpgradePathTest.php @@ -1,8 +1,8 @@ drupalGet('admin/structure/media/add'); - $this->drupalPostForm(NULL, [ + $this->submitForm([ 'label' => 'embeddable Video Bundle', 'id' => 'embeddable_bundle', 'type' => 'embeddable_video', ], 'Save media bundle'); $this->assertText('The media bundle embeddable Video Bundle has been added.'); - $this->drupalPostForm('admin/structure/media/manage/embeddable_bundle/fields/add-field', array( + $this->drupalGet('admin/structure/media/manage/embeddable_bundle/fields/add-field'); + $this->submitForm([ 'new_storage_type' => 'string', 'label' => 'Video Text Field', 'field_name' => 'video_text_field', - ), 'Save and continue'); - $this->drupalPostForm(NULL, [], 'Save field settings'); - $this->drupalPostForm(NULL, [], 'Save settings'); - $this->drupalPostForm('admin/structure/media/manage/embeddable_bundle', ['type_configuration[embeddable_video][source_field]' => 'field_video_text_field'], 'Save media bundle'); - $this->drupalPostForm('media/add/embeddable_bundle', [ + ], t('Save and continue')); + $this->submitForm([], t('Save field settings')); + $this->submitForm([], t('Save settings')); + $this->drupalGet('admin/structure/media/manage/embeddable_bundle'); + $this->submitForm(['type_configuration[embeddable_video][source_field]' => 'field_video_text_field'], t('Save media bundle')); + $this->drupalGet('media/add/embeddable_bundle'); + $this->submitForm([ 'field_video_text_field[0][value]' => 'https://www.youtube.com/watch?v=gnERPdAiuSo', 'name[0][value]' => 'Test Media Entity', - ], 'Save'); + ], t('Save')); // Install video_embed_field. - $this->drupalPostForm('admin/modules', [ + $this->drupalGet('admin/modules'); + $this->submitForm([ 'modules[Video Embed Field][video_embed_media][enable]' => '1', - ], 'Install'); + ], t('Install')); $this->assertUpgradeComplete(); // Uninstall the module and ensure everything is still okay. - $this->drupalPostForm('admin/modules/uninstall', [ + $this->drupalGet('admin/modules/uninstall'); + $this->submitForm([ 'uninstall[media_entity_embeddable_video]' => TRUE, - ], 'Uninstall'); - $this->drupalPostForm(NULL, [], 'Uninstall'); + ], t('Uninstall')); + $this->submitForm([], 'Uninstall'); $this->assertUpgradeComplete(); } @@ -82,10 +87,10 @@ class UpgradePathTest extends WebTestBase { protected function assertUpgradeComplete() { // Ensure the new type is selected. $this->drupalGet('admin/structure/media/manage/embeddable_bundle'); - $this->assertTrue(!empty($this->xpath('//option[@value="video_embed_field" and @selected="selected"]')), 'The media type was updated.'); + $this->assertTrue(!empty($this->getSession()->getPage()->find('xpath', '//option[@value="video_embed_field" and @selected="selected"]')), 'The media type was updated.'); // Ensure the media entity has updated values. $this->drupalGet('media/1/edit'); - $this->assertFieldByName('field_video_text_field[0][value]', 'https://www.youtube.com/watch?v=gnERPdAiuSo', 'Field values were copied.'); + $this->assertEquals($this->getSession()->getPage()->find('css', 'input[name="field_video_text_field[0][value]"]')->getValue(), 'https://www.youtube.com/watch?v=gnERPdAiuSo', 'Field values were copied.'); } } diff --git a/modules/video_embed_media/src/Tests/ProvidedFieldsTest.php b/modules/video_embed_media/tests/src/Kernel/ProvidedFieldsTest.php similarity index 96% rename from modules/video_embed_media/src/Tests/ProvidedFieldsTest.php rename to modules/video_embed_media/tests/src/Kernel/ProvidedFieldsTest.php index 0887ece..a392776 100644 --- a/modules/video_embed_media/src/Tests/ProvidedFieldsTest.php +++ b/modules/video_embed_media/tests/src/Kernel/ProvidedFieldsTest.php @@ -1,10 +1,10 @@ drupalLogin($this->adminUser); - - // Assert access is denied without enabling the filter. - $this->drupalGet('video-embed-wysiwyg/dialog/plain_text'); - $this->assertResponse(403); - - // Enable the filter. - $this->drupalPostForm('admin/config/content/formats/manage/plain_text', [ - 'editor[editor]' => 'ckeditor', - ], t('Save configuration')); - $this->drupalPostAjaxForm(NULL, [], 'editor_configure'); - $this->drupalPostForm(NULL, [ - 'filters[video_embed_wysiwyg][status]' => TRUE, - 'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed"]}]]', - ], t('Save configuration')); - - // Visit the modal again. - $this->drupalGet('video-embed-wysiwyg/dialog/plain_text'); - - // Assert all the form fields appear on the modal. - $this->assertText('Autoplay'); - $this->assertText('Responsive Video'); - $this->assertText('Width'); - $this->assertText('Height'); - $this->assertText('Video URL'); - - // Attempt to submit the modal with no values. - $this->drupalPostAjaxForm(NULL, [], 'op'); - $this->assertText('Video URL field is required.'); - - // Submit the form with an invalid video URL. - $this->drupalPostAjaxForm(NULL, [ - 'video_url' => 'http://example.com/', - ], 'op'); - $this->assertText('Could not find a video provider to handle the given URL.'); - $this->assertRaw('http://example.com/'); - - // Assert the settings are sent to the client. - $this->assertAjax('editorDialogSave', function ($command) { - $this->assertEqual($command['values']['video_url'], 'https://www.youtube.com/watch?v=iaf3Sl2r3jE&t=1553s'); - $this->assertEqual($command['values']['settings'], [ - 'responsive' => 1, - 'width' => '854', - 'height' => '480', - 'autoplay' => 1, - ]); - $this->assertEqual($command['values']['settings_summary'], ['Embedded Video (Responsive, autoplaying).']); - }); - - // Assert the modal close command is sent. - $this->assertAjax('closeDialog', function ($command) { - $this->assertEqual($command['selector'], '#drupal-modal'); - }); - - // Submit a valid URL. - $this->drupalPostAjaxForm(NULL, [ - 'video_url' => 'https://www.youtube.com/watch?v=iaf3Sl2r3jE&t=1553s', - ], 'op'); - } - - /** - * Add an item to the AJAX assertions. - * - * @param string $command - * The command to respond to. - * @param callable $callback - * The callback to run assertions with. - */ - protected function assertAjax($command, callable $callback) { - $this->ajaxAsserts[] = [ - 'command' => $command, - 'callback' => $callback, - ]; - } - - /** - * {@inheritdoc} - */ - protected function drupalProcessAjaxResponse($content, array $ajax_response, array $ajax_settings, array $drupal_settings) { - // Process the AJAX assertions as a stack. - while ($assertion = array_pop($this->ajaxAsserts)) { - $called = FALSE; - foreach ($ajax_response as $command) { - if ($command['command'] == $assertion['command']) { - $assertion['callback']($command); - $called = TRUE; - } - } - if (!$called) { - throw new \Exception('AJAX command was not found.'); - } - } - parent::drupalProcessAjaxResponse($content, $ajax_response, $ajax_settings, $drupal_settings); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() { - if (count($this->ajaxAsserts) > 0) { - throw new \Exception('AJAX commands were not handled.'); - } - parent::tearDown(); - } - -} diff --git a/modules/video_embed_wysiwyg/src/Tests/TextFormatConfigurationTest.php b/modules/video_embed_wysiwyg/tests/src/Functional/TextFormatConfigurationTest.php similarity index 80% rename from modules/video_embed_wysiwyg/src/Tests/TextFormatConfigurationTest.php rename to modules/video_embed_wysiwyg/tests/src/Functional/TextFormatConfigurationTest.php index e14165f..195172e 100644 --- a/modules/video_embed_wysiwyg/src/Tests/TextFormatConfigurationTest.php +++ b/modules/video_embed_wysiwyg/tests/src/Functional/TextFormatConfigurationTest.php @@ -1,8 +1,8 @@ drupalGet('admin/config/content/formats/manage/plain_text'); // Setup the filter to have an editor. - $this->drupalPostForm(NULL, [ - 'editor[editor]' => 'ckeditor', - ], t('Save configuration')); - $this->drupalPostAjaxForm(NULL, [], 'editor_configure'); - $this->drupalPostForm(NULL, [], t('Save configuration')); + $this->setFieldValue('editor[editor]', 'ckeditor'); + $this->getSession()->getPage()->find('css', 'input[name="editor_configure"]')->click(); + $this->submitForm([], t('Save configuration')); } /** @@ -48,22 +46,25 @@ class TextFormatConfigurationTest extends WebTestBase { */ public function testFormatConfiguration() { // Save the settings with the filter enabled, but with no button. - $this->drupalPostForm('admin/config/content/formats/manage/plain_text', [ + $this->drupalGet('admin/config/content/formats/manage/plain_text'); + $this->submitForm([ 'filters[video_embed_wysiwyg][status]' => TRUE, 'editor[settings][toolbar][button_groups]' => '[]', - ], 'Save configuration'); + ], t('Save configuration')); $this->assertText('To embed videos, make sure you have enabled the "Video Embed WYSIWYG" filter and dragged the video icon into the WYSIWYG toolbar.'); - $this->drupalPostForm('admin/config/content/formats/manage/plain_text', [ + $this->drupalGet('admin/config/content/formats/manage/plain_text'); + $this->submitForm([ 'filters[video_embed_wysiwyg][status]' => FALSE, 'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed"]}]]', - ], 'Save configuration'); + ], t('Save configuration')); $this->assertText('To embed videos, make sure you have enabled the "Video Embed WYSIWYG" filter and dragged the video icon into the WYSIWYG toolbar.'); - $this->drupalPostForm('admin/config/content/formats/manage/plain_text', [ + $this->drupalGet('admin/config/content/formats/manage/plain_text'); + $this->submitForm([ 'filters[video_embed_wysiwyg][status]' => TRUE, 'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed"]}]]', - ], 'Save configuration'); + ], t('Save configuration')); $this->assertText('The text format Plain text has been updated.'); } @@ -80,14 +81,14 @@ class TextFormatConfigurationTest extends WebTestBase { $this->assertText('Width'); $this->assertText('Height'); - $this->drupalPostForm(NULL, [ + $this->submitForm([ 'filters[video_embed_wysiwyg][status]' => TRUE, 'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed"]}]]', 'editor[settings][plugins][video_embed][defaults][children][width]' => '123', 'editor[settings][plugins][video_embed][defaults][children][height]' => '456', 'editor[settings][plugins][video_embed][defaults][children][responsive]' => FALSE, 'editor[settings][plugins][video_embed][defaults][children][autoplay]' => FALSE, - ], 'Save configuration'); + ], t('Save configuration')); // Ensure the configured defaults show up on the modal window. $this->drupalGet('video-embed-wysiwyg/dialog/plain_text'); diff --git a/modules/video_embed_wysiwyg/tests/src/FunctionalJavascript/EmbedDialogTest.php b/modules/video_embed_wysiwyg/tests/src/FunctionalJavascript/EmbedDialogTest.php new file mode 100644 index 0000000..2eddc33 --- /dev/null +++ b/modules/video_embed_wysiwyg/tests/src/FunctionalJavascript/EmbedDialogTest.php @@ -0,0 +1,120 @@ +adminUser = $this->drupalCreateUser(array_keys($this->container->get('user.permissions')->getPermissions())); + $this->drupalLogin($this->adminUser); + $this->createContentType(['type' => 'page']); + \Drupal::configFactory()->getEditable('image.settings')->set('suppress_itok_output', TRUE)->save(); + } + + /** + * Test the WYSIWYG embed modal. + */ + public function testEmbedDialog() { + // Assert access is denied without enabling the filter. + $this->drupalGet('video-embed-wysiwyg/dialog/plain_text'); + $this->assertEquals(403, $this->getSession()->getStatusCode()); + + // Enable the filter. + $this->drupalGet('admin/config/content/formats/manage/plain_text'); + $this->getSession() + ->getPage() + ->find('css', '[name="editor[editor]"]') + ->setValue('ckeditor'); + $this->getSession()->wait(static::AJAX_WAIT_TIMEOUT); + $this->submitForm([ + 'filters[video_embed_wysiwyg][status]' => TRUE, + 'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed","Source"]}]]', + ], t('Save configuration')); + + // Visit the modal again. + $this->drupalGet('video-embed-wysiwyg/dialog/plain_text'); + $this->assertEquals(200, $this->getSession()->getStatusCode()); + + // Use the modal to embed into a page. + $this->drupalGet('node/add/page'); + $this->getSession()->getPage()->find('css', '.cke_button__video_embed')->click(); + $this->getSession()->wait(static::AJAX_WAIT_TIMEOUT); + + // Assert all the form fields appear on the modal. + $this->assertText('Autoplay'); + $this->assertText('Responsive Video'); + $this->assertText('Width'); + $this->assertText('Height'); + $this->assertText('Video URL'); + + // Attempt to submit the modal with no values. + $this->getSession()->getPage()->find('css', 'input[name="video_url"]')->setValue(''); + $this->getSession()->getPage()->find('css', 'button.form-submit')->click(); + $this->getSession()->wait(static::AJAX_WAIT_TIMEOUT); + $this->assertText('Video URL field is required.'); + + // Submit the form with an invalid video URL. + $this->getSession()->getPage()->find('css', 'input[name="video_url"]')->setValue('http://example.com/'); + $this->getSession()->getPage()->find('css', 'button.form-submit')->click(); + $this->getSession()->wait(static::AJAX_WAIT_TIMEOUT); + $this->assertText('Could not find a video provider to handle the given URL.'); + $this->assertRaw('http://example.com/'); + + // Submit a valid URL. + $this->getSession()->getPage()->find('css', 'input[name="video_url"]')->setValue('https://www.youtube.com/watch?v=iaf3Sl2r3jE&t=1553s'); + $this->getSession()->getPage()->find('css', 'button.form-submit')->click(); + $this->getSession()->wait(static::AJAX_WAIT_TIMEOUT); + + // Make sure the video paragraph appears in the page content and the + // upcast/downcast works. + $this->getSession()->getPage()->find('css', '.cke_button__source_icon')->click(); + $this->getSession()->wait(500); + $this->assertEquals('

{"preview_thumbnail":"' . $this->baseUrl . $this->publicFilesDirectory . '/styles/video_embed_wysiwyg_preview/public/video_thumbnails/iaf3Sl2r3jE.jpg","video_url":"https://www.youtube.com/watch?v=iaf3Sl2r3jE&t=1553s","settings":{"responsive":1,"width":"854","height":"480","autoplay":1},"settings_summary":["Embedded Video (Responsive, autoplaying)."]}

', trim($this->getSession()->getPage()->find('css', '.cke_source')->getValue())); + } + +} diff --git a/modules/video_embed_wysiwyg/src/Tests/FilterTest.php b/modules/video_embed_wysiwyg/tests/src/Kernel/FilterTest.php similarity index 97% rename from modules/video_embed_wysiwyg/src/Tests/FilterTest.php rename to modules/video_embed_wysiwyg/tests/src/Kernel/FilterTest.php index f05865b..585b89d 100644 --- a/modules/video_embed_wysiwyg/src/Tests/FilterTest.php +++ b/modules/video_embed_wysiwyg/tests/src/Kernel/FilterTest.php @@ -1,10 +1,10 @@ assertTrue(strpos($this->getSession()->getPage()->getHtml(), (string) $content) !== FALSE); + } + + /** + * Make an assertion on the page HTML. + * + * @param string $content + * The content to assert is not on the current page. + */ + protected function assertNoRaw($content) { + $this->assertTrue(strpos($this->getSession()->getPage()->getHtml(), (string) $content) === FALSE); + } + + /** + * Make an assertion on the page text. + * + * @param string $text + * The text to assert on the current page. + */ + protected function assertText($text) { + $this->assertTrue(strpos(strip_tags($this->getSession()->getPage()->getContent()), (string) $text) !== FALSE); + } + + /** + * Assert a field value by xpath query. + * + * @param string $xpath + * The xpath query. + * @param string $value + * The field value. + */ + protected function assertFieldByXPath($xpath, $value) { + $this->assertEquals($value, $this->getSession()->getPage()->find('xpath', $xpath)->getValue()); + } +} diff --git a/src/Tests/Web/AutoplayPermissionTest.php b/tests/src/Functional/AutoplayPermissionTest.php similarity index 81% rename from src/Tests/Web/AutoplayPermissionTest.php rename to tests/src/Functional/AutoplayPermissionTest.php index 9904571..a2452b2 100644 --- a/src/Tests/Web/AutoplayPermissionTest.php +++ b/tests/src/Functional/AutoplayPermissionTest.php @@ -1,8 +1,6 @@ drupalCreateNode([ + $node = $this->createNode([ 'type' => $this->contentTypeName, $this->fieldName => [ ['value' => 'https://vimeo.com/80896303'], @@ -27,7 +25,7 @@ class AutoplayPermissionTest extends WebTestBase { 'autoplay' => TRUE, ], ])->save(); - $bypass_autoplay_user = $this->createUser(['never autoplay videos']); + $bypass_autoplay_user = $this->drupalCreateUser(['never autoplay videos']); // Assert a user with the permission doesn't get autoplay. $this->drupalLogin($bypass_autoplay_user); $this->drupalGet('node/' . $node->id()); diff --git a/src/Tests/Web/FormatterConfigurationTest.php b/tests/src/Functional/FormatterConfigurationTest.php similarity index 81% rename from src/Tests/Web/FormatterConfigurationTest.php rename to tests/src/Functional/FormatterConfigurationTest.php index ac4a019..13048da 100644 --- a/src/Tests/Web/FormatterConfigurationTest.php +++ b/tests/src/Functional/FormatterConfigurationTest.php @@ -1,9 +1,8 @@ drupalPostAjaxForm($this->manageDisplay, [ + $this->drupalGet($this->manageDisplay); + $this->getSession()->getPage()->find('css', 'input[name="refresh_rows"]')->setValue($this->fieldName); + $this->submitForm([ 'fields[' . $this->fieldName . '][type]' => $formatter, - 'refresh_rows' => $this->fieldName, - ], ['op' => t('Refresh')]); - $this->drupalPostForm(NULL, [], t('Save')); + ], t('Refresh')); + $this->submitForm([], t('Save')); } /** @@ -84,9 +84,9 @@ class FormatterConfigurationTest extends WebTestBase { $edit["fields[{$this->fieldName}][settings_edit_form][settings][$key]"] = $value; } $this->drupalGet($this->manageDisplay); - $this->drupalPostAjaxForm(NULL, [], $this->fieldName . '_settings_edit'); - $this->drupalPostAjaxForm(NULL, $edit, $this->fieldName . '_plugin_settings_update'); - $this->drupalPostForm(NULL, [], t('Save')); + $this->getSession()->getPage()->find('css', 'input[name="' . $this->fieldName . '_settings_edit"]')->click(); + $this->submitForm($edit, $this->fieldName . '_plugin_settings_update'); + $this->submitForm([], t('Save')); } } diff --git a/src/Tests/WebTestBase.php b/tests/src/Functional/WebTestBase.php similarity index 73% rename from src/Tests/WebTestBase.php rename to tests/src/Functional/WebTestBase.php index 75056a1..6fe810c 100644 --- a/src/Tests/WebTestBase.php +++ b/tests/src/Functional/WebTestBase.php @@ -1,15 +1,21 @@ fieldName = strtolower($this->randomMachineName()); $this->contentTypeName = strtolower($this->randomMachineName()); - $this->drupalCreateContentType(['type' => $this->contentTypeName]); + $this->createContentType(['type' => $this->contentTypeName]); $this->adminUser = $this->drupalCreateUser(array_keys($this->container->get('user.permissions')->getPermissions())); $field_storage = FieldStorageConfig::create([ 'field_name' => $this->fieldName, @@ -86,4 +92,16 @@ abstract class WebTestBase extends CoreWebTestBase { $this->resetAll(); } + /** + * Set a field value. + * + * @param $field + * The name of the field to set. + * @param $value + * The value to set. + */ + protected function setFieldValue($field, $value) { + $this->getSession()->getPage()->find('css', '[name="' . $field . '"]')->setValue($value); + } + } diff --git a/src/Tests/Web/WidgetTest.php b/tests/src/Functional/WidgetTest.php similarity index 78% rename from src/Tests/Web/WidgetTest.php rename to tests/src/Functional/WidgetTest.php index b3c820c..abc048c 100644 --- a/src/Tests/Web/WidgetTest.php +++ b/tests/src/Functional/WidgetTest.php @@ -1,9 +1,8 @@ randomMachineName(); // Test an invalid input. - $this->drupalPostForm(Url::fromRoute('node.add', ['node_type' => $this->contentTypeName]), [ + $this->drupalGet(Url::fromRoute('node.add', ['node_type' => $this->contentTypeName])->toString()); + $this->submitForm([ 'title[0][value]' => $node_title, $this->fieldName . '[0][value]' => 'Some useless value.', ], t('Save and publish')); @@ -32,7 +32,7 @@ class WidgetTest extends WebTestBase { // Test a valid input. $valid_input = 'https://vimeo.com/80896303'; - $this->drupalPostForm(NULL, [ + $this->submitForm([ $this->fieldName . '[0][value]' => $valid_input, ], t('Save and publish')); $this->assertRaw(t('@type %title has been created.', [ @@ -41,11 +41,11 @@ class WidgetTest extends WebTestBase { ])); // Load the saved node and assert the valid value was saved into the field. - $nodes = \Drupal::entityManager() + $nodes = \Drupal::entityTypeManager() ->getStorage('node') ->loadByProperties(['title' => $node_title]); $node = array_shift($nodes); - $this->assertEqual($node->{$this->fieldName}[0]->value, $valid_input); + $this->assertEquals($node->{$this->fieldName}[0]->value, $valid_input); } } diff --git a/src/Tests/Kernel/FieldOutputTest.php b/tests/src/Kernel/FieldOutputTest.php similarity index 98% rename from src/Tests/Kernel/FieldOutputTest.php rename to tests/src/Kernel/FieldOutputTest.php index b4b9bed..f27b569 100644 --- a/src/Tests/Kernel/FieldOutputTest.php +++ b/tests/src/Kernel/FieldOutputTest.php @@ -1,11 +1,10 @@