Currently you can configure page displays to provide itself not only as local task/local action but also
as contextual link.

As #2040379: Define contextual entity operations through annotation; remove the context property from hook_menu items might kill the functionality let's ensure that it is not just ignored.
People might interpretate this patch as a kind of asshole patch (as it makes refactoring difficult), but I just care about hidden and potential regressions.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
4.64 KB

Status: Needs review » Needs work

The last submitted patch, vdc-2051917-1.patch, failed testing.

damiankloip’s picture

I don't think this is an 'asshole patch' :) We have been screwed many times by regressions, this is fair enough imo.

+++ b/core/modules/node/lib/Drupal/node/Tests/Views/NodeContextualLinks.phpundefined
@@ -0,0 +1,61 @@
+namespace Drupal\node\Tests\Views;
+use Symfony\Component\HttpFoundation\Request;

Space between

+++ b/core/modules/node/lib/Drupal/node/Tests/Views/NodeContextualLinks.phpundefined
@@ -0,0 +1,61 @@
+    /** @var \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel */

Weird place for this comment, use '//' or we could make it a property or somthing and document it there?

+++ b/core/modules/node/lib/Drupal/node/Tests/Views/NodeContextualLinks.phpundefined
@@ -0,0 +1,61 @@
+    $this->assertEqual(1, count($result), 'One contextual link found.');
+    $this->assertEqual('Test contextual link', (string) $result[0], 'Ensure the right link text was returned');

I like to switch these params round, I find it easier to read - that' just preference though. I think unit tests in phpunit may want them this way?

dawehner’s picture

Status: Needs work » Needs review
FileSize
936 bytes
4.66 KB

Weird place for this comment, use '//' or we could make it a property or somthing and document it there?

That is a phpstorm thing to be able to document the type of variable, which is just a good idea in general, I think.

I don't really know why this failing, as it works fine locally.

Status: Needs review » Needs work

The last submitted patch, vdc-2051917-4.patch, failed testing.

dawehner’s picture

FileSize
4.48 KB

mhh

dawehner’s picture

Status: Needs work » Needs review

.

Status: Needs review » Needs work

The last submitted patch, vdc-2051917-6.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
2.75 KB
5.93 KB

Seriously testing contextual links is hell.

damiankloip’s picture

+++ b/core/modules/node/lib/Drupal/node/Tests/Views/NodeContextualLinksTest.phpundefined
@@ -0,0 +1,101 @@
+      'description' => 'Tests contextual links provided by views on nodes.',

Maybe 'Tests views contextual links on nodes' instead?

+++ b/core/modules/node/lib/Drupal/node/Tests/Views/NodeContextualLinksTest.phpundefined
@@ -0,0 +1,101 @@
+   * Test contextual links.

Tests.. sorry

+++ b/core/modules/node/lib/Drupal/node/Tests/Views/NodeContextualLinksTest.phpundefined
@@ -0,0 +1,101 @@
+    $result = $this->xpath("//a[contains(@href, 'node/1/contextual-links')]");
+    $this->assertEqual(count($result), 1, 'One contextual link found.');
+    $this->assertEqual((string) $result[0], 'Test contextual link', 'Ensure the right link text was returned');

We could still use assertlink() and friends here? I guess you want the count first, so might as well use the xpath result you have?

+++ b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_contextual_links.ymlundefined
@@ -0,0 +1,98 @@
+label: Frontpage

New label please :)

dawehner’s picture

FileSize
5.85 KB

Thanks for the review!

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Who did this to contextual links? Ouch.

The ugliness of this code is not @dawehner's fault.

Test looks great.

dawehner’s picture

#11: vdc-2051917-11.patch queued for re-testing.

Wim Leers’s picture

#12: you're probably referring to the fact that you need HTTP requests for contextual links to show up; I did that, but it was necessary to fix the render cache, see #914382: Contextual links incompatible with render cache.
If you're referring to test ugliness — then I'm happy to point you to #2074037: Add drupalPostUrl() — drupalPost()/drupalPostAjax() are for forms only, D8 JS performs non-form HTTP requests which fixes that :) mondrake just +1'd that issue and tagged it with VDC because you apparently encountered the same problem in Views.

dawehner’s picture

#11: vdc-2051917-11.patch queued for re-testing.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Yay, more tests!

It seems like this could benefit from #2074037: Add drupalPostUrl() — drupalPost()/drupalPostAjax() are for forms only, D8 JS performs non-form HTTP requests once that's in, but that's still under discussion, so for now, curlExec() it is, I suppose.

Committed and pushed to 8.x. Thanks!

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