namespace Friendica\Test\src\Core\Console;
-use Friendica\App;
-use Friendica\BaseObject;
+use Asika\SimpleConsole\Console;
+use Friendica\Test\MockedTest;
+use Friendica\Test\Util\AppMockTrait;
use Friendica\Test\Util\Intercept;
-use PHPUnit\Framework\TestCase;
+use Friendica\Test\Util\VFSTrait;
-abstract class ConsoleTest extends TestCase
+abstract class ConsoleTest extends MockedTest
{
+ use VFSTrait;
+ use AppMockTrait;
+
/**
- * @var MultiUseConsole Extension of the basic Friendica Console for testing purpose
- */
- private $console;
- /**
- * @var App The Friendica App
+ * @var array The default argv for a Console Instance
*/
- protected $app;
-
- protected $stdout;
+ protected $consoleArgv = [ 'consoleTest.php' ];
protected function setUp()
{
parent::setUp();
- Intercept::setUp();
-
if (!getenv('MYSQL_DATABASE')) {
$this->markTestSkipped('Please set the MYSQL_* environment variables to your test database credentials.');
}
- // Reusable App object
- $this->app = BaseObject::getApp();
- $this->console = new MultiUseConsole();
+ Intercept::setUp();
+
+ $this->setUpVfsDir();
+ $this->mockApp($this->root);
}
- public function execute($args) {
+ /**
+ * 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
+ */
+ protected function dumpExecute($console)
+ {
Intercept::reset();
- $this->console->reset();
- $this->console->parseTestArgv($args);
- $this->console->execute();
-
+ $console->execute();
$returnStr = Intercept::$cache;
Intercept::reset();
+
return $returnStr;
}
}