Skip to content

Instantly share code, notes, and snippets.

@szeidler
Created April 8, 2024 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szeidler/7989e724edb766bb6ff2ffff6aa0ead7 to your computer and use it in GitHub Desktop.
Save szeidler/7989e724edb766bb6ff2ffff6aa0ead7 to your computer and use it in GitHub Desktop.
Test drush commands as a functional test
<?php
namespace Drupal\Tests\staffing_figures_api\Functional;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\BrowserTestBase;
use Drush\TestTraits\DrushTestTrait;
/**
* Tests the Drush commands provided by the staffing_figures_api module.
*
* @group staffing_figures_api
*/
class DrushCommandsTest extends BrowserTestBase {
use DrushTestTrait;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Modules to install.
*
* @var array
*/
public static $modules = [
'taxonomy',
'staffing_figures',
'staffing_figures_api',
];
protected function setUp(): void {
parent::setUp();
Vocabulary::create(['vid' => 'workplace', 'name' => 'Workplace'])->save();
}
/**
* Tests the Drush commands
*/
public function testDrushCommands() {
// Test the different drush commands are executed without errors.
// TODO: Extend the tests with proper test for results and return messges.
$this->drush('staffing-figures-api:generate:workplaces');
$this->drush('staffing-figures-api:generate:file');
$this->drush('staffing-figures-api:generate:file', [2020, 2, 1]);
$this->drush('staffing-figures-api:generate:merged', [1]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment