function ImageGalleryTest::testBasic in Image 7
Same name and namespace in other branches
- 6 contrib/image_gallery/tests/image_gallery.test \ImageGalleryTest::testBasic()
File
- contrib/image_gallery/tests/image_gallery.test, line 20
Class
- ImageGalleryTest
Code
function testBasic() {
$galleries_count = 2;
$images_count = 5;
$galleries = array();
$images = array();
$this
->drupalVariableSet('image_images_per_page', $images_count);
$vid = _image_gallery_get_vid();
for ($i = 0; $i < $galleries_count; $i++) {
$galleries[] = $this
->createGallery();
}
$images_misc = file_scan_directory('misc', '.png');
shuffle($images_misc);
$images_files = array_slice($images_misc, 0, $images_count);
for ($i = 0; $i < $images_count; $i++) {
$tid = $galleries[array_rand($galleries)];
$edit = array(
'taxonomy[' . $vid . ']' => $tid,
'files[image]' => realpath($images_files[$i]->filename),
);
$images[] = array(
'tid' => $tid,
'node' => $this
->createImage($edit),
);
}
foreach ($galleries as $tid) {
$this
->drupalGet('image/tid/' . $tid);
foreach ($images as $image) {
if ($image['tid'] == $tid) {
$this
->assertWantedRaw($image['node']->title, 'Gallery ' . $tid . ': image ' . $image['node']->title . ' displayed. %s');
}
else {
$this
->assertNoUnwantedRaw($image['node']->title, 'Gallery ' . $tid . ': image ' . $images['node']->title . ' not displayed. %s');
}
}
}
foreach ($galleries as $tid) {
taxonomy_del_term($tid);
}
}