To simplify the tests and make them easier to read, I suggest we drop the getEmbedDialog helper function.

 
-  /**
-   * Retrieves an embed dialog based on given parameters.
-   *
-   * @param string $filter_format_id
-   *   ID of the filter format.
-   * @param string $embed_button_id
-   *   ID of the embed button.
-   *
-   * @return string
-   *   The retrieved HTML string.
-   */
-  public function getEmbedDialog($filter_format_id = NULL, $embed_button_id = NULL) {
-    $url = 'entity-embed/dialog';
-    if (!empty($filter_format_id)) {
-      $url .= '/' . $filter_format_id;
-      if (!empty($embed_button_id)) {
-        $url .= '/' . $embed_button_id;
-      }
-    }
-    return $this->drupalGet($url);
-  }
-
 }

It just obfuscates the url on drupalGet() calls, as it just concatenates a string to create a url that's easy to understand by looking at the url itself.

I think it's clearer to see the url in the test:

-    $this->getEmbedDialog('custom_format', 'node');
+    $this->drupalGet('/entity-embed/dialog/custom_format/node');

Comments

oknate created an issue. See original summary.

oknate’s picture

Issue tags: +Novice
oknate’s picture

Issue summary: View changes
wim leers’s picture

+1

wim leers’s picture

Title: Drop getEmbedDialog from EntityEmbedTestBase.php » Refactor away getEmbedDialog() from EntityEmbedTestBase, just use URLs
Issue tags: +php-novice
iuana’s picture

Assigned: Unassigned » iuana
iuana’s picture

Assigned: iuana » Unassigned
Status: Active » Needs review
StatusFileSize
new8.72 KB

Status: Needs review » Needs work

The last submitted patch, 7: entity_embed-8.x-1.x-remove_getEmbedDialog.patch, failed testing. View results

oknate’s picture

-    $this->getEmbedDialog('custom_format', 'invalid_button');
+    $this->drupalGet('/entity-embed/dialog/custom_format/node');

I would think this should be

/entity-embed/dialog/custom_format/invalid_button

not

/entity-embed/dialog/custom_format/node

etc.

If you can, run the test and see the output from each getEmbedDialog() and put that into drupalGet().

iuana’s picture

yes, I will do, thanks for the review.

phenaproxima’s picture

+1 for this change. Once the tests are fixed, I'm comfortable committing this.

iuana’s picture

StatusFileSize
new8.73 KB

I couldn't run the tests.. an error occurred. I fixed the problem I see.
Here are the new changes.

iuana’s picture

Status: Needs work » Needs review
phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

  • phenaproxima committed 3c8869b on 8.x-1.x authored by iuana
    Issue #3056391 by iuana, oknate: Refactor away getEmbedDialog() from...
phenaproxima’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x-1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.