You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.9 KiB
56 lines
1.9 KiB
<?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; |
|
use yiiunit\TestCase; |
|
|
|
/** |
|
* @group console |
|
*/ |
|
class ControllerTest extends TestCase |
|
{ |
|
public function testBindActionParams() |
|
{ |
|
$this->mockApplication([]); |
|
|
|
$controller = new FakeController('fake', Yii::$app); |
|
|
|
$params = ['from params']; |
|
list($fromParam, $other) = $controller->run('aksi1', $params); |
|
$this->assertEquals('from params', $fromParam); |
|
$this->assertEquals('default', $other); |
|
|
|
$params = ['from params', 'notdefault']; |
|
list($fromParam, $other) = $controller->run('aksi1', $params); |
|
$this->assertEquals('from params', $fromParam); |
|
$this->assertEquals('notdefault', $other); |
|
|
|
$params = ['d426,mdmunir', 'single']; |
|
$result = $controller->runAction('aksi2', $params); |
|
$this->assertEquals([['d426', 'mdmunir'], 'single'], $result); |
|
|
|
$params = ['_aliases' => ['t' => 'test']]; |
|
$result = $controller->runAction('aksi4', $params); |
|
$this->assertEquals('test', $result); |
|
|
|
$params = ['_aliases' => ['a' => 'testAlias']]; |
|
$result = $controller->runAction('aksi5', $params); |
|
$this->assertEquals('testAlias', $result); |
|
|
|
$params = ['_aliases' => ['ta' => 'from params,notdefault']]; |
|
list($fromParam, $other) = $controller->runAction('aksi6', $params); |
|
$this->assertEquals('from params', $fromParam); |
|
$this->assertEquals('notdefault', $other); |
|
|
|
$params = ['avaliable']; |
|
$message = Yii::t('yii', 'Missing required arguments: {params}', ['params' => implode(', ', ['missing'])]); |
|
$this->setExpectedException('yii\console\Exception', $message); |
|
$result = $controller->runAction('aksi3', $params); |
|
} |
|
}
|
|
|