Node tokens are currently broken because the use for the instanceof NodeInterface is missing, so that is never true.

Also removed some unused uses.

Comments

berdir’s picture

Status: Active » Needs review
StatusFileSize
new597 bytes

Status: Needs review » Needs work

The last submitted patch, 1: google_analytics-use-2500157-1.patch, failed testing.

hass’s picture

Status: Needs work » Fixed

  • hass committed 8d62a04 on 8.x-2.x authored by Berdir
    Issue #2500157 by bedir: Missing use for NodeInterface
    
hass’s picture

Any idea why the uninstall test fails now?

hass’s picture

Status: Fixed » Needs work

There seems no test.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new597 bytes

Added the test for node tokens.

hass’s picture

Status: Needs review » Needs work

Invalid patch

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new3.12 KB

Uhh, sorry. Selected the wrong patch.

berdir’s picture

Status: Needs review » Needs work
  1. +++ b/src/Tests/GoogleAnalyticsCustomDimensionsAndMetricsTest.php
    @@ -43,6 +58,11 @@ class GoogleAnalyticsCustomDimensionsAndMetricsTest extends WebTestBase {
    +    $node = $this->drupalCreateNode([
    +      'type' => $this->nodeType,
    +    ]);
    +    $node_id = $node->id();
    +    $node_title = $node->getTitle();
    

    This is the only place where you us $this->nodeType, everything else is hardcoded. I'd just hardcode this as well.

    I don't think $node_id and $node_title are used?

  2. +++ b/src/Tests/GoogleAnalyticsCustomDimensionsAndMetricsTest.php
    @@ -105,6 +129,10 @@ class GoogleAnalyticsCustomDimensionsAndMetricsTest extends WebTestBase {
    +    $this->assertText($node_title);
    +    $this->assertRaw('ga("set", ' . Json::encode('dimension5') . ', ' . Json::encode('article') . ');', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Article is shown.');
    

    Something like "Node tokens are shown" might be more useful as an assertion message?

    While we're adding this, might be useful to add an assertRaw() on the frontpage or whatever page we visit above, and make sure that there is no ga('set' for dimension 5 at all, to make sure that we don't print out an empty value.

The last submitted patch, 9: missing_use_for-2500157-7.patch, failed testing.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new3.06 KB
new2.44 KB

Fixes based on the comments above.

Are the test fails related to this change?

berdir’s picture

Status: Needs review » Reviewed & tested by the community

No, they aren't. Looks good now.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 12: missing_use_for-2500157-12.patch, failed testing.

berdir’s picture

Status: Needs work » Reviewed & tested by the community
hass’s picture

Status: Reviewed & tested by the community » Needs work

I was also thinking about the http://cgit.drupalcode.org/google_analytics/tree/google_analytics.module... code that need to be tested. This patch seems to test dimensions only.

berdir’s picture

Status: Needs work » Reviewed & tested by the community

I don't think we should be testing that here. That part needs work (at least for comments/concepts.. content_translation in 8.x has no translation sets or multiple nodes.. a different language could have a different URL, though), so it seems like that should be it's own issue to improve those things too.

Why would you want to block additional test coverage on more.. let's get this committed and then we can write more.

hass’s picture

content_translation in 8.x has no translation sets or multiple nodes

I have tested this feature a few months ago and it worked. When has it changed that translations of a node are no longer other nodes?

When I reopened the case I only thought about testing lines 150ff...

hass’s picture

Status: Reviewed & tested by the community » Fixed

  • hass committed 372d4d0 on 8.x-2.x authored by sasanikolic
    Issue #2500157 by sasanikolic, Berdir: Missing use for NodeInterface
    

Status: Fixed » Closed (fixed)

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