Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeryan created an issue. See original summary.

mikeryan’s picture

Component: API » Tests
alex_sansom’s picture

Version: 8.x-2.x-dev » 8.x-4.x-dev
Status: Active » Needs review
FileSize
8.31 KB

Attaching initial http data fetcher tests .patch file.

heddn’s picture

Status: Needs review » Needs work
+++ b/tests/src/Unit/data_fetcher/HttpTest.php
@@ -0,0 +1,165 @@
+    $plugin = new TestHttp($migration_config, $this->dataFetcherPluginId, $this->pluginDefinition);
...
+    $plugin = new TestHttp($migration_config, $this->dataFetcherPluginId, $this->pluginDefinition);
...
+    $plugin = new TestHttp($migration_config, $this->dataFetcherPluginId, $this->pluginDefinition);
+    $plugin->mockHttpClient([[403, 'text/html', 'Forbidden']], $this->basicAuthenticator);
...
+    $plugin = new TestHttp($migration_config, $this->dataFetcherPluginId, $this->pluginDefinition);

+++ b/tests/src/Unit/data_fetcher/TestHttp.php
@@ -0,0 +1,88 @@
+ * @see https://www.drupal.org/docs/8/phpunit/unit-testing-more-complicated-drupal-classes
...
+class TestHttp extends Http {

Can't we mock the whole HTTP request/response with something less than a full object? There seems to be some idea of that possibility over in http://guzzle.readthedocs.io/en/latest/testing.html

heddn’s picture

Status: Needs work » Needs review
FileSize
7.27 KB
7.5 KB

Some minor changes. Hopefully this makes things more understandable.

  • heddn committed 5e1715b on 8.x-4.x
    Issue #2710311 by heddn, alex_sansom: Add tests for Http fetcher
    
heddn’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.