You are here

thunder_test_mock_request.install in Thunder 6.1.x

Install functions for thunder_test_mock_request.

File

tests/modules/thunder_test_mock_request/thunder_test_mock_request.install
View source
<?php

/**
 * @file
 * Install functions for thunder_test_mock_request.
 */
use Drupal\thunder_test_mock_request\MockHttpClientMiddleware;

/**
 * Implements hook_install().
 */
function thunder_test_mock_request_install() {
  $fixturesDirectory = drupal_get_path('profile', 'thunder') . '/tests/fixtures/oembed';
  MockHttpClientMiddleware::addUrlResponse('https://oembed.com/providers.json', file_get_contents($fixturesDirectory . '/providers.json'), [
    'Content-Type' => 'application/json',
  ]);
  MockHttpClientMiddleware::addUrlResponse('https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=PWjcqE3QKBg', file_get_contents($fixturesDirectory . '/youtube.json'), [
    'Content-Type' => 'application/json',
  ]);
  MockHttpClientMiddleware::addUrlResponse('https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=PWjcqE3QKBg&maxwidth=241&maxheight=138', file_get_contents($fixturesDirectory . '/youtube.json'), [
    'Content-Type' => 'application/json',
  ]);
  MockHttpClientMiddleware::addUrlResponse('https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=PWjcqE3QKBg&maxwidth=854&maxheight=480', file_get_contents($fixturesDirectory . '/youtube.json'), [
    'Content-Type' => 'application/json',
  ]);
  MockHttpClientMiddleware::addUrlResponse('https://publish.twitter.com/oembed?url=https://twitter.com/ThunderCoreTeam/status/776417570756976640', file_get_contents($fixturesDirectory . '/twitter.json'), [
    'Content-Type' => 'application/json',
  ]);
  MockHttpClientMiddleware::addUrlResponse('https://graph.facebook.com/v8.0/instagram_oembed?url=https://www.instagram.com/p/B2huuS8AQVq/&access_token=123%7C123&omitscript=1', file_get_contents($fixturesDirectory . '/instagram.json'), [
    'Content-Type' => 'application/json',
  ]);
}

Functions