public function ServicesSpycLibraryTests::testMakeFileLinkValid in Services 7.3
Testing whether link in make file is valid.
File
- tests/
unit/ ServicesSpycLibraryTests.test, line 24
Class
- ServicesSpycLibraryTests
- Run test cases to check whether Spyc library can be downloaded.
Code
public function testMakeFileLinkValid() {
$makefile_path = drupal_get_path('module', 'services') . '/services.make.example';
$makefile_content = file_get_contents($makefile_path);
// libraries[spyc][download][url] = "https://raw.github.com/mustangostang/spyc/79f61969f63ee77e0d9460bc254a27a671b445f3/spyc.php"
$matches = array();
preg_match('/libraries\\[spyc\\]\\[download\\]\\[url\\] = (.*)/', $makefile_content, $matches);
$spyc_library_url = $matches[1];
$spyc_library_content = file_get_contents($spyc_library_url);
$search_keywords = array(
'<?php',
'Spyc',
'YAML',
);
$spyc_library_valid = TRUE;
foreach ($search_keywords as $keyword) {
$spyc_library_valid = $spyc_library_valid && strpos($spyc_library_content, $keyword) !== FALSE;
}
$this
->assertTrue($spyc_library_valid, 'Spyc library can be downloaded from make file.');
}