Config Console Tests (#5621)
* Config Console Tests - `MultiUseConsole` is now a testable console - `ConsoleTest` is a abstract TestClass for console tests - `ConfigConsoleTest` tests the config console commands * disable preserve global state because of smarty * fixed requires & basepath für Console Test
This commit is contained in:
parent
1711f4dc56
commit
4eaeea7889
4 changed files with 201 additions and 0 deletions
45
tests/Util/Intercept.php
Normal file
45
tests/Util/Intercept.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\Util;
|
||||
|
||||
use php_user_filter;
|
||||
|
||||
/**
|
||||
* Output Interceptor for STDOUT to prevent outputing to the console
|
||||
* Instead the $cache variable will get filled with the output
|
||||
*
|
||||
* @package Friendica\Test\Util
|
||||
*/
|
||||
class Intercept extends php_user_filter
|
||||
{
|
||||
/**
|
||||
* @var string The cache which holds the current output of STDOUT
|
||||
*/
|
||||
public static $cache = '';
|
||||
|
||||
public function filter($in, $out, &$consumed, $closing)
|
||||
{
|
||||
while ($bucket = stream_bucket_make_writeable($in)) {
|
||||
self::$cache .= $bucket->data;
|
||||
$consumed += $bucket->datalen;
|
||||
stream_bucket_append($out, $bucket);
|
||||
}
|
||||
return PSFS_FEED_ME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the interceptor and prevents therefore the output to STDOUT
|
||||
*/
|
||||
public static function setUp() {
|
||||
stream_filter_register("intercept", Intercept::class);
|
||||
stream_filter_append(STDOUT, "intercept");
|
||||
stream_filter_append(STDERR, "intercept");
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the cache
|
||||
*/
|
||||
public static function reset() {
|
||||
self::$cache = '';
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue