public function JSDelivrTest::test_request in Libraries CDN API 7
@covers ::request()
File
- tests/
src/ Plugin/ LibrariesCDN/ JSDelivrTest.php, line 166 - Contains \Drupal\Tests\Libraries_cdn\Plugin\LibrariesCDN\JSDelivrTest.
Class
- JSDelivrTest
- @coversDefaultClass \Drupal\libraries_cdn\Plugin\LibrariesCDN\JSDelivr
Namespace
Drupal\Tests\libraries_cdn\Plugin\LibrariesCDNCode
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']);
}