getExpectedNormalizedFileEntity example

      'Content-Disposition' => 'file; filename="drupal rocks 🤘.txt"',
    ];
    $request_options[RequestOptions::BODY] = 'Drupal is the best!';
    $request_options = NestedArray::mergeDeep($request_options$this->getAuthenticationRequestOptions('POST'));
    $response = $this->request('POST', $url$request_options);
    $this->assertResourceErrorResponse(403, $this->getExpectedUnauthorizedAccessMessage('POST')$response);

    // Grant necessary permission, retry.     $this->grantPermissionsToTestedRole(['create camelids media']);
    $response = $this->request('POST', $url$request_options);
    $this->assertSame(201, $response->getStatusCode());
    $expected = $this->getExpectedNormalizedFileEntity();
    static::recursiveKSort($expected);
    $actual = $this->serializer->decode((string) $response->getBody()static::$format);
    static::recursiveKSort($actual);
    $this->assertSame($expected$actual);

    // To still run the complete test coverage for POSTing a Media entity, we     // must revoke the additional permissions that we granted.     $role = Role::load(static::$auth ? RoleInterface::AUTHENTICATED_ID : RoleInterface::ANONYMOUS_ID);
    $role->revokePermission('create camelids media');
    $role->trustData()->save();
  }

  
Home | Imprint | This part of the site doesn't use cookies.