Skip to content

Commit

Permalink
Test execution of deploy hooks inside a module with _deploy in the name.
Browse files Browse the repository at this point in the history
Test for #5216
  • Loading branch information
pfrenssen committed Aug 30, 2022
1 parent 2940512 commit 5ad4838
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/fixtures/modules/woot_deploy/woot_deploy.deploy.php
@@ -0,0 +1,17 @@
<?php

/**
* This is a NAME.deploy.php file. It contains "deploy" functions. These are
* one-time functions that run *after* config is imported during a deployment.
* These are a higher level alternative to hook_update_n and hook_post_update_NAME
* functions. See https://www.drush.org/latest/deploycommand/#authoring-update-functions
* for a detailed comparison.
*/

/**
* Deploy hook in module containing _deploy.
*/
function woot_deploy_deploy_function()
{
return 'This is the update message from ' . __FUNCTION__;
}
5 changes: 5 additions & 0 deletions tests/fixtures/modules/woot_deploy/woot_deploy.info.yml
@@ -0,0 +1,5 @@
name: Woot Deploy
type: module
description: Deploys Mightily.
core_version_requirement: ^9 || ^10
package: Other
18 changes: 18 additions & 0 deletions tests/functional/DeployHookTest.php
Expand Up @@ -94,4 +94,22 @@ public function testSkipDeployHooks()
$this->drush('deploy:hook-status', [], $options, null, null, self::EXIT_SUCCESS);
$this->assertStringContainsString('[]', $this->getOutput());
}

public function testDeployHooksInModuleWithDeployInName()
{
$this->setUpDrupal(1, true);
$options = [
'yes' => null,
];
$this->setupModulesForTests(['woot_deploy'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm-install', ['woot_deploy'], $options);

// Run deploy hooks.
$this->drush('deploy:hook', [], $options, null, null, self::EXIT_SUCCESS);

$this->assertStringContainsString('[notice] Deploy hook started: woot_deploy_deploy_function', $this->getErrorOutput());
$this->assertStringContainsString('[notice] This is the update message from woot_deploy_deploy_function', $this->getErrorOutput());
$this->assertStringContainsString('[notice] Performed: woot_deploy_deploy_function', $this->getErrorOutput());
$this->assertStringContainsString('[success] Finished performing deploy hooks.', $this->getErrorOutput());
}
}

0 comments on commit 5ad4838

Please sign in to comment.