Esempio n. 1
0
 /**
  * Tests the embed_button and file usage integration.
  */
 public function testEmbedButtonIconUsage()
 {
     $this->enableModules(['system', 'user', 'file']);
     $this->installSchema('file', ['file_usage']);
     $this->installConfig(['system']);
     $this->installEntitySchema('user');
     $this->installEntitySchema('file');
     $this->installEntitySchema('embed_button');
     $file1 = file_save_data(file_get_contents('core/misc/druplicon.png'));
     $file1->setTemporary();
     $file1->save();
     $file2 = file_save_data(file_get_contents('core/misc/druplicon.png'));
     $file2->setTemporary();
     $file2->save();
     $button = array('id' => 'test_button', 'label' => 'Testing embed button instance', 'type_id' => 'embed_test_default', 'icon_uuid' => $file1->uuid());
     $entity = EmbedButton::create($button);
     $entity->save();
     $this->assertTrue(File::load($file1->id())->isPermanent());
     // Delete the icon from the button.
     $entity->icon_uuid = NULL;
     $entity->save();
     $this->assertTrue(File::load($file1->id())->isTemporary());
     $entity->icon_uuid = $file1->uuid();
     $entity->save();
     $this->assertTrue(File::load($file1->id())->isPermanent());
     $entity->icon_uuid = $file2->uuid();
     $entity->save();
     $this->assertTrue(File::load($file1->id())->isTemporary());
     $this->assertTrue(File::load($file2->id())->isPermanent());
     $entity->delete();
     $this->assertTrue(File::load($file2->id())->isTemporary());
 }
 /**
  * {@inheritdoc}
  */
 public function getButtons()
 {
     $buttons = array();
     if ($ids = $this->embedButtonQuery->execute()) {
         $embed_buttons = EmbedButton::loadMultiple($ids);
         foreach ($embed_buttons as $embed_button) {
             $buttons[$embed_button->id()] = $this->getButton($embed_button);
         }
     }
     return $buttons;
 }
 /**
  * Tests the entity browser integration.
  */
 public function testEntityEmbedEntityBrowserIntegration()
 {
     $this->getEmbedDialog('custom_format', 'node');
     $this->assertResponse(200, 'Embed dialog is accessible with custom filter format and default embed button.');
     // Verify that an autocomplete field is available by default.
     $this->assertFieldByName('attributes[data-entity-id]', '', 'Entity ID/UUID field is present.');
     $this->assertNoText('Select entities to embed', 'Entity browser button is not present.');
     // Set up entity browser.
     $entity_browser = EntityBrowser::create(["name" => 'entity_embed_entity_browser_test', "label" => 'Test Entity Browser for Entity Embed', "display" => 'modal', "display_configuration" => ['width' => '650', 'height' => '500', 'link_text' => 'Select entities to embed'], "selection_display" => 'no_display', "selection_display_configuration" => [], "widget_selector" => 'single', "widget_selector_configuration" => [], "widgets" => []]);
     $entity_browser->save();
     // Enable entity browser for the default entity embed button.
     $embed_button = EmbedButton::load('node');
     $embed_button->type_settings['entity_browser'] = 'entity_embed_entity_browser_test';
     $embed_button->save();
     $this->getEmbedDialog('custom_format', 'node');
     $this->assertResponse(200, 'Embed dialog is accessible with custom filter format and default embed button.');
     // Verify that the autocomplete field is replaced by an entity browser
     // button.
     $this->assertNoFieldByName('attributes[data-entity-id]', '', 'Entity ID/UUID field is present.');
     $this->assertText('Select entities to embed', 'Entity browser button is present.');
 }