Fixes #17133: Fixed aliases rendering during help generation for a console command

This commit is contained in:
Nikolay Poryadin
2019-03-09 15:35:19 +03:00
committed by Alexander Makarov
parent 687f15fbd2
commit 5b5150ae62
4 changed files with 28 additions and 1 deletions

View File

@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.17 under development 2.0.17 under development
------------------------ ------------------------
- Bug #17133: Fixed aliases rendering during help generation for a console command (GHopperMSK)
- Bug #17185: Fixed `AssetManager` timestamp appending when a file is published manually (GHopperMSK) - Bug #17185: Fixed `AssetManager` timestamp appending when a file is published manually (GHopperMSK)
- Bug #17156: Fixes PHP 7.2 warning when a data provider has no data as a parameter for a GridView (evilito) - Bug #17156: Fixes PHP 7.2 warning when a data provider has no data as a parameter for a GridView (evilito)
- Bug #17083: Fixed `yii\validators\EmailValidator::$checkDNS` tells that every domain is correct on alpine linux (mikk150) - Bug #17083: Fixed `yii\validators\EmailValidator::$checkDNS` tells that every domain is correct on alpine linux (mikk150)

View File

@ -532,7 +532,7 @@ class HelpController extends Controller
protected function formatOptionAliases($controller, $option) protected function formatOptionAliases($controller, $option)
{ {
foreach ($controller->optionAliases() as $name => $value) { foreach ($controller->optionAliases() as $name => $value) {
if ($value === $option) { if (Inflector::camel2id($value, '-', true) === $option) {
return ', -' . $name; return ', -' . $name;
} }
} }

View File

@ -23,6 +23,7 @@ class ControllerTest extends TestCase
$this->mockApplication(); $this->mockApplication();
Yii::$app->controllerMap = [ Yii::$app->controllerMap = [
'fake' => 'yiiunit\framework\console\FakeController', 'fake' => 'yiiunit\framework\console\FakeController',
'fake_witout_output' => 'yiiunit\framework\console\FakeHelpControllerWithoutOutput',
'help' => 'yiiunit\framework\console\FakeHelpController', 'help' => 'yiiunit\framework\console\FakeHelpController',
]; ];
} }
@ -127,6 +128,10 @@ class ControllerTest extends TestCase
$this->assertFalse(FakeController::getWasActionIndexCalled()); $this->assertFalse(FakeController::getWasActionIndexCalled());
$this->assertEquals(FakeHelpController::getActionIndexLastCallParams(), ['posts/index']); $this->assertEquals(FakeHelpController::getActionIndexLastCallParams(), ['posts/index']);
$helpController = new FakeHelpControllerWithoutOutput('help', Yii::$app);
$helpController->actionIndex('fake/aksi1');
$this->assertContains('--test-array, -ta', $helpController->outputString);
} }
/** /**

View File

@ -0,0 +1,21 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\console;
use yii\console\controllers\HelpController;
use yii\helpers\Console;
class FakeHelpControllerWithoutOutput extends HelpController
{
public $outputString = '';
public function stdout($string)
{
return $this->outputString .= $string;
}
}