mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-16 14:29:30 +08:00
Added Console helper mock, updated DbSessionTest::testMigration() to hide migration process output
This commit is contained in:
@@ -120,7 +120,10 @@ 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');
|
$history = $this->runMigrate('history');
|
||||||
$this->assertEquals(['base'], $history);
|
$this->assertEquals(['base'], $history);
|
||||||
|
|
||||||
@@ -129,5 +132,7 @@ class DbSessionTest extends TestCase
|
|||||||
|
|
||||||
$history = $this->runMigrate('down');
|
$history = $this->runMigrate('down');
|
||||||
$this->assertEquals(['base'], $history);
|
$this->assertEquals(['base'], $history);
|
||||||
|
|
||||||
|
Yii::$classMap['yii\helpers\Console'] = $consoleClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
34
tests/framework/web/mocks/ConsoleMock.php
Normal file
34
tests/framework/web/mocks/ConsoleMock.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user