当前位置: 首页>>代码示例>>PHP>>正文


PHP file_url_transform_relative函数代码示例

本文整理汇总了PHP中file_url_transform_relative函数的典型用法代码示例。如果您正苦于以下问题:PHP file_url_transform_relative函数的具体用法?PHP file_url_transform_relative怎么用?PHP file_url_transform_relative使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了file_url_transform_relative函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doTestAutoOrientOperations

 /**
  * Auto Orientation operations test.
  */
 public function doTestAutoOrientOperations()
 {
     $image_factory = $this->container->get('image.factory');
     $test_data = [['test_file' => drupal_get_path('module', 'image_effects') . '/misc/portrait-painting.jpg', 'original_width' => 640, 'original_height' => 480, 'derivative_width' => 200, 'derivative_height' => 267], ['test_file' => drupal_get_path('module', 'simpletest') . '/files/image-test.jpg', 'original_width' => 40, 'original_height' => 20, 'derivative_width' => 200, 'derivative_height' => 100], ['test_file' => drupal_get_path('module', 'simpletest') . '/files/image-1.png', 'original_width' => 360, 'original_height' => 240, 'derivative_width' => 200, 'derivative_height' => 133]];
     foreach ($test_data as $data) {
         // Get expected URIs.
         $original_uri = file_unmanaged_copy($data['test_file'], 'public://', FILE_EXISTS_RENAME);
         $generated_uri = 'public://styles/image_effects_test/public/' . \Drupal::service('file_system')->basename($original_uri);
         // Test source image dimensions.
         $image = $image_factory->get($original_uri);
         $this->assertEqual($data['original_width'], $image->getWidth());
         $this->assertEqual($data['original_height'], $image->getHeight());
         // Load Image Style and get expected derivative URL.
         $image_style = ImageStyle::load('image_effects_test');
         $url = file_url_transform_relative($image_style->buildUrl($original_uri));
         // Check that ::transformDimensions returns expected dimensions.
         $variables = array('#theme' => 'image_style', '#style_name' => 'image_effects_test', '#uri' => $original_uri, '#width' => $image->getWidth(), '#height' => $image->getHeight());
         $this->assertEqual('<img src="' . $url . '" width="' . $data['derivative_width'] . '" height="' . $data['derivative_height'] . '" alt="" class="image-style-image-effects-test" />', $this->getImageTag($variables));
         // Check that ::applyEffect generates image with expected dimensions.
         $image_style->createDerivative($original_uri, $image_style->buildUri($original_uri));
         $image = $image_factory->get($generated_uri);
         $this->assertEqual($data['derivative_width'], $image->getWidth());
         $this->assertEqual($data['derivative_height'], $image->getHeight());
     }
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:28,代码来源:ImageEffectsAutoOrientTest.php

示例2: testPictureOnNodeComment

 /**
  * Tests embedded users on node pages.
  */
 function testPictureOnNodeComment()
 {
     $this->drupalLogin($this->webUser);
     // Save a new picture.
     $image = current($this->drupalGetTestFiles('image'));
     $file = $this->saveUserPicture($image);
     $node = $this->drupalCreateNode(array('type' => 'article'));
     // Enable user pictures on nodes.
     $this->config('system.theme.global')->set('features.node_user_picture', TRUE)->save();
     $image_style_id = $this->config('core.entity_view_display.user.user.compact')->get('content.user_picture.settings.image_style');
     $style = ImageStyle::load($image_style_id);
     $image_url = file_url_transform_relative($style->buildUrl($file->getfileUri()));
     $alt_text = 'Profile picture for user ' . $this->webUser->getUsername();
     // Verify that the image is displayed on the node page.
     $this->drupalGet('node/' . $node->id());
     $elements = $this->cssSelect('.node__meta .field--name-user-picture img[alt="' . $alt_text . '"][src="' . $image_url . '"]');
     $this->assertEqual(count($elements), 1, 'User picture with alt text found on node page.');
     // Enable user pictures on comments, instead of nodes.
     $this->config('system.theme.global')->set('features.node_user_picture', FALSE)->set('features.comment_user_picture', TRUE)->save();
     $edit = array('comment_body[0][value]' => $this->randomString());
     $this->drupalPostForm('comment/reply/node/' . $node->id() . '/comment', $edit, t('Save'));
     $elements = $this->cssSelect('.comment__meta .field--name-user-picture img[alt="' . $alt_text . '"][src="' . $image_url . '"]');
     $this->assertEqual(count($elements), 1, 'User picture with alt text found on the comment.');
     // Disable user pictures on comments and nodes.
     $this->config('system.theme.global')->set('features.node_user_picture', FALSE)->set('features.comment_user_picture', FALSE)->save();
     $this->drupalGet('node/' . $node->id());
     $this->assertNoRaw(file_uri_target($file->getFileUri()), 'User picture not found on node and comment.');
 }
开发者ID:Wylbur,项目名称:gj,代码行数:31,代码来源:UserPictureTest.php

示例3: process

 /**
  * {@inheritdoc}
  */
 public function process($text, $langcode)
 {
     $result = new FilterProcessResult($text);
     if (stristr($text, 'data-entity-type="file"') !== FALSE) {
         $dom = Html::load($text);
         $xpath = new \DOMXPath($dom);
         $processed_uuids = array();
         foreach ($xpath->query('//*[@data-entity-type="file" and @data-entity-uuid]') as $node) {
             $uuid = $node->getAttribute('data-entity-uuid');
             // If there is a 'src' attribute, set it to the file entity's current
             // URL. This ensures the URL works even after the file location changes.
             if ($node->hasAttribute('src')) {
                 $file = $this->entityManager->loadEntityByUuid('file', $uuid);
                 if ($file) {
                     $node->setAttribute('src', file_url_transform_relative(file_create_url($file->getFileUri())));
                 }
             }
             // Only process the first occurrence of each file UUID.
             if (!isset($processed_uuids[$uuid])) {
                 $processed_uuids[$uuid] = TRUE;
                 $file = $this->entityManager->loadEntityByUuid('file', $uuid);
                 if ($file) {
                     $result->addCacheTags($file->getCacheTags());
                 }
             }
         }
         $result->setProcessedText(Html::serialize($dom));
     }
     return $result;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:33,代码来源:EditorFileReference.php

示例4: viewElements

 /**
  * {@inheritdoc}
  */
 public function viewElements(FieldItemListInterface $items, $langcode)
 {
     $elements = array();
     foreach ($this->getEntitiesToView($items, $langcode) as $delta => $file) {
         $elements[$delta] = array('#markup' => file_url_transform_relative(file_create_url($file->getFileUri())), '#cache' => array('tags' => $file->getCacheTags()));
     }
     return $elements;
 }
开发者ID:Wylbur,项目名称:gj,代码行数:11,代码来源:UrlPlainFormatter.php

示例5: testThemeImageWithSrcsetWidth

 /**
  * Tests that an image with the srcset and widths is output correctly.
  */
 function testThemeImageWithSrcsetWidth()
 {
     // Test with multipliers.
     $widths = array(rand(0, 500) . 'w', rand(500, 1000) . 'w');
     $image = array('#theme' => 'image', '#srcset' => array(array('uri' => $this->testImages[0], 'width' => $widths[0]), array('uri' => $this->testImages[1], 'width' => $widths[1])), '#width' => rand(0, 1000) . 'px', '#height' => rand(0, 500) . 'px', '#alt' => $this->randomMachineName(), '#title' => $this->randomMachineName());
     $this->render($image);
     // Make sure the srcset attribute has the correct value.
     $this->assertRaw(file_url_transform_relative(file_create_url($this->testImages[0])) . ' ' . $widths[0] . ', ' . file_url_transform_relative(file_create_url($this->testImages[1])) . ' ' . $widths[1], 'Correct output for image with srcset attribute and width descriptors.');
 }
开发者ID:318io,项目名称:318-io,代码行数:12,代码来源:ImageTest.php

示例6: doTestSetCanvasOperations

 /**
  * Set canvas operations test.
  */
 public function doTestSetCanvasOperations()
 {
     $image_factory = $this->container->get('image.factory');
     $test_file = drupal_get_path('module', 'simpletest') . '/files/image-test.png';
     $original_uri = file_unmanaged_copy($test_file, 'public://', FILE_EXISTS_RENAME);
     $generated_uri = 'public://styles/image_effects_test/public/' . \Drupal::service('file_system')->basename($original_uri);
     // Test EXACT size canvas.
     $effect = ['id' => 'image_effects_set_canvas', 'data' => ['canvas_size' => 'exact', 'canvas_color][container][transparent' => FALSE, 'canvas_color][container][hex' => '#FF00FF', 'canvas_color][container][opacity' => 100, 'exact][width' => '200%', 'exact][height' => '200%']];
     $uuid = $this->addEffectToTestStyle($effect);
     // Load Image Style.
     $image_style = ImageStyle::load('image_effects_test');
     // Check that ::transformDimensions returns expected dimensions.
     $image = $image_factory->get($original_uri);
     $this->assertEqual(40, $image->getWidth());
     $this->assertEqual(20, $image->getHeight());
     $url = file_url_transform_relative($image_style->buildUrl($original_uri));
     $variables = array('#theme' => 'image_style', '#style_name' => 'image_effects_test', '#uri' => $original_uri, '#width' => $image->getWidth(), '#height' => $image->getHeight());
     $this->assertEqual('<img src="' . $url . '" width="80" height="40" alt="" class="image-style-image-effects-test" />', $this->getImageTag($variables));
     // Check that ::applyEffect generates image with expected canvas.
     $image_style->createDerivative($original_uri, $image_style->buildUri($original_uri));
     $image = $image_factory->get($generated_uri, 'gd');
     $this->assertEqual(80, $image->getWidth());
     $this->assertEqual(40, $image->getHeight());
     $this->assertTrue($this->colorsAreEqual($this->fuchsia, $this->getPixelColor($image, 0, 0)));
     $this->assertTrue($this->colorsAreEqual($this->fuchsia, $this->getPixelColor($image, 79, 0)));
     $this->assertTrue($this->colorsAreEqual($this->fuchsia, $this->getPixelColor($image, 0, 39)));
     $this->assertTrue($this->colorsAreEqual($this->fuchsia, $this->getPixelColor($image, 79, 39)));
     // Remove effect.
     $this->removeEffectFromTestStyle($uuid);
     // Test RELATIVE size canvas.
     $effect = ['id' => 'image_effects_set_canvas', 'data' => ['canvas_size' => 'relative', 'canvas_color][container][transparent' => FALSE, 'canvas_color][container][hex' => '#FFFF00', 'canvas_color][container][opacity' => 100, 'relative][right' => 10, 'relative][left' => 20, 'relative][top' => 30, 'relative][bottom' => 40]];
     $uuid = $this->addEffectToTestStyle($effect);
     // Load Image Style.
     $image_style = ImageStyle::load('image_effects_test');
     // Check that ::transformDimensions returns expected dimensions.
     $image = $image_factory->get($original_uri);
     $this->assertEqual(40, $image->getWidth());
     $this->assertEqual(20, $image->getHeight());
     $url = file_url_transform_relative($image_style->buildUrl($original_uri));
     $variables = array('#theme' => 'image_style', '#style_name' => 'image_effects_test', '#uri' => $original_uri, '#width' => $image->getWidth(), '#height' => $image->getHeight());
     $this->assertEqual('<img src="' . $url . '" width="70" height="90" alt="" class="image-style-image-effects-test" />', $this->getImageTag($variables));
     // Check that ::applyEffect generates image with expected canvas.
     $image_style->createDerivative($original_uri, $image_style->buildUri($original_uri));
     $image = $image_factory->get($generated_uri, 'gd');
     $this->assertEqual(70, $image->getWidth());
     $this->assertEqual(90, $image->getHeight());
     $this->assertTrue($this->colorsAreEqual($this->yellow, $this->getPixelColor($image, 0, 0)));
     $this->assertTrue($this->colorsAreEqual($this->yellow, $this->getPixelColor($image, 69, 0)));
     $this->assertTrue($this->colorsAreEqual($this->yellow, $this->getPixelColor($image, 0, 89)));
     $this->assertTrue($this->colorsAreEqual($this->yellow, $this->getPixelColor($image, 69, 89)));
     // Remove effect.
     $this->removeEffectFromTestStyle($uuid);
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:56,代码来源:ImageEffectsSetCanvasTest.php

示例7: testUrlHandling

 /**
  * Tests relative, root-relative, protocol-relative and absolute URLs.
  */
 public function testUrlHandling()
 {
     // Only the plain_text text format is available by default, which escapes
     // all HTML.
     FilterFormat::create(['format' => 'full_html', 'name' => 'Full HTML', 'filters' => []])->save();
     $defaults = ['type' => 'article', 'promote' => 1];
     $this->drupalCreateNode($defaults + ['body' => ['value' => '<p><a href="' . file_url_transform_relative(file_create_url('public://root-relative')) . '">Root-relative URL</a></p>', 'format' => 'full_html']]);
     $protocol_relative_url = substr(file_create_url('public://protocol-relative'), strlen(\Drupal::request()->getScheme() . ':'));
     $this->drupalCreateNode($defaults + ['body' => ['value' => '<p><a href="' . $protocol_relative_url . '">Protocol-relative URL</a></p>', 'format' => 'full_html']]);
     $absolute_url = file_create_url('public://absolute');
     $this->drupalCreateNode($defaults + ['body' => ['value' => '<p><a href="' . $absolute_url . '">Absolute URL</a></p>', 'format' => 'full_html']]);
     $this->drupalGet('rss.xml');
     $this->assertRaw(file_create_url('public://root-relative'), 'Root-relative URL is transformed to absolute.');
     $this->assertRaw($protocol_relative_url, 'Protocol-relative URL is left untouched.');
     $this->assertRaw($absolute_url, 'Absolute URL is left untouched.');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:19,代码来源:NodeRSSContentTest.php

示例8: testImageButtonDisplay

 /**
  * Method tests CKEditor image buttons.
  */
 public function testImageButtonDisplay()
 {
     $this->drupalLogin($this->admin_user);
     // Install the Arabic language (which is RTL) and configure as the default.
     $edit = [];
     $edit['predefined_langcode'] = 'ar';
     $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
     $edit = ['site_default_language' => 'ar'];
     $this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));
     // Once the default language is changed, go to the tested text format
     // configuration page.
     $this->drupalGet('admin/config/content/formats/manage/full_html');
     // Check if any image button is loaded in CKEditor json.
     $json_encode = function ($html) {
         return trim(Json::encode($html), '"');
     };
     $markup = $json_encode(file_url_transform_relative(file_create_url('core/modules/ckeditor/js/plugins/drupalimage/image.png')));
     $this->assertRaw($markup);
 }
开发者ID:Wylbur,项目名称:gj,代码行数:22,代码来源:CKEditorToolbarButtonTest.php

示例9: preRenderButton

 /**
  * {@inheritdoc}
  */
 public static function preRenderButton($element)
 {
     $element['#attributes']['type'] = 'image';
     Element::setAttributes($element, array('id', 'name', 'value'));
     $element['#attributes']['src'] = file_url_transform_relative(file_create_url($element['#src']));
     if (!empty($element['#title'])) {
         $element['#attributes']['alt'] = $element['#title'];
         $element['#attributes']['title'] = $element['#title'];
     }
     $element['#attributes']['class'][] = 'image-button';
     if (!empty($element['#button_type'])) {
         $element['#attributes']['class'][] = 'image-button--' . $element['#button_type'];
     }
     $element['#attributes']['class'][] = 'js-form-submit';
     $element['#attributes']['class'][] = 'form-submit';
     if (!empty($element['#attributes']['disabled'])) {
         $element['#attributes']['class'][] = 'is-disabled';
     }
     return $element;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:23,代码来源:ImageButton.php

示例10: testFile

 /**
  * Test the field formatter with a file field and file upload widget.
  */
 public function testFile()
 {
     // Create a test node with an image file.
     $this->createNodeWithFile();
     $node = $this->node;
     $xml_path = 'juicebox/xml/field/node/' . $node->id() . '/' . $this->instFieldName . '/full';
     $xml_url = \Drupal::url('juicebox.xml_field', array('entityType' => 'node', 'entityId' => $node->id(), 'fieldName' => $this->instFieldName, 'displayName' => 'full'));
     // Get the urls to the test image and thumb derivative used by default.
     $uri = \Drupal\file\Entity\File::load($node->{$this->instFieldName}[0]->target_id)->getFileUri();
     $test_image_url = entity_load('image_style', 'juicebox_medium')->buildUrl($uri);
     $test_thumb_url = entity_load('image_style', 'juicebox_square_thumb')->buildUrl($uri);
     // Check for correct embed markup as anon user.
     $this->drupalLogout();
     $this->drupalGet('node/' . $node->id());
     $this->assertRaw(trim(json_encode(array('configUrl' => $xml_url)), '{}"'), 'Gallery setting found in Drupal.settings.');
     $this->assertRaw('id="node--' . $node->id() . '--' . str_replace('_', '-', $this->instFieldName) . '--full"', 'Embed code wrapper found.');
     $this->assertRaw(Html::escape(file_url_transform_relative($test_image_url)), 'Test image found in embed code');
     // Check for correct XML.
     $this->drupalGet($xml_path);
     $this->assertRaw('<?xml version="1.0" encoding="UTF-8"?>', 'Valid XML detected.');
     $this->assertRaw('imageURL="' . Html::escape($test_image_url), 'Test image found in XML.');
     $this->assertRaw('thumbURL="' . Html::escape($test_thumb_url), 'Test thumbnail found in XML.');
     $this->assertRaw('<juicebox gallerywidth="100%" galleryheight="100%" backgroundcolor="#222222" textcolor="rgba(255,255,255,1)" thumbframecolor="rgba(255,255,255,.5)" showopenbutton="TRUE" showexpandbutton="TRUE" showthumbsbutton="TRUE" usethumbdots="FALSE" usefullscreenexpand="FALSE">', 'Expected default configuration options set in XML.');
 }
开发者ID:pulibrary,项目名称:recap,代码行数:27,代码来源:JuiceboxFileCase.php

示例11: processUserConf

 /**
  * Processes raw profile configuration of a user.
  */
 public static function processUserConf(array $conf, AccountProxyInterface $user)
 {
     // Convert MB to bytes
     $conf['maxsize'] *= 1048576;
     $conf['quota'] *= 1048576;
     // Set root uri and url
     $conf['root_uri'] = $conf['scheme'] . '://';
     // file_create_url requires a filepath for some schemes like private://
     $conf['root_url'] = preg_replace('@/(?:%2E|\\.)$@i', '', file_create_url($conf['root_uri'] . '.'));
     // Convert to relative
     if (!\Drupal::config('imce.settings')->get('abs_urls')) {
         $conf['root_url'] = file_url_transform_relative($conf['root_url']);
     }
     $conf['token'] = $user->isAnonymous() ? 'anon' : \Drupal::csrfToken()->get('imce');
     // Process folders
     $conf['folders'] = static::processUserFolders($conf['folders'], $user);
     // Call plugin processors
     \Drupal::service('plugin.manager.imce.plugin')->processUserConf($conf, $user);
     return $conf;
 }
开发者ID:aakb,项目名称:cfia,代码行数:23,代码来源:Imce.php

示例12: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $response = new AjaxResponse();
     // Convert any uploaded files from the FID values to data-editor-file-uuid
     // attributes.
     if (!empty($form_state['values']['fid'][0])) {
         $file = file_load($form_state['values']['fid'][0]);
         $file_url = file_create_url($file->getFileUri());
         // Transform absolute image URLs to relative image URLs: prevent problems
         // on multisite set-ups and prevent mixed content errors.
         $file_url = file_url_transform_relative($file_url);
         $form_state['values']['attributes']['src'] = $file_url;
         $form_state['values']['attributes']['data-editor-file-uuid'] = $file->uuid();
     }
     if (form_get_errors($form_state)) {
         unset($form['#prefix'], $form['#suffix']);
         $status_messages = array('#theme' => 'status_messages');
         $output = drupal_render($form);
         $output = '<div>' . drupal_render($status_messages) . $output . '</div>';
         $response->addCommand(new HtmlCommand('#editor-image-dialog-form', $output));
     } else {
         $response->addCommand(new EditorDialogSave($form_state['values']));
         $response->addCommand(new CloseModalDialogCommand());
     }
     return $response;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:29,代码来源:EditorImageDialog.php

示例13: testImageStyleTheme

 /**
  * Tests usage of the image style theme function.
  */
 function testImageStyleTheme()
 {
     /** @var \Drupal\Core\Render\RendererInterface $renderer */
     $renderer = $this->container->get('renderer');
     // Create an image.
     $files = $this->drupalGetTestFiles('image');
     $file = reset($files);
     $original_uri = file_unmanaged_copy($file->uri, 'public://', FILE_EXISTS_RENAME);
     // Create a style.
     $style = ImageStyle::create(array('name' => 'image_test', 'label' => 'Test'));
     $style->save();
     $url = file_url_transform_relative($style->buildUrl($original_uri));
     // Create the base element that we'll use in the tests below.
     $base_element = array('#theme' => 'image_style', '#style_name' => 'image_test', '#uri' => $original_uri);
     $element = $base_element;
     $this->setRawContent($renderer->renderRoot($element));
     $elements = $this->xpath('//img[@class="image-style-image-test" and @src=:url and @alt=""]', array(':url' => $url));
     $this->assertEqual(count($elements), 1, 'theme_image_style() renders an image correctly.');
     // Test using theme_image_style() with a NULL value for the alt option.
     $element = $base_element;
     $element['#alt'] = NULL;
     $this->setRawContent($renderer->renderRoot($element));
     $elements = $this->xpath('//img[@class="image-style-image-test" and @src=:url]', array(':url' => $url));
     $this->assertEqual(count($elements), 1, 'theme_image_style() renders an image correctly with a NULL value for the alt option.');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:28,代码来源:ImageThemeFunctionTest.php

示例14: getDefaultContentsCssConfig

 protected function getDefaultContentsCssConfig()
 {
     return array(file_url_transform_relative(file_create_url('core/modules/ckeditor/css/ckeditor-iframe.css')), file_url_transform_relative(file_create_url('core/modules/system/css/components/align.module.css')));
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:4,代码来源:CKEditorTest.php

示例15: _testColor

 /**
  * Tests the Color module functionality using the given theme.
  *
  * @param string $theme
  *   The machine name of the theme being tested.
  * @param array $test_values
  *   An associative array of test settings (i.e. 'Main background', 'Text
  *   color', 'Color set', etc) for the theme which being tested.
  */
 function _testColor($theme, $test_values)
 {
     $this->config('system.theme')->set('default', $theme)->save();
     $settings_path = 'admin/appearance/settings/' . $theme;
     $this->drupalLogin($this->bigUser);
     $this->drupalGet($settings_path);
     $this->assertResponse(200);
     $this->assertUniqueText('Color set');
     $edit['scheme'] = '';
     $edit[$test_values['palette_input']] = '#123456';
     $this->drupalPostForm($settings_path, $edit, t('Save configuration'));
     $this->drupalGet('<front>');
     $stylesheets = $this->config('color.theme.' . $theme)->get('stylesheets');
     foreach ($stylesheets as $stylesheet) {
         $this->assertPattern('|' . file_url_transform_relative(file_create_url($stylesheet)) . '|', 'Make sure the color stylesheet is included in the content. (' . $theme . ')');
         $stylesheet_content = join("\n", file($stylesheet));
         $this->assertTrue(strpos($stylesheet_content, 'color: #123456') !== FALSE, 'Make sure the color we changed is in the color stylesheet. (' . $theme . ')');
     }
     $this->drupalGet($settings_path);
     $this->assertResponse(200);
     $edit['scheme'] = $test_values['scheme'];
     $this->drupalPostForm($settings_path, $edit, t('Save configuration'));
     $this->drupalGet('<front>');
     $stylesheets = $this->config('color.theme.' . $theme)->get('stylesheets');
     foreach ($stylesheets as $stylesheet) {
         $stylesheet_content = join("\n", file($stylesheet));
         $this->assertTrue(strpos($stylesheet_content, 'color: ' . $test_values['scheme_color']) !== FALSE, 'Make sure the color we changed is in the color stylesheet. (' . $theme . ')');
     }
     // Test with aggregated CSS turned on.
     $config = $this->config('system.performance');
     $config->set('css.preprocess', 1);
     $config->save();
     $this->drupalGet('<front>');
     $stylesheets = \Drupal::state()->get('drupal_css_cache_files') ?: array();
     $stylesheet_content = '';
     foreach ($stylesheets as $uri) {
         $stylesheet_content .= join("\n", file(drupal_realpath($uri)));
     }
     $this->assertTrue(strpos($stylesheet_content, 'public://') === FALSE, 'Make sure the color paths have been translated to local paths. (' . $theme . ')');
     $config->set('css.preprocess', 0);
     $config->save();
 }
开发者ID:318io,项目名称:318-io,代码行数:51,代码来源:ColorTest.php


注:本文中的file_url_transform_relative函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。