Skip to content

Commit

Permalink
Put empty table message test in its own test function, and mark it to…
Browse files Browse the repository at this point in the history
… only run on php 8+
  • Loading branch information
greg-1-anderson committed Jun 8, 2023
1 parent 63e3fc7 commit 20fcb8f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/FullStackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,42 @@ function testCommandsAndHooksIncludeAllPublicMethods()
$this->assertRunCommandViaApplicationEquals('get:serious', 'very serious');
$this->assertRunCommandViaApplicationContains('get:lost', 'Command "get:lost" is not defined.', [], 1);
$this->assertRunCommandViaApplicationContains('get:both', 'Here is some data.', [], 3);
}

/**
* @requires PHP 8.0
*/
function testAttributeCommands()
{
// First, search for commandfiles in the 'alpha'
// directory. Note that this same functionality
// is tested more thoroughly in isolation in
// testCommandFileDiscovery.php
$discovery = new CommandFileDiscovery();
$discovery
->setSearchPattern('*CommandFile.php')
->setIncludeFilesAtBase(false)
->setSearchLocations(['alpha']);

chdir(__DIR__);
$commandFiles = $discovery->discover('.', '\Consolidation\TestUtils');

$formatter = new FormatterManager();
$formatter->addDefaultFormatters();
$formatter->addDefaultSimplifiers();
$hookManager = new HookManager();
$commandProcessor = new CommandProcessor($hookManager);
$commandProcessor->setFormatterManager($formatter);

// Create a new factory, and load all of the files
// discovered above. The command factory class is
// tested in isolation in testAnnotatedCommandFactory.php,
// but this is the only place where
$factory = new AnnotatedCommandFactory();
$factory->setCommandProcessor($commandProcessor);
// $factory->addListener(...);
$factory->setIncludeAllPublicMethods(true);
$this->addDiscoveredCommands($factory, $commandFiles);

// Test to see if an empty table omits the table headers (labels header)
$this->assertRunCommandViaApplicationContains('tabularify apples peaches pumpkin pie', '----');
Expand Down

0 comments on commit 20fcb8f

Please sign in to comment.