diff -u b/tests/libraries.drush.test b/tests/libraries.drush.test --- b/tests/libraries.drush.test +++ b/tests/libraries.drush.test @@ -6,99 +6,100 @@ -/** - * Class LibrariesDrushTestCase. - */ -class LibrariesDrushTestCase extends DrupalWebTestCase { - - const TEST_MODULE = 'libraries_test_download'; - /** - * @var LibrariesManager - */ - private $manager; - /** - * @var string[] - */ - private $libraries = array(); - - /** - * {@inheritdoc} - */ - public static function getInfo() { - return array( - 'name' => 'Drush integration', - 'group' => 'Libraries API', - 'description' => 'Testing Drush integration.', - ); - } - - /** - * {@inheritdoc} - */ - public function setUp() { - $this->profile = drupal_get_profile(); +// Allow to run these tests only by Drush. Otherwise they are will not work +// because SimpleTest renames database connection and Drush cannot use it. +// Also, Drush functionality has been used. +if (function_exists('drush_mkdir')) { + /** + * Class LibrariesDrushTestCase. + */ + class LibrariesDrushTestCase extends DrupalWebTestCase { + + const TEST_MODULE = 'libraries_test_download'; + /** + * @var LibrariesManager + */ + private $manager; + /** + * @var string[] + */ + private $libraries = array(); + + /** + * {@inheritdoc} + */ + public static function getInfo() { + return array( + 'name' => 'Drush integration', + 'group' => 'Libraries API', + 'description' => 'Testing Drush integration.', + ); + } - parent::setUp(self::TEST_MODULE); + /** + * {@inheritdoc} + */ + public function setUp() { + $this->profile = drupal_get_profile(); - // Allow to run these tests only by Drush. Otherwise they are will not work - // because SimpleTest renames database connection and Drush cannot use it. - // Also, Drush functionality has been used. - $this->setup = function_exists('drush_mkdir'); - $this->manager = new LibrariesManager(); - $this->libraries = array_keys(module_invoke(self::TEST_MODULE, 'libraries_info')); - } + parent::setUp(self::TEST_MODULE); - /** - * {@inheritdoc} - */ - public function tearDown() { - parent::tearDown(); - $this->manager->uninstall(self::TEST_MODULE); - } - - /** - * Testing manual downloading. - * - * @param array $options - * Options for "libget" command. - */ - public function testManualDownloading(array $options = array()) { - foreach ($this->libraries as $library) { - $info = libraries_detect($library); - $this->assertFalse($info['installed']); - - $this->manager->download(array($library), $options); - drupal_flush_all_caches(); + $this->manager = new LibrariesManager(); + $this->libraries = array_keys(module_invoke(self::TEST_MODULE, 'libraries_info')); + } - $info = libraries_detect($library); - $this->assertTrue($info['installed']); + /** + * {@inheritdoc} + */ + public function tearDown() { + parent::tearDown(); + $this->manager->uninstall(self::TEST_MODULE); } - } - /** - * Testing manual downloading to sub-site. - * - * @param string $site - * Sub-site machine name. - */ - public function testDownloadingToSubSite($site = 'testing') { - $path = "sites/$site"; + /** + * Testing manual downloading. + * + * @param array $options + * Options for "libget" command. + */ + public function testManualDownloading(array $options = array()) { + foreach ($this->libraries as $library) { + $info = libraries_detect($library); + $this->assertFalse($info['installed']); + + $this->manager->download(array($library), $options); + drupal_flush_all_caches(); + + $info = libraries_detect($library); + $this->assertTrue($info['installed']); + } + } - $this->assertTrue(drush_mkdir($path)); - $this->assertTrue(file_unmanaged_copy('sites/default/settings.php', $path)); + /** + * Testing manual downloading to sub-site. + * + * @param string $site + * Sub-site machine name. + */ + public function testDownloadingToSubSite($site = 'testing') { + $path = "sites/$site"; + + $this->assertTrue(drush_mkdir($path)); + $this->assertTrue(file_unmanaged_copy('sites/default/settings.php', $path)); + + // @see conf_path() + // @see libraries_get_libraries() + $conf =& drupal_static('conf_path'); + $conf = $path; - // @see conf_path() - // @see libraries_get_libraries() - $conf =& drupal_static('conf_path'); - $conf = $path; + $this->testManualDownloading(array('uri' => $site)); + $this->assertTrue(drush_delete_dir($path)); + } - $this->testManualDownloading(array('uri' => $site)); - $this->assertTrue(drush_delete_dir($path)); - } + /** + * Testing manual downloading to profile. + */ + public function testDownloadingToProfile() { + $this->testManualDownloading(array('profile' => TRUE)); + } - /** - * Testing manual downloading to profile. - */ - public function testDownloadingToProfile() { - $this->testManualDownloading(array('profile' => TRUE)); } - }