|
|
|
<?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;
|
|
|
|
use yiiunit\framework\di\stubs\Qux;
|
|
|
|
use yiiunit\framework\web\stubs\Bar;
|
|
|
|
use yiiunit\framework\web\stubs\OtherQux;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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 = ['avaliable'];
|
|
|
|
$message = Yii::t('yii', 'Missing required arguments: {params}', ['params' => implode(', ', ['missing'])]);
|
|
|
|
$this->setExpectedException('yii\console\Exception', $message);
|
|
|
|
$result = $controller->runAction('aksi3', $params);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|