I've created tests for Simpletest for Image Attach contrib module.
There is a problem: Can't upload attached images
There are 2 patches in Fix bugs in hook_nodeapi for image_attach:
The first patch works, the second fails the test.
Forgot the test.
still haven't gotten the test attached :(
Strange enough. I cannpt attach the test file. So I put it here.
class ImageAttachTest extends DrupalTestCase { protected $web_user; protected $image; function get_info() { return array('name' => t('Image Attach tests'), 'desc' => t('Test Image Attach module functionality.'), 'group' => 'Image'); } function setUp() { parent::setUp(); // User to create images and pages. $this->web_user = $this->drupalCreateUserRolePerm(array('create images', 'view original images', 'edit own images', 'edit images', 'create page content', 'edit own page content')); $this->drupalGet('logout'); $this->drupalLoginUser($this->web_user); // Uploadable image $this->image = 'misc' . DIRECTORY_SEPARATOR . 'druplicon.png'; // Enable attach images to Page. $this->drupalVariableSet('image_attach_page', 1); $this->drupalVariableSet('image_attach_size_body_page', 'thumbnail'); $this->drupalVariableSet('image_attach_size_teaser_page', 'thumbnail'); $this->drupalVariableSet('image_attach_weight_body_page', 0); $this->drupalVariableSet('image_attach_weight_teaser_page', 0); } function testAttachExistingImage() { $this->drupalVariableSet('image_attach_existing', 1); // Create an image. $edit_image = array( 'title' => $this->randomName(), 'body' => $this->randomName(), 'files[image]' => realpath($this->image), ); $this->drupalPost('node/add/image', $edit_image, 'Save'); $this->assertWantedRaw(t('@type %title has been created.', array('@type' => 'Image', '%title' => $edit_image['title'])), 'Image created. %s'); $node_image = node_load(array('title' => $edit_image['title'])); $this->assertNotNull($node_image, 'Image found in database. %s'); // Create a Page $edit_page = array( 'title' => $this->randomName(), 'body' => $this->randomName(), 'iid' => $node_image->nid, ); $this->drupalPost('node/add/page', $edit_page, 'Save'); $this->assertWantedRaw(t('!post %title has been created.', array ('!post' => 'Page', '%title' => $edit_page['title'])), 'Page created'); $node_page = node_load(array('title' => $edit_page['title'])); $this->assertNotNull($node_page, 'Page found in database.'); // Display an image. $this->assertWantedPattern('|<img[^>]+?' . $node_image->images['thumbnail'] . '[^>]+?'.'>|', $this->drupalGetContent(), 'Image is on the page. %s'); $this->assertTrue(file_exists($node_image->images['thumbnail']), 'Image thumbnail exists. %s'); } function testAttachUploadImage() { // Create a Page $edit_page = array( 'title' => $this->randomName(), 'body' => $this->randomName(), 'files[image]' => realpath($this->image), 'image_title' => $this->randomName(), ); $this->drupalPost('node/add/page', $edit_page, 'Save'); $this->assertWantedRaw(t('!post %title has been created.', array ('!post' => 'Page', '%title' => $edit_page['title'])), 'Page created'); $node_page = node_load(array('title' => $edit_page['title'])); $this->assertNotNull($node_page, 'Page found in database.'); $node_image = node_load($node_page->iid); $this->assertNotNull($node_image, 'Image found in database.'); // Display an image. $this->assertWantedPattern('|<img[^>]+?' . $node_image->images['thumbnail'] . '[^>]+?'.'>|', $this->drupalGetContent(), 'Image is on the page. %s'); $this->assertTrue(file_exists($node_image->images['thumbnail']), 'Image thumbnail exists. %s'); } }
Tried running that and got: Image thumbnail exists. Expected true, got [Boolean: false] at [/Users/amorton/Sites/d6/sites/all/modules/image/tests/image_attach.test line 77]
Image thumbnail exists. Expected true, got [Boolean: false] at [/Users/amorton/Sites/d6/sites/all/modules/image/tests/image_attach.test line 77]
Bummer. I would have loved to see some tests for Image Attach module.
Sorry, without further information this issue can only be marked as won't fix.
vladimir, what does drewish's output mean?
Comments
Comment #1
vladimir.dolgopolov commentedThere is a problem: Can't upload attached images
There are 2 patches in Fix bugs in hook_nodeapi for image_attach:
The first patch works, the second fails the test.
Comment #2
vladimir.dolgopolov commentedForgot the test.
Comment #3
drewish commentedstill haven't gotten the test attached :(
Comment #4
vladimir.dolgopolov commentedStrange enough. I cannpt attach the test file.
So I put it here.
Comment #5
drewish commentedTried running that and got:
Image thumbnail exists. Expected true, got [Boolean: false] at [/Users/amorton/Sites/d6/sites/all/modules/image/tests/image_attach.test line 77]Comment #6
sunBummer. I would have loved to see some tests for Image Attach module.
Sorry, without further information this issue can only be marked as won't fix.
Comment #7
random_ commentedvladimir, what does drewish's output mean?