Skip to content
Snippets Groups Projects
Select Git revision
  • 8.9.x
  • 11.x default protected
  • 11.2.x protected
  • 10.5.x protected
  • 10.6.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.2 protected
  • 11.2.3 protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
40 results

DrupalSelenium2DriverTest.php

Blame
  • catch's avatar
    Issue #3082655 by Wim Leers, alexpott, iyyappan.govind, dww, lauriii: Specify...
    catch authored
    Issue #3082655 by Wim Leers, alexpott, iyyappan.govind, dww, lauriii: Specify the $defaultTheme property in all functional tests
    19aae044
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    DrupalSelenium2DriverTest.php 2.04 KiB
    <?php
    
    namespace Drupal\FunctionalJavascriptTests\Tests;
    
    use Drupal\entity_test\Entity\EntityTest;
    use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
    use Drupal\Tests\file\Functional\FileFieldCreationTrait;
    use Drupal\Tests\TestFileCreationTrait;
    
    /**
     * Tests the DrupalSelenium2Driver methods.
     *
     * @coversDefaultClass \Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver
     * @group javascript
     */
    class DrupalSelenium2DriverTest extends WebDriverTestBase {
    
      use TestFileCreationTrait;
      use FileFieldCreationTrait;
    
      /**
       * {@inheritdoc}
       */
      protected static $modules = ['file', 'field_ui', 'entity_test'];
    
      /**
       * {@inheritdoc}
       */
      protected $defaultTheme = 'stark';
    
      /**
       * {@inheritdoc}
       */
      protected function setUp() {
        parent::setUp();
        $storage_settings = ['cardinality' => 3];
        $this->createFileField('field_file', 'entity_test', 'entity_test', $storage_settings);
        $this->drupalLogin($this->drupalCreateUser([
          'administer entity_test content',
          'access content',
        ]));
      }
    
      /**
       * Tests uploading remote files.
       */
      public function testGetRemoteFilePath() {
        $web_driver = $this->getSession()->getDriver();
        $file_system = \Drupal::service('file_system');
        $entity = EntityTest::create();
        $entity->save();
    
        $files = array_slice($this->getTestFiles('text'), 0, 3);
        $real_paths = [];
        foreach ($files as $file) {
          $real_paths[] = $file_system->realpath($file->uri);
        }
        $remote_paths = [];
        foreach ($real_paths as $path) {
          $remote_paths[] = $web_driver->uploadFileAndGetRemoteFilePath($path);
        }
    
        // Tests that uploading multiple remote files works with remote path.
        $this->drupalGet($entity->toUrl('edit-form'));
        $multiple_field = $this->xpath('//input[@multiple]')[0];
        $multiple_field->setValue(implode("\n", $remote_paths));
        $this->assertSession()->assertWaitOnAjaxRequest();
        $this->getSession()->getPage()->findButton('Save')->click();
        $entity = EntityTest::load($entity->id());
        $this->assertCount(3, $entity->field_file);
      }
    
    }