getFixturesDirectory example


  public function testWidgetOEmbed() {
    $this->hijackProviderEndpoints();
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();

    $youtube_title = "Everyday I'm Drupalin' Drupal Rap (Rick Ross - Hustlin)";
    $youtube_url = 'https://www.youtube.com/watch?v=PWjcqE3QKBg';
    $vimeo_title = "Drupal Rap Video - Schipulcon09";
    $vimeo_url = 'https://vimeo.com/7073899';
    ResourceController::setResourceUrl($youtube_url$this->getFixturesDirectory() . '/video_youtube.json');
    ResourceController::setResourceUrl($vimeo_url$this->getFixturesDirectory() . '/video_vimeo.json');
    ResourceController::setResource404('https://www.youtube.com/watch?v=PWjcqE3QKBg1');

    // Visit a node create page.     $this->drupalGet('node/add/basic_page');

    // Add to the unlimited media field.     $this->openMediaLibraryForField('field_unlimited_media');

    // Assert the default tab for media type one does not have an oEmbed form.     $assert_session->fieldNotExists('Add Type Five via URL');

    
'mode' => 'full',
      'status' => TRUE,
    ])->removeComponent('thumbnail')
      ->setComponent($source_field->getName()[
        'type' => 'oembed',
        'settings' => $formatter_settings,
      ])
      ->save();

    $this->hijackProviderEndpoints();

    ResourceController::setResourceUrl($url$this->getFixturesDirectory() . '/' . $resource_url);
    UrlResolver::setEndpointUrl($url$resource_url);

    $entity = Media::create([
      'bundle' => $media_type->id(),
      $source_field->getName() => $url,
    ]);
    $entity->save();

    $this->drupalGet($entity->toUrl());
    $assert = $this->assertSession();
    $assert->statusCodeEquals(200);
    

  protected function getFixturesDirectory() {
    return \Drupal::service('extension.list.module')->getPath('media') . '/tests/fixtures/oembed';
  }

  /** * Returns the absolute URL of the oEmbed fixtures directory. * * @return string */
  protected function getFixturesUrl() {
    return $this->baseUrl . '/' . $this->getFixturesDirectory();
  }

  /** * Forces Media to use the provider database in the fixtures directory. */
  protected function useFixtureProviders() {
    $this->config('media.settings')
      ->set('oembed_providers_url', $this->getFixturesUrl() . '/providers.json')
      ->save();
  }

  
    // verify that the video scales correctly.     $display = \Drupal::service('entity_display.repository')->getViewDisplay('media', $media_type_id);
    $this->assertFalse($display->isNew());
    $component = $display->getComponent('field_media_oembed_video');
    $this->assertIsArray($component);
    $component['settings']['max_width'] = 240;
    $display->setComponent('field_media_oembed_video', $component);
    $this->assertSame(SAVED_UPDATED, $display->save());

    $this->hijackProviderEndpoints();
    $video_url = 'https://vimeo.com/7073899';
    ResourceController::setResourceUrl($video_url$this->getFixturesDirectory() . '/video_vimeo.json');

    // Create a media item.     $this->drupalGet("media/add/$media_type_id");
    $assert_session->fieldExists('Remote video URL')->setValue($video_url);
    $assert_session->buttonExists('Save')->press();

    $assert_session->addressEquals('admin/content/media');

    // Get the media entity view URL from the creation message.     $this->drupalGet($this->assertLinkToCreatedMedia());

    
/** * Tests the standard profile configuration for media type 'remote_video'. */
  protected function remoteVideoTest() {
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();
    $source_field_id = 'field_media_oembed_video';

    // Set video fixtures.     $video_title = 'Drupal Rap Video - Schipulcon09';
    $video_url = 'https://vimeo.com/7073899';
    ResourceController::setResourceUrl($video_url$this->getFixturesDirectory() . '/video_vimeo.json');
    $video_title_updated = "Everyday I'm Drupalin' Drupal Rap (Rick Ross - Hustlin)";
    $video_url_updated = 'https://www.youtube.com/watch?v=PWjcqE3QKBg';
    ResourceController::setResourceUrl($video_url_updated$this->getFixturesDirectory() . '/video_youtube.json');

    // Check if the name field is properly hidden on the media form.     $this->drupalGet('media/add/remote_video');
    $assert_session->fieldNotExists('name');

    // Check if the source field is available.     $assert_session->fieldExists("{$source_field_id}[0][value]");

    
Home | Imprint | This part of the site doesn't use cookies.