public function IconFileUsageTest::testEmbedButtonIcon in Entity Embed 7
Same name and namespace in other branches
- 7.3 entity_embed.test \IconFileUsageTest::testEmbedButtonIcon()
- 7.2 entity_embed.test \IconFileUsageTest::testEmbedButtonIcon()
Tests the embed_button and file usage integration.
File
- ./
entity_embed.test, line 497 - Test integration for the entity_embed module.
Class
- IconFileUsageTest
- Tests embed button icon file usage.
Code
public function testEmbedButtonIcon() {
$file1 = file_save_data(file_get_contents('misc/druplicon.png'));
$file1->status = 0;
file_save($file1);
$file2 = file_save_data(file_get_contents('misc/druplicon.png'));
$file1->status = 0;
file_save($file2);
$button = entity_embed_embed_button_new();
$button->admin_title = 'Testing embed button instance';
$button->name = 'test_button';
$button->entity_type = 'node';
$button->entity_type_bundles = array(
'page',
);
$button->button_icon_fid = $file1->fid;
$button->display_plugins = array(
'default',
);
// Verify that saving a new button makes the icon file permanent.
entity_embed_embed_button_save($button);
$this
->assertTrue(file_load($file1->fid)->status == FILE_STATUS_PERMANENT);
// Verify that updating an existing button makes the icon file permanent.
$button->button_icon_fid = $file2->fid;
entity_embed_embed_button_save($button);
// Verify that replacing an existing button makes the new icon file
// permanent and the old icon file temporary.
$this
->assertTrue(file_load($file1->fid)->status == 0);
$this
->assertTrue(file_load($file2->fid)->status == FILE_STATUS_PERMANENT);
// Verify that deleting a button makes the icon file temporary.
entity_embed_embed_button_delete($button);
$this
->assertTrue(file_load($file2->fid)->status == 0);
}