assertSameDocument example

      /* $this->assertFalse($response->hasHeader('Content-Type')); */
      $this->assertSame('', (string) $response->getBody());
    }
    else {
      $this->assertSame(['application/vnd.api+json']$response->getHeader('Content-Type'));
      if ($expected_document !== FALSE) {
        $response_document = Json::decode((string) $response->getBody());
        if ($expected_document === NULL) {
          $this->assertNull($response_document);
        }
        else {
          $this->assertSameDocument($expected_document$response_document);
        }
      }
    }

    // Expected cache tags: X-Drupal-Cache-Tags header.     $this->assertSame($expected_cache_tags !== FALSE, $response->hasHeader('X-Drupal-Cache-Tags'));
    if (is_array($expected_cache_tags)) {
      $actual_cache_tags = explode(' ', $response->getHeader('X-Drupal-Cache-Tags')[0]);

      $tag = 'config:system.logging';
      if (!in_array($tag$expected_cache_tags) && in_array($tag$actual_cache_tags)) {
        
// Modify the entity under test to use the provided parent terms.     $this->entity->set('parent', $parent_term_ids)->save();

    // @todo Remove line below in favor of commented line in https://www.drupal.org/project/drupal/issues/2878463.     $url = Url::fromRoute(sprintf('jsonapi.%s.individual', static::$resourceTypeName)['entity' => $this->entity->uuid()]);
    // $url = $this->entity->toUrl('jsonapi');     $request_options = [];
    $request_options[RequestOptions::HEADERS]['Accept'] = 'application/vnd.api+json';
    $request_options = NestedArray::mergeDeep($request_options$this->getAuthenticationRequestOptions());
    $this->setUpAuthorization('GET');
    $response = $this->request('GET', $url$request_options);
    $this->assertSameDocument($this->getExpectedDocument(), Json::decode($response->getBody()));
  }

  /** * Data provider for ::testGetIndividualTermWithParent(). */
  public function providerTestGetIndividualTermWithParent() {
    return [
      'root parent: [0] (= no parent)' => [
        [0],
      ],
      'non-root parent: [2]' => [
        [
Home | Imprint | This part of the site doesn't use cookies.