// Output should contain all image styles and all breakpoints.
$this->drupalGet('node/' . $nid); if(!$empty_styles){ $this->assertSession()->responseContains('/styles/medium/'); // Assert the empty image is present.
$this->assertSession()->responseContains('data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='); $thumbnail_style = ImageStyle::load('thumbnail'); // Assert the output of the 'srcset' attribute (small multipliers first).
$this->assertSession()->responseContains('data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== 1x, ' . $this->fileUrlGenerator->transformRelative($thumbnail_style->buildUrl($image_uri)) . ' 1.5x'); $this->assertSession()->responseContains('/styles/medium/'); // Assert the output of the original image.
$this->assertSession()->responseContains($this->fileUrlGenerator->generateString($image_uri) . ' 3x'); // Assert the output of the breakpoints.
$this->assertSession()->responseContains('media="(min-width: 0px)"'); $this->assertSession()->responseContains('media="(min-width: 560px)"'); // Assert the output of the 'sizes' attribute.
$this->assertSession()->responseContains('sizes="(min-width: 700px) 700px, 100vw"'); $this->assertSession()->responseMatches('/media="\(min-width: 560px\)".+?sizes="\(min-width: 700px\) 700px, 100vw"/'); // Assert the output of the 'srcset' attribute (small images first).
$medium_style = ImageStyle::load('medium');
publicfunctiontestRead(){ $this->createDefaultContent(61, 5, TRUE, TRUE, static::IS_NOT_MULTILINGUAL, FALSE); // Unpublish the last entity, so we can check access.
$this->nodes[60]->setUnpublished()->save();
// Different databases have different sort orders, so a sort is required so
// test expectations do not need to vary per database.
$default_sort = ['sort' => 'drupal_internal__nid'];
// 0. HEAD request allows a client to verify that JSON:API is installed.
$this->httpClient->request('HEAD', $this->buildUrl('/jsonapi/node/article')); $this->assertSession()->statusCodeEquals(200); // 1. Load all articles (1st page).
$collection_output = Json::decode($this->drupalGet('/jsonapi/node/article', [ 'query' => $default_sort, ])); $this->assertSession()->statusCodeEquals(200); $this->assertCount(OffsetPage::SIZE_MAX, $collection_output['data']); $this->assertSession() ->responseHeaderEquals('Content-Type', 'application/vnd.api+json'); // 2. Load all articles (Offset 3).
$collection_output = Json::decode($this->drupalGet('/jsonapi/node/article', [
$this->assertCount(1, $drupal_settings['views']['ajaxViews']); $view_entry = array_keys($drupal_settings['views']['ajaxViews'])[0]; $this->assertEquals('test_ajax_view', $drupal_settings['views']['ajaxViews'][$view_entry]['view_name'], 'The view\'s ajaxViews array entry has the correct \'view_name\' key.'); $this->assertEquals('page_1', $drupal_settings['views']['ajaxViews'][$view_entry]['view_display_id'], 'The view\'s ajaxViews array entry has the correct \'view_display_id\' key.'); }
// Not even logging in would make it possible to see the view, because then
// we are denied based on authentication method (cookie).
$this->drupalLogin($this->adminUser); $this->drupalGet('test/serialize/auth_with_perm', ['query' => ['_format' => 'json']]); $this->assertSession()->statusCodeEquals(403); $this->drupalLogout();
// But if we use the basic auth authentication strategy, we should be able
// to see the page.
$url = $this->buildUrl('test/serialize/auth_with_perm'); $response = \Drupal::httpClient()->get($url, [ 'auth' => [$this->adminUser->getAccountName(), $this->adminUser->pass_raw], 'query' => [ '_format' => 'json', ], ]);
// Ensure that any changes to variables in the other thread are picked up.
$this->refreshVariables();
foreach($itemsas$delta => $item){ // By default use the full URL as the link text.
$url = $this->buildUrl($item); $link_title = $url->toString();
// If the link text field value is available, use it for the text.
if(empty($settings['url_only']) && !empty($item->title)){ // Unsanitized token replacement here because the entire link title
// gets auto-escaped during link generation in
// \Drupal\Core\Utility\LinkGenerator::generate().
$link_title = \Drupal::token()->replace($item->title, [$entity->getEntityTypeId() => $entity], ['clear' => TRUE]); }
// The link_separate formatter has two titles; the link text (as in the