// Get the autocomplete URL of the owner_uid textfield.
$autocomplete_field = $this->getSession()->getPage()->findField('owner_uid'); $autocomplete_url = $this->getAbsoluteUrl($autocomplete_field->getAttribute('data-autocomplete-path'));
$anonymous = User::getAnonymousUser(); // Ensure that the anonymous user exists.
$this->assertNotNull($anonymous); // Make sure the autocomplete does not show the anonymous user.
$data = Json::decode($this->drupalGet($autocomplete_url, ['query' => ['q' => $anonymous->getDisplayName(), '_format' => 'json']])); $this->assertEmpty($data);
}
}
#[Package('core')]
classJsonApiDecoderimplements DecoderInterface { finalpublicconst FORMAT = 'jsonapi';
/**
* @covers ::getBaseEncoder
*/ publicfunctiontestDefaultEncoderHasSerializer(){ // The serializer should be set on the Drupal encoder, which should then
// set it on our default encoder.
$encoder = newXmlEncoder(); $serializer = newSerializer([newGetSetMethodNormalizer()]); $encoder->setSerializer($serializer);
// 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(); }
/**
* Gets the expected file entity.
*
* @return array
* The expected normalized data array.
*/
// Status should be FALSE when posting as anonymous.
$response = $this->request('POST', $url, $request_options); $this->assertResourceResponse(201, FALSE, $response); $this->assertFalse(Json::decode((string)$response->getBody())['data']['attributes']['status']); $this->assertFalse($this->entityStorage->loadUnchanged(2)->isPublished());
// Grant anonymous permission to skip comment approval.
$this->grantPermissionsToTestedRole(['skip comment approval']);
// Status must be TRUE when posting as anonymous and skip comment approval.
$response = $this->request('POST', $url, $request_options); $this->assertResourceResponse(201, FALSE, $response); $this->assertTrue(Json::decode((string)$response->getBody())['data']['attributes']['status']); $this->assertTrue($this->entityStorage->loadUnchanged(3)->isPublished()); }
/**
* {@inheritdoc}
*/ publicfunctionparse($filename){ if(!file_exists($filename)){ $parsed_info = []; } else{ try{ $parsed_info = Yaml::decode(file_get_contents($filename)); } catch(InvalidDataTypeException $e){ thrownewInfoParserException("Unable to parse $filename " . $e->getMessage()); } $missing_keys = array_diff($this->getRequiredKeys(), array_keys($parsed_info)); if(!empty($missing_keys)){ thrownewInfoParserException('Missing required keys (' . implode(', ', $missing_keys) . ') in ' . $filename); } if(!isset($parsed_info['core_version_requirement'])){ if(str_starts_with($filename, 'core/') || str_starts_with($filename, $this->root . '/core/')){ // Core extensions do not need to specify core compatibility: they are