Stdin'den okuyan ve okunan değeri döndüren bir okuyucu sınıfına sahibim.PHPUnit'teki test STDIN
class Reader
{
const STREAM_READ = 'php://stdin';
private $_streamHandle;
public function __construct($stream = self::STREAM_READ)
{
$this->_streamHandle = fopen($stream, 'r');
}
public function getReadedValue()
{
$value = trim(fgets($this->_streamHandle));
return $value;
}
public function __destruct()
{
fclose($this->_streamHandle);
}
}
Şimdi benim sorum ben stdin'den şey okurken, bu sınıf test ve getReadedValue()
işlevi tarafından çok okunan değer döndürmek nasıl, nedir?
Komut satırı ile bir komut satırı yürütme –
PHPUnit için vfsStream adlı bir dosya sistemi alay uzantısı var, ancak yardımcı olabileceğini düşündüm ama dokümanlar hiçbir şey söylemiyor, belki de değil. Belki de bir kazıya değer mi? GitHub'da. Alternatif olarak burada okumaya değer bir QA olabilir: http://stackoverflow.com/questions/9158155/how-to-write-unit-tests-for-interactive-console-app –