You are here

public function HttpTest::testFetchHttp500Error in Migrate Plus 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/Unit/data_fetcher/HttpTest.php \Drupal\Tests\migrate_plus\Unit\data_fetcher\HttpTest::testFetchHttp500Error()

Test 'http' data fetcher (with auth) dies as expected when server down.

File

tests/src/Unit/data_fetcher/HttpTest.php, line 161
PHPUnit tests for the Migrate Plus Http 'data fetcher' plugin.

Class

HttpTest
@coversDefaultClass \Drupal\migrate_plus\Plugin\migrate_plus\data_fetcher\Http

Namespace

Drupal\Tests\migrate_plus\Unit\data_fetcher

Code

public function testFetchHttp500Error() {
  $migration_config = $this->migrationConfiguration + $this->specificMigrationConfig;
  $plugin = new TestHttp($migration_config, $this->dataFetcherPluginId, $this->pluginDefinition);
  $plugin
    ->mockHttpClient([
    [
      500,
      'text/html',
      'Internal Server Error',
    ],
  ], $this->basicAuthenticator);
  $this
    ->setExpectedException(MigrateException::class, 'GET http://example.org/http_fetcher_test` resulted in a `500 Internal Server Error');
  $plugin
    ->getResponseContent($migration_config['urls'][0]);
}