Added Console helper mock, updated DbSessionTest::testMigration() to hide migration process output

This commit is contained in:
SilverFire - Dmitry Naumenko
2016-04-25 11:17:43 +03:00
parent 0b357446c9
commit 8de6fde989
2 changed files with 40 additions and 1 deletions

View File

@@ -121,6 +121,9 @@ class DbSessionTest extends TestCase
],
]);
$consoleClass = Yii::$classMap['yii\helpers\Console'];
Yii::$classMap['yii\helpers\Console'] = Yii::getAlias('@yiiunit/framework/web/mocks/ConsoleMock.php');
$history = $this->runMigrate('history');
$this->assertEquals(['base'], $history);
@@ -129,5 +132,7 @@ class DbSessionTest extends TestCase
$history = $this->runMigrate('down');
$this->assertEquals(['base'], $history);
Yii::$classMap['yii\helpers\Console'] = $consoleClass;
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace yii\helpers;
/**
* Mock of Console class
* @package yii\helpers
*/
class Console extends BaseConsole
{
/**
* Prints a string to output buffer instead of STOUT
*
* @param string $string the string to print
* @return integer|boolean Number of bytes printed or false on error
*/
public static function stdout($string)
{
echo $string;
return mb_strlen($string);
}
/**
* Prints a string to output buffer instead of STDERR
*
* @param string $string the string to print
* @return integer|boolean Number of bytes printed or false on error
*/
public static function stderr($string)
{
echo $string;
return mb_strlen($string);
}
}