2018-08-17 19:41:46 +00:00
|
|
|
<?php
|
2024-08-24 12:31:41 +00:00
|
|
|
|
|
|
|
// Copyright (C) 2010-2024, the Friendica project
|
|
|
|
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-08-17 19:41:46 +00:00
|
|
|
|
2024-12-14 08:16:37 +00:00
|
|
|
namespace Friendica\Test;
|
2018-08-17 19:41:46 +00:00
|
|
|
|
2018-10-31 09:16:15 +00:00
|
|
|
use Asika\SimpleConsole\Console;
|
2024-12-11 22:45:17 +00:00
|
|
|
use Friendica\Test\MockedTestCase;
|
2018-08-17 19:41:46 +00:00
|
|
|
use Friendica\Test\Util\Intercept;
|
|
|
|
|
2024-12-14 08:16:37 +00:00
|
|
|
abstract class ConsoleTestCase extends MockedTestCase
|
2018-08-17 19:41:46 +00:00
|
|
|
{
|
2018-10-31 10:57:51 +00:00
|
|
|
/**
|
|
|
|
* @var array The default argv for a Console Instance
|
|
|
|
*/
|
|
|
|
protected $consoleArgv = [ 'consoleTest.php' ];
|
2018-08-17 19:41:46 +00:00
|
|
|
|
2021-04-01 21:04:30 +00:00
|
|
|
protected function setUp() : void
|
2018-08-17 19:41:46 +00:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2018-10-31 09:16:15 +00:00
|
|
|
Intercept::setUp();
|
|
|
|
}
|
2018-08-27 04:15:55 +00:00
|
|
|
|
2018-10-31 09:16:15 +00:00
|
|
|
/**
|
|
|
|
* Dumps the execution of an console output to a string and returns it
|
|
|
|
*
|
|
|
|
* @param Console $console The current console instance
|
|
|
|
*
|
|
|
|
* @return string the output of the execution
|
|
|
|
*/
|
2020-10-18 18:31:57 +00:00
|
|
|
protected function dumpExecute(Console $console)
|
2018-10-31 09:16:15 +00:00
|
|
|
{
|
2018-08-17 19:41:46 +00:00
|
|
|
Intercept::reset();
|
2018-10-31 09:16:15 +00:00
|
|
|
$console->execute();
|
2018-08-17 19:41:46 +00:00
|
|
|
$returnStr = Intercept::$cache;
|
|
|
|
Intercept::reset();
|
2018-08-27 04:15:55 +00:00
|
|
|
|
2018-10-31 09:16:15 +00:00
|
|
|
return $returnStr;
|
2018-08-27 04:15:55 +00:00
|
|
|
}
|
2018-08-17 19:41:46 +00:00
|
|
|
}
|