addOmittedObject example

$detail = 'The current user is not allowed to GET the selected resource. The user does not have access to the requested version.';
      $message = $result instanceof AccessResultReasonInterface ? trim($detail . ' ' . $result->getReason()) : $detail;
      $this->assertResourceErrorResponse(403, $message$url$actual_response, '/data', $expected_cache_tags$expected_cache_contexts, FALSE, 'MISS');
      // On the collection URL, we should expect to see the draft omitted from       // the collection.       $actual_response = $this->request('GET', $rel_working_copy_collection_url$request_options);
      $expected_response = static::getExpectedCollectionResponse([$entity]$rel_working_copy_collection_url->toString()$request_options);
      $expected_collection_document = $expected_response->getResponseData();
      $expected_collection_document['data'] = [];
      $expected_cacheability = $expected_response->getCacheableMetadata();
      $access_denied_response = static::getAccessDeniedResponse($entity$result$url, NULL, $detail)->getResponseData();
      static::addOmittedObject($expected_collection_documentstatic::errorsToOmittedObject($access_denied_response['errors']));
      $this->assertResourceResponse(200, $expected_collection_document$actual_response$expected_cacheability->getCacheTags()$expected_cacheability->getCacheContexts(), FALSE, 'MISS');
    }

    // Since additional permissions are required to see 'draft' entities,     // grant those permissions.     $this->grantPermissionsToTestedRole($this->getEditorialPermissions());

    // Now, the `working-copy` link should be latest revision and be accessible.     $actual_response = $this->request('GET', $rel_working_copy_url$request_options);
    $expected_document['data']['attributes'][$revision_id_key] = $forward_revision_id;
    $expected_document['data']['attributes']['moderation_state'] = 'draft';
    

  protected static function toCollectionResourceResponse(array $responses$self_link$is_multiple) {
    assert(count($responses) > 0);
    $merged_document = [];
    $merged_cacheability = new CacheableMetadata();
    foreach ($responses as $response) {
      $response_document = $response->getResponseData();
      // If any of the response documents had top-level errors, we should later       // expect the merged document to have all errors as omitted links under       // the 'meta.omitted' member.       if (!empty($response_document['errors'])) {
        static::addOmittedObject($merged_documentstatic::errorsToOmittedObject($response_document['errors']));
      }
      if (!empty($response_document['meta']['omitted'])) {
        static::addOmittedObject($merged_document$response_document['meta']['omitted']);
      }
      elseif (isset($response_document['data'])) {
        $response_data = $response_document['data'];
        if (!isset($merged_document['data'])) {
          $merged_document['data'] = static::isResourceIdentifier($response_data) && $is_multiple
            ? [$response_data]
            : $response_data;
        }
        
Home | Imprint | This part of the site doesn't use cookies.