silverstripe-framework/tests/php/Dev/BuildTaskTest.php
Guy Sartorelli e46135be0a
NEW Refactor CLI interaction with Silverstripe app (#11353)
- Turn sake into a symfony/console app
- Avoid using HTTPRequest for CLI interaction
- Implement abstract hybrid execution path
2024-09-26 17:16:47 +12:00

29 lines
973 B
PHP

<?php
namespace SilverStripe\Dev\Tests;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Dev\Tests\BuildTaskTest\TestBuildTask;
use SilverStripe\PolyExecution\PolyOutput;
use SilverStripe\ORM\FieldType\DBDatetime;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
class BuildTaskTest extends SapphireTest
{
public function testRunOutput(): void
{
DBDatetime::set_mock_now('2024-01-01 12:00:00');
$task = new TestBuildTask();
$task->setTimeTo = '2024-01-01 12:00:15';
$buffer = new BufferedOutput();
$output = new PolyOutput(PolyOutput::FORMAT_ANSI, wrappedOutput: $buffer);
$input = new ArrayInput([]);
$input->setInteractive(false);
$task->run($input, $output);
$this->assertSame("Running task 'my title'\nThis output is coming from a build task\n\nTask 'my title' completed successfully in 15 seconds\n", $buffer->fetch());
}
}