You are here

function ImagecacheExternalTestCase::addNodeImage in Imagecache External 7.2

Same name and namespace in other branches
  1. 8 imagecache_external.test \ImagecacheExternalTestCase::addNodeImage()

Set a to a node.

Parameters

$image: A file object representing the image to upload.

$field_name: Name of the image field the image should be attached to.

$type: The type of node to create.

1 call to ImagecacheExternalTestCase::addNodeImage()
ImagecacheExternalTestCase::testCachingExternalImage in ./imagecache_external.test
Test caching an external image.

File

./imagecache_external.test, line 113
Tests for Imagecache External.

Class

ImagecacheExternalTestCase
Tests the functions for working with public/private file schemes.

Code

function addNodeImage($image_uri, $field_name, $type) {
  $edit = array(
    'title' => $this
      ->randomName(),
    $field_name . '[' . LANGUAGE_NONE . '][0][value]' => $image_uri,
  );
  $this
    ->drupalPost('node/add/' . $type, $edit, t('Save'));

  // Retrieve ID of the newly created node from the current URL.
  $matches = array();
  preg_match('/node\\/([0-9]+)/', $this
    ->getUrl(), $matches);
  return isset($matches[1]) ? $matches[1] : FALSE;
}