You are here

public function CDNJSTest::test_request in Libraries CDN API 7

@covers ::request()

File

tests/src/Plugin/LibrariesCDN/CDNJSTest.php, line 184
Contains \Drupal\Tests\Libraries_cdn\Plugin\LibrariesCDN\CDNJSTest.

Class

CDNJSTest
@coversDefaultClass \Drupal\libraries_cdn\Plugin\LibrariesCDN\CDNJS

Namespace

Drupal\Tests\libraries_cdn\Plugin\LibrariesCDN

Code

public function test_request() {

  // Test 1
  $url = 'http://drupal.org/';
  $this->drupal7
    ->shouldReceive('drupal_http_request')
    ->with($url, array())
    ->andReturn(array(
    'code' => 200,
    'data' => 'it works',
  ));
  $request = $this->plugin
    ->request($url);
  $this
    ->assertEquals('it works', $request['data']);

  // Test 2
  $url = 'http://ThisUrlDoesntExists.org/';
  $this->drupal7
    ->shouldReceive('drupal_http_request')
    ->with($url, array())
    ->andReturn(array(
    'code' => 500,
  ));
  $request = $this->plugin
    ->request($url);
  $this
    ->assertEquals(500, $request['code']);
}