Problem/Motivation

The collect client web test is currently failing in the main branch. When trying to test the following error is shown

Value 1 is equal to value 2.	Other	CollectClientWebTest.php	115	Drupal\collect_client\Tests\CollectClientWebTest->testShortcutEntityCapture()	
[17-Jul-2015 11:57:14 UTC] Uncaught PHP Exception LogicException: "The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\rest\ResourceResponse." at /var/lib/drupaltestbot/sites/default/files/checkout/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php line 160	Fatal error	Unknown	0	Unknown	
The test did not complete due to a fatal error.	Completion check	CollectClientWebTest.php	121	Drupal\collect_client\Tests\CollectClientWebTest->testContinuousEntityReferenceCapture()	
Value 3 is equal to value 6.	Other	CollectClientWebTest.php	155	Drupal\collect_client\Tests\CollectClientWebTest->testContinuousEntityReferenceCapture()	
Undefined index: valuesDrupal\collect_client\Tests\CollectClientWebTest->testContinuousEntityReferenceCapture() Drupal\simpletest\TestBase->run(Array) simpletest_script_run_one_test('2', 'Drupal\collect_client\Tests\CollectClientWebTest')	Notice	CollectClientWebTest.php	161	Drupal\collect_client\Tests\CollectClientWebTest->testContinuousEntityReferenceCapture()

Proposed resolution

Go to the test and find what is broken.

Remaining tasks

User interface changes

API changes

Data model changes

Original report by [username]

Comments

mbovan’s picture

Status: Active » Needs review
StatusFileSize
new1.68 KB

Recent core changes (CR URLs/links now have the bubbleable metadata of the outbound path & route processors that were applied) broke CollectClientWebTest. It seems that we saved/created only fields definition container, but not values container...

Providing a patch...

Status: Needs review » Needs work

The last submitted patch, 1: collect_client_web_test-2536258-1.patch, failed testing.

mbovan’s picture

Status: Needs work » Needs review
StatusFileSize
new3.99 KB
new3.66 KB

Fixed failiing Unit tests and changed again to use urlGenerator.

berdir’s picture

Status: Needs review » Needs work
  1. +++ b/src/Plugin/rest/resource/CollectResource.php
    @@ -159,7 +159,7 @@ class CollectResource extends ResourceBase {
         $content = $this->serializer->normalize($submission, $format);
         if ($format == 'hal_json') {
    -      $content['_links']['self']['href'] = $this->getCanonicalUrl($submission);
    +      $content['_links']['self']['href'] = $this->getCanonicalUrl($submission)->getGeneratedUrl();
         }
         return new ResourceResponse($content);
    

    This here likely needs the same change, we might just not have test coverage for it?

  2. +++ b/tests/src/Unit/Plugin/rest/resource/CollectResourceTest.php
    @@ -137,10 +138,18 @@ class CollectResourceTest extends UnitTestCase {
    +    $generated_url = $this->getMockBuilder('Drupal\Core\GeneratedUrl')
    +      ->disableOriginalConstructor()
    +      ->getMock();
    

    Sometimes it is easier to use real objects for things like this. Depends on the class/test.

mbovan’s picture

Status: Needs work » Needs review
StatusFileSize
new3.45 KB
new4.1 KB

1. Changed... Not sure that this part is needed at all, as we use collect_json format. hal_json condition is covered in testGet() in CollectResourceTest.

berdir’s picture

Looks good, let's unblock collect (again).

  • Berdir committed a1c986c on 8.x-1.x authored by mbovan
    Issue #2536258 by mbovan: Collect Client Web Test Failing
    
berdir’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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