public function PDFToImageTest::testAttachingPdf in PDF to ImageField 7.3
Save a document with an attached PDF, check that the image was generated.
File
- tests/
pdf_to_image.test, line 54 - Test the file attachment and process.
Class
- PDFToImageTest
- Test attaching a PDF.
Code
public function testAttachingPdf() {
$langcode = LANGUAGE_NONE;
$test_file = $this
->getTestFile('text');
// Create a new node with the uploaded file.
$nid = $this
->uploadNodeFile($test_file, $this->fieldName, $this->typeName);
$this
->assertTrue($nid !== FALSE, format_string('Created a new @type_name with @test_file as an uploaded @field_name', array(
'@test_file' => $test_file->uri,
'@field_name' => $this->fieldName,
'@type_name' => $this->typeName,
)));
// Inspect the saved fields.
$node = node_load($nid, NULL, TRUE);
$node_file = (object) $node->{$this->fieldName}[$langcode][0];
$node_image = (object) $node->{$this->imageFieldName}[$langcode][0];
$message = format_string('File %file exists after uploading to %field_name.', array(
'%file' => $node_file->uri,
'%field_name' => $this->fieldName,
));
$this
->assertTrue(is_file($node_file->uri), $message);
// After saving, there should also now be an attached image.
$message = format_string('Generated Image preview %file exists in %image_field_name.', array(
'%file' => $node_image->uri,
'%image_field_name' => $this->imageFieldName,
));
$this
->assertTrue(is_file($node_image->uri), $message);
}