Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:

# Runs PHPUnit tests.
- name: PHPUnit
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd $GITHUB_WORKSPACE
lando run-tests
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ system for each contributed module, theme and layout.
- Warnings if dependency does not exist in the Backdrop Contributed Modules
space (e.g. CiviCRM).

### Changed
- Update Download tests to use GitHub Token when running on GitHub.

## [1.x-1.2.0] - 2026-02-25

### Added
Expand Down
30 changes: 24 additions & 6 deletions tests/backdrop/DownloadCommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,24 @@ class DownloadCommandsTest extends TestCase {
* Make sure that the download command works.
*/
public function test_download_command_works() {
// Get GITHUB_TOKEN if running on GitHub.
$token_string = '';
foreach (getenv() as $settingKey => $settingValue) {
if ($settingKey == 'GH_TOKEN') {
$token = $settingValue;
$token_string = " --github-token=$token";
}
}

global $bee_test_root;
// Single module.
$output_single = shell_exec('bee download simplify');
$output_single = shell_exec('bee download' . $token_string . ' simplify');
$pattern = '/\'simplify\' \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/backdrop\/modules\/simplify\'/';
$this->assertMatchesRegularExpression($pattern, $output_single);
$this->assertTrue(file_exists("$bee_test_root/backdrop/modules/simplify/simplify.info"));

// Multiple projects (theme and layout).
$output_multiple = shell_exec('bee download lumi bamboo');
$output_multiple = shell_exec('bee download' . $token_string . ' lumi bamboo');
$pattern = '/\'lumi\' \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/backdrop\/themes\/lumi\'/';
$this->assertMatchesRegularExpression($pattern, $output_multiple);
$this->assertTrue(file_exists("$bee_test_root/backdrop/themes/lumi/lumi.info"));
Expand All @@ -31,7 +40,7 @@ public function test_download_command_works() {
$this->assertTrue(file_exists("$bee_test_root/backdrop/layouts/bamboo/bamboo.info"));

// Defined release.
$output_defined_release = shell_exec('bee download layout_custom_theme:1.x-1.0.4');
$output_defined_release = shell_exec('bee download' . $token_string . ' layout_custom_theme:1.x-1.0.4');
$pattern = '/\'layout_custom_theme\' \(1\.x\-1\.0\.4\, published at 2024\-02\-01T[\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/backdrop\/modules\/layout_custom_theme\'/';
// Cleanup downloads.
exec("rm -fr $bee_test_root/backdrop/modules/simplify $bee_test_root/backdrop/themes/lumi $bee_test_root/backdrop/layouts/bamboo $bee_test_root/backdrop/modules/layout_custom_theme");
Expand All @@ -41,21 +50,30 @@ public function test_download_command_works() {
* Make sure that the download-core command works.
*/
public function test_download_core_command_works() {
// Get GITHUB_TOKEN if running on GitHub.
$token_string = '';
foreach (getenv() as $settingKey => $settingValue) {
if ($settingKey == 'GH_TOKEN') {
$token = $settingValue;
$token_string = " --github-token=$token";
}
}

global $bee_test_root;
// Download to current directory.
$output_current = shell_exec("mkdir $bee_test_root/current && cd $bee_test_root/current && bee download-core");
$output_current = shell_exec("mkdir $bee_test_root/current && cd $bee_test_root/current && bee download-core" . $token_string);
$pattern = '/Backdrop \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/current\'/';
$this->assertMatchesRegularExpression($pattern, $output_current);
$this->assertTrue(file_exists("$bee_test_root/current/index.php"));

// Download to specified directory.
$output_directory = shell_exec("bee download-core $bee_test_root/directory");
$output_directory = shell_exec("bee download-core $bee_test_root/directory" . $token_string);
$pattern = '/Backdrop \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/directory\'/';
$this->assertMatchesRegularExpression($pattern, $output_directory);
$this->assertTrue(file_exists("$bee_test_root/directory/index.php"));

// Download a defined release.
$output_defined_release = shell_exec("bee download-core $bee_test_root/defined_release --version=1.30.0");
$output_defined_release = shell_exec("bee download-core $bee_test_root/defined_release --version=1.30.0" . $token_string);
$pattern = '/Backdrop \(1\.30\.0\, published at 2025\-01\-1\dT[\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/defined_release\'/';
$this->assertMatchesRegularExpression($pattern, $output_defined_release);
$this->assertTrue(file_exists("$bee_test_root/defined_release/index.php"));
Expand Down
Loading