Yii2 framework backup
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.

49 lines
1.4 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;
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);
9 years ago
$params = ['avaliable'];
$message = Yii::t('yii', 'Missing required arguments: {params}', ['params' => implode(', ', ['missing'])]);
$this->setExpectedException('yii\console\Exception', $message);
$result = $controller->runAction('aksi3', $params);
}
}