You are here

public function MetatagTestBase::generateImage in Metatag 7

Create an image of a specific size & type.

Parameters

string $image_size: The size of the requested image in 'XxY' format; defaults to '200x200'.

string $format: The image format to use, defaults to 'png'.

Return value

string The URL to a public file.

7 calls to MetatagTestBase::generateImage()
MetatagCoreImageTest::testConfigAbsoluteURL in tests/MetatagCoreImageTest.test
Confirm images can be added to a global config with its absolute URL.
MetatagCoreImageTest::testConfigDrupalRelativeURL in tests/MetatagCoreImageTest.test
Confirm images can be added to a global config using its relative URL.
MetatagCoreImageTest::testConfigImageWithSpaceInURL in tests/MetatagCoreImageTest.test
Confirm images with a space in its URL will be handled properly.
MetatagCoreImageTest::testConfigInternalURL in tests/MetatagCoreImageTest.test
Confirm images can be added to a global config with its internal URI.
MetatagCoreImageTest::testConfigProtocolRelativeURL in tests/MetatagCoreImageTest.test
Confirm images can be added to a global config w its protocol-relative URL.

... See full list

File

tests/MetatagTestBase.test, line 712
A base class for the Metatag tests, provides shared methods.

Class

MetatagTestBase
A base class for the Metatag tests, provides shared methods.

Code

public function generateImage($image_size = '200x200', $format = 'png') {

  // Only proceed if the Devel Generate module is installed.
  if (module_exists('devel_generate')) {

    // Load the Devel Generate image generator logic.
    module_load_include('inc', 'devel_generate', 'image.devel_generate');
    $image_format = 'png';
    $image_size = '200x200';
    $temp_image = devel_generate_image($image_format, $image_size, $image_size);
    return file_unmanaged_move($temp_image, 'public://');
  }
  else {
    $this
      ->error('The Devel Generate module is not enabled, it must be added to the $modules array in the setUp() method for this test class.');
  }
}