You are here

public function MetatagTestBase::generateImageFile in Metatag 7

Create an image file object 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

object The file object for the generated image.

4 calls to MetatagTestBase::generateImageFile()
MetatagCoreImageTest::testNodeFieldDefault in tests/MetatagCoreImageTest.test
Confirm that a default value on an image field will be output correctly.
MetatagCoreImageTest::testNodeFieldValue in tests/MetatagCoreImageTest.test
Confirm that a file on an image field will be output correctly.
MetatagCoreImageTest::testNodeFieldValueMultiple in tests/MetatagCoreImageTest.test
Confirm that multiple tags will be output with tags that allow multiples.
MetatagCoreImageTest::testNodeFieldValueNotMultiple in tests/MetatagCoreImageTest.test
Confirm that only a single meta tag will be output with non-multiple tags.

File

tests/MetatagTestBase.test, line 740
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 generateImageFile($image_size = '200x200', $format = 'png') {

  // Generate a test image.
  $image_uri = $this
    ->generateImage();

  // Create a file object for this image.
  $file = new StdClass();
  $file->fid = NULL;
  $file->uid = 1;
  $file->uri = $image_uri;
  $file->filemime = file_get_mimetype($image_uri);
  $file->filesize = filesize($image_uri);
  $file->status = 1;
  $file->timestamp = filemtime($image_uri);
  $saved_file = file_save($file);
  return $saved_file;
}