public function TextimageTest::testTextimage in Textimage 7.2
Same name and namespace in other branches
- 7.3 tests/textimage.test \TextimageTest::testTextimage()
Test functionality of the module.
File
- tests/
textimage.test, line 46 - Textimage - web test case script.
Class
- TextimageTest
- Functional tests for Textimage.
Code
public function testTextimage() {
$stream_wrapper = file_stream_wrapper_get_instance_by_scheme(variable_get('file_default_scheme', 'public'));
$directory_path = $stream_wrapper
->getDirectoryPath();
// Create a user and log it in.
$this->admin_user = $this
->drupalCreateUser(array(
'administer site configuration',
'create textimages',
));
$this
->drupalLogin($this->admin_user);
// Change the font directory.
$edit = array(
'textimage_fonts_path' => drupal_get_path('module', 'textimage') . '/tests/fonts',
);
$this
->drupalPost($this->textimageAdmin . '/settings', $edit, t('Save configuration'));
// Create a test preset.
$edit = array(
'name' => 'textimage_test',
'description' => 'textimage_test description',
'settings[font][file]' => 'OldStandard-Regular.ttf',
'settings[font][size]' => 20,
'settings[text][maximum_width]' => 200,
'settings[text][fixed_width]' => TRUE,
);
$this
->drupalPost($this->textimageAdmin . '/preset/new', $edit, t('Save preset'));
// Generate a few derivative images via theme.
$textimage = theme('textimage_image', array(
'preset' => 1,
'text' => 'preview text image',
));
$textimage = theme('textimage_image', array(
'preset' => 1,
'text' => 'Предварительный просмотр текста',
));
$textimage = theme('textimage_image', array(
'preset' => 1,
'text' => 'προεπισκόπηση της εικόνας κείμενο',
));
// Check files were generated.
$files_count = 0;
$dir = dir($directory_path . '/textimage/1');
if ($dir) {
while (($entry = $dir
->read()) !== FALSE) {
if ($entry == '.' || $entry == '..') {
continue;
}
$files_count++;
}
$dir
->close();
}
$this
->assertTrue($files_count == 3, t('Textimage generation via theme.'));
}