2023-06-08 02:32:47 +02:00
< ? php
namespace SilverStripe\Dev\Tests ;
use SilverStripe\Dev\SapphireTest ;
2024-09-26 07:16:47 +02:00
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 ;
2023-06-08 02:32:47 +02:00
class BuildTaskTest extends SapphireTest
{
2024-09-26 07:16:47 +02:00
public function testRunOutput () : void
2023-06-08 02:32:47 +02:00
{
2024-09-26 07:16:47 +02:00
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' \n This output is coming from a build task \n \n Task 'my title' completed successfully in 15 seconds \n " , $buffer -> fetch ());
2023-06-08 02:32:47 +02:00
}
}