Files
yii2/tests/framework/helpers/ConsoleStub.php
Pavel Dovlatov b20d2692a1 More tests for Console helper (#15285)
* Adding some tests for \yii\helpers\BaseConsole

BaseConsole::input()
BaseConsole::output()
BaseConsole::error()
BaseConsole::prompt()
BaseConsole::confirm()
BaseConsole::select()

* Simplify Console helper stub for obviousness

* Linking to \yii\helpers\Console instead of \yii\helpers\BaseConsole
2017-12-06 12:51:02 +03:00

59 lines
1.1 KiB
PHP

<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\helpers;
use yii\helpers\Console;
/**
* Console helper stub for STDIN/STDOUT/STDERR replacement
*
* @author Pavel Dovlatov <mysterydragon@yandex.ru>
*/
class ConsoleStub extends Console
{
/**
* @var resource input stream
*/
public static $inputStream = \STDIN;
/**
* @var resource output stream
*/
public static $outputStream = \STDOUT;
/**
* @var resource error stream
*/
public static $errorStream = \STDERR;
/**
* @inheritdoc
*/
public static function stdin($raw = false)
{
return $raw ? fgets(self::$inputStream) : rtrim(fgets(self::$inputStream), PHP_EOL);
}
/**
* @inheritdoc
*/
public static function stdout($string)
{
return fwrite(self::$outputStream, $string);
}
/**
* @inheritdoc
*/
public static function stderr($string)
{
return fwrite(self::$errorStream, $string);
}
}