diff --git a/.gitignore b/.gitignore index 9d8fb04..67e1c87 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ .DS_Store -/phpunit +/phpunit.phar +/phpunit_source/ .phpunit.result.cache /backdrop/ /multisite/ +/current/ /backdrop.zip /box /bee.phar diff --git a/.lando.yml b/.lando.yml index 6030f5d..38ed4a5 100644 --- a/.lando.yml +++ b/.lando.yml @@ -29,9 +29,10 @@ services: - ln -s /app/bee.php /usr/local/bin/bee # Download Backdrop. - wget -q --show-progress -O /app/backdrop.zip https://github.com/backdrop/backdrop/archive/1.x.zip - # Download PHPUnit. - - wget -q --show-progress -O /app/phpunit https://phar.phpunit.de/phpunit-8.5.phar - - chmod +x /app/phpunit + # Download PHPUnit and extract the source to help validate test code functions. + - wget -q --show-progress -O /app/phpunit.phar https://phar.phpunit.de/phpunit-9.6.phar + - chmod +x /app/phpunit.phar + - mkdir -p /app/phpunit_source && cd /app/phpunit_source && phar extract -f /app/phpunit.phar # Download Box - wget -q --show-progress -O /app/box "https://github.com/box-project/box/releases/download/4.4.0/box.phar" - chmod +x /app/box @@ -56,12 +57,12 @@ events: # Run clean-up tasks. - /app/.lando/setup.sh clean # Remove `bee` symlink, Backdrop, PHPUnit, Box and any created bee.phar files. - - rm -f /usr/local/bin/bee /app/backdrop.zip /app/phpunit /app/box /app/bee.phar + - rm -rf /usr/local/bin/bee /app/backdrop.zip /app/phpunit.phar /app/phpunit_source /app/box /app/bee.phar pre-destroy: # Run clean-up tasks. - /app/.lando/setup.sh clean # Remove `bee` symlink, Backdrop, PHPUnit, Box and any created bee.phar files. - - rm -f /usr/local/bin/bee /app/backdrop.zip /app/phpunit /app/box /app/bee.phar + - rm -rf /usr/local/bin/bee /app/backdrop.zip /app/phpunit.phar /app/phpunit_source /app/box /app/bee.phar tooling: bee: service: appserver @@ -75,8 +76,8 @@ tooling: run-tests: service: appserver cmd: - - cd /app/backdrop && /app/phpunit --testsuite backdrop --configuration /app/tests - - cd /app/multisite && /app/phpunit --testsuite multisite --configuration /app/tests + - cd /app/backdrop && /app/phpunit.phar --testsuite backdrop --configuration /app/tests + - cd /app/multisite && /app/phpunit.phar --testsuite multisite --configuration /app/tests xdebug-on: service: appserver description: Enable Xdebug. diff --git a/CHANGELOG.md b/CHANGELOG.md index 65bbffd..0c7c824 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ better able to support the coming 'update' command. - Provide default terminal width if `tput cols` fails to get the value. - The `config-import` command will now import `system.extensions` config updates first if there are any. +- Updated PHPUnit to 9.6 ## [1.x-1.1.0] - 2024-09-07 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e8210e7..2a3e443 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,6 +69,9 @@ There are automated tests which test both functionality and coding standards, though the coding standards test is not comprehensive. If tests fail, please attempt to fix if you can. If you're not sure why tests have failed, ask. +If you wish to run the tests locally and you are not using Lando you will need +version 9.6 of PHPUnit. + If you are adding a new command or making changes to the way a command works, a new functional test or changes to existing functional tests, respectively, may be required. It is ok to request help if you are unsure about this. diff --git a/README.md b/README.md index eb72e3b..45b8e33 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,7 @@ user who is currently associated with the "BWpanda" user name. - Inspired by [Drush](https://github.com/drush-ops/drush). - [Bee icon](https://thenounproject.com/aomam/collection/bee-emoticons-line/?i=2257433) by AomAm from [the Noun Project](http://thenounproject.com). +- Bee uses [PHPUnit](https://github.com/sebastianbergmann/phpunit/) for testing. ## License diff --git a/tests/backdrop/ConfigCommandsTest.php b/tests/backdrop/ConfigCommandsTest.php index 4c97ff9..7e14d92 100644 --- a/tests/backdrop/ConfigCommandsTest.php +++ b/tests/backdrop/ConfigCommandsTest.php @@ -105,7 +105,7 @@ public function test_config_import_command_works() { $this->assertStringContainsString('1 file was synced.', (string) $output); // Verify config file doesn't exist in active. - $this->assertFileNotExists($file); + $this->assertFileDoesNotExist($file); // Put config file back. exec('mv dashboard.settings.json files/config_*/active/'); diff --git a/tests/backdrop/DownloadCommandsTest.php b/tests/backdrop/DownloadCommandsTest.php index 18e0384..7e9986a 100644 --- a/tests/backdrop/DownloadCommandsTest.php +++ b/tests/backdrop/DownloadCommandsTest.php @@ -18,16 +18,16 @@ public function test_download_command_works() { // Single module. $output_single = shell_exec('bee download simplify'); $pattern = '/\'simplify\' \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/backdrop\/modules\/simplify\'/'; - $this->assertRegExp($pattern, $output_single); + $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'); $pattern = '/\'lumi\' \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/backdrop\/themes\/lumi\'/'; - $this->assertRegExp($pattern, $output_multiple); + $this->assertMatchesRegularExpression($pattern, $output_multiple); $this->assertTrue(file_exists("$bee_test_root/backdrop/themes/lumi/lumi.info")); $pattern = '/\'bamboo\' \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/backdrop\/layouts\/bamboo\'/'; - $this->assertRegExp($pattern, $output_multiple); + $this->assertMatchesRegularExpression($pattern, $output_multiple); $this->assertTrue(file_exists("$bee_test_root/backdrop/layouts/bamboo/bamboo.info")); // Defined release. @@ -45,19 +45,19 @@ public function test_download_core_command_works() { // Download to current directory. $output_current = shell_exec("mkdir $bee_test_root/current && cd $bee_test_root/current && bee download-core"); $pattern = '/Backdrop \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/current\'/'; - $this->assertRegExp($pattern, $output_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"); $pattern = '/Backdrop \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/directory\'/'; - $this->assertRegExp($pattern, $output_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"); $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->assertRegExp($pattern, $output_defined_release); + $this->assertMatchesRegularExpression($pattern, $output_defined_release); $this->assertTrue(file_exists("$bee_test_root/defined_release/index.php")); // Cleanup downloads. diff --git a/tests/backdrop/ProjectsCommandsTest.php b/tests/backdrop/ProjectsCommandsTest.php index 7230f6c..296b288 100644 --- a/tests/backdrop/ProjectsCommandsTest.php +++ b/tests/backdrop/ProjectsCommandsTest.php @@ -16,18 +16,18 @@ class ProjectsCommandsTest extends TestCase { public function test_projects_command_works() { // All projects. $output_all = shell_exec('bee projects'); - $this->assertRegExp('/| admin_bar +| Administration Bar +| module +| Enabled +|/', (string) $output_all); - $this->assertRegExp('/| bartik +| Bartik +| theme +| Disabled +|/', (string) $output_all); - $this->assertRegExp('/| moscone +| Moscone +| layout +| Enabled +|/', (string) $output_all); + $this->assertMatchesRegularExpression('/| admin_bar +| Administration Bar +| module +| Enabled +|/', (string) $output_all); + $this->assertMatchesRegularExpression('/| bartik +| Bartik +| theme +| Disabled +|/', (string) $output_all); + $this->assertMatchesRegularExpression('/| moscone +| Moscone +| layout +| Enabled +|/', (string) $output_all); // Specific project. $output_project = shell_exec('bee projects contact'); - $this->assertRegExp('/Name +Contact/', (string) $output_project); - $this->assertRegExp('/Description +Enables the use of both personal and site-wide contact forms./', (string) $output_project); + $this->assertMatchesRegularExpression('/Name +Contact/', (string) $output_project); + $this->assertMatchesRegularExpression('/Description +Enables the use of both personal and site-wide contact forms./', (string) $output_project); // Just modules. $output_modules = shell_exec('bee projects --type=module'); - $this->assertRegExp('/| taxonomy +| Taxonomy +| module +| Enabled +|/', (string) $output_modules); + $this->assertMatchesRegularExpression('/| taxonomy +| Taxonomy +| module +| Enabled +|/', (string) $output_modules); $this->assertStringNotContainsString(' | theme ', (string) $output_modules); $this->assertStringNotContainsString(' | layout ', (string) $output_modules); } diff --git a/tests/backdrop/UserCommandsTest.php b/tests/backdrop/UserCommandsTest.php index e177cd0..8333980 100644 --- a/tests/backdrop/UserCommandsTest.php +++ b/tests/backdrop/UserCommandsTest.php @@ -15,7 +15,7 @@ class UserCommandsTest extends TestCase { */ public function test_users_command_works() { $output = shell_exec('bee users'); - $this->assertRegExp('/| 1 +| admin +| admin@example.com +|/', (string) $output); + $this->assertMatchesRegularExpression('/| 1 +| admin +| admin@example.com +|/', (string) $output); } /** diff --git a/tests/multisite/MultisiteDownloadCommandsTest.php b/tests/multisite/MultisiteDownloadCommandsTest.php index 68af2e5..bb2c815 100644 --- a/tests/multisite/MultisiteDownloadCommandsTest.php +++ b/tests/multisite/MultisiteDownloadCommandsTest.php @@ -18,7 +18,7 @@ public function test_download_command_works() { // Root directory, no site specified. $output_root = shell_exec('bee download simplify'); $pattern = '/\'simplify\' \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/multisite\/modules\/simplify\'/'; - $this->assertRegExp($pattern, $output_root); + $this->assertMatchesRegularExpression($pattern, $output_root); $this->assertTrue(file_exists("$bee_test_root/multisite/modules/simplify/simplify.info")); // Root directory, site specified, 'allow-multisite-copy' option NOT @@ -29,19 +29,19 @@ public function test_download_command_works() { // Root directory, site specified, 'allow-multisite-copy' option included. $output_root = shell_exec('bee --site=multi_one download --allow-multisite-copy simplify'); $pattern = '/\'simplify\' \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/multisite\/sites\/multi_one\/modules\/simplify\'/'; - $this->assertRegExp($pattern, $output_root); + $this->assertMatchesRegularExpression($pattern, $output_root); $this->assertTrue(file_exists("$bee_test_root/multisite/sites/multi_one/modules/simplify/simplify.info")); // Root directory, site specified. $output_root_site = shell_exec('bee download --site=multi_one lumi'); $pattern = '/\'lumi\' \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/multisite\/sites\/multi_one\/themes\/lumi\'/'; - $this->assertRegExp($pattern, $output_root_site); + $this->assertMatchesRegularExpression($pattern, $output_root_site); $this->assertTrue(file_exists("$bee_test_root/multisite/sites/multi_one/themes/lumi/lumi.info")); // Site directory. $output_site = shell_exec('cd sites/multi_two && bee download bamboo'); $pattern = '/\'bamboo\' \([\w\s\.\W]*\) was downloaded into \'' . preg_quote($bee_test_root, '/') . '\/multisite\/sites\/multi_two\/layouts\/bamboo\'/'; - $this->assertRegExp($pattern, $output_site); + $this->assertMatchesRegularExpression($pattern, $output_site); $this->assertTrue(file_exists("$bee_test_root/multisite/sites/multi_two/layouts/bamboo/bamboo.info")); // Cleanup downloads. diff --git a/tests/multisite/MultisiteInstallCommandsTest.php b/tests/multisite/MultisiteInstallCommandsTest.php index 7475bd2..c693240 100644 --- a/tests/multisite/MultisiteInstallCommandsTest.php +++ b/tests/multisite/MultisiteInstallCommandsTest.php @@ -17,8 +17,8 @@ public function test_install_command_works() { global $bee_test_db_host, $bee_test_multisite_install_test_db_name; // Check site status before install. $output_before = shell_exec('bee status --site=install_test'); - $this->assertRegExp('/Site type +Multisite/', (string) $output_before); - $this->assertRegExp('/Site directory +install_test/', (string) $output_before); + $this->assertMatchesRegularExpression('/Site type +Multisite/', (string) $output_before); + $this->assertMatchesRegularExpression('/Site directory +install_test/', (string) $output_before); $this->assertStringNotContainsString('Database', (string) $output_before); // Install the site. @@ -27,10 +27,10 @@ public function test_install_command_works() { // Check site status after install. $output_after = shell_exec('bee status --site=install_test'); - $this->assertRegExp('/Site type +Multisite/', (string) $output_after); - $this->assertRegExp('/Site directory +install_test/', (string) $output_after); - $this->assertRegExp('/Database name +install_test/', (string) $output_after); - $this->assertRegExp('/Database host +database/', (string) $output_after); + $this->assertMatchesRegularExpression('/Site type +Multisite/', (string) $output_after); + $this->assertMatchesRegularExpression('/Site directory +install_test/', (string) $output_after); + $this->assertMatchesRegularExpression('/Database name +install_test/', (string) $output_after); + $this->assertMatchesRegularExpression('/Database host +database/', (string) $output_after); // Cleanup the install. exec('bee --site=install_test db-drop -y'); diff --git a/tests/multisite/MultisiteTest.php b/tests/multisite/MultisiteTest.php index 1219c35..14f3a61 100644 --- a/tests/multisite/MultisiteTest.php +++ b/tests/multisite/MultisiteTest.php @@ -20,16 +20,16 @@ class MultisiteTest extends TestCase { public function test_site_global_option_works() { global $bee_test_multisite_multi_2_domain; $output_no_site = shell_exec('bee status'); - $this->assertRegExp('/Site type +Multisite/', (string) $output_no_site); - $this->assertNotRegExp('/Site directory +multisite/', (string) $output_no_site); + $this->assertMatchesRegularExpression('/Site type +Multisite/', (string) $output_no_site); + $this->assertDoesNotMatchRegularExpression('/Site directory +multisite/', (string) $output_no_site); $output_site_dir = shell_exec('bee --site=multi_one status'); - $this->assertRegExp('/Site type +Multisite/', (string) $output_site_dir); - $this->assertRegExp('/Site directory +multi_one/', (string) $output_site_dir); + $this->assertMatchesRegularExpression('/Site type +Multisite/', (string) $output_site_dir); + $this->assertMatchesRegularExpression('/Site directory +multi_one/', (string) $output_site_dir); $output_site_url = shell_exec("bee --site=$bee_test_multisite_multi_2_domain status"); - $this->assertRegExp('/Site type +Multisite/', (string) $output_site_url); - $this->assertRegExp('/Site directory +multi_two/', (string) $output_site_url); + $this->assertMatchesRegularExpression('/Site type +Multisite/', (string) $output_site_url); + $this->assertMatchesRegularExpression('/Site directory +multi_two/', (string) $output_site_url); } }