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.
64 lines
2.1 KiB
64 lines
2.1 KiB
10 years ago
|
<?php
|
||
|
/**
|
||
|
* @link http://www.yiiframework.com/
|
||
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||
|
* @license http://www.yiiframework.com/license/
|
||
|
*/
|
||
|
|
||
|
namespace yiiunit\framework\grid;
|
||
|
|
||
|
use yii\data\ArrayDataProvider;
|
||
|
use yii\grid\CheckboxColumn;
|
||
|
use yii\grid\GridView;
|
||
|
use yii\helpers\FileHelper;
|
||
|
use yii\i18n\Formatter;
|
||
|
use yii\web\View;
|
||
|
use Yii;
|
||
|
use yiiunit\TestCase;
|
||
|
|
||
|
/**
|
||
|
* @group grid
|
||
|
*/
|
||
|
class CheckboxColumnTest extends TestCase
|
||
|
{
|
||
|
protected function setUp()
|
||
|
{
|
||
|
parent::setUp();
|
||
|
$this->mockApplication();
|
||
|
Yii::setAlias('@webroot', '@yiiunit/runtime');
|
||
|
Yii::setAlias('@web', 'http://localhost/');
|
||
|
FileHelper::createDirectory(Yii::getAlias('@webroot/assets'));
|
||
|
}
|
||
|
|
||
|
public function testInputName()
|
||
|
{
|
||
|
$column = new CheckboxColumn(['name' => 'selection', 'grid' => $this->getGrid()]);
|
||
|
$this->assertContains('name="selection_all"', $column->renderHeaderCell());
|
||
|
|
||
|
$column = new CheckboxColumn(['name' => 'selections[]', 'grid' => $this->getGrid()]);
|
||
|
$this->assertContains('name="selections_all"', $column->renderHeaderCell());
|
||
|
|
||
|
$column = new CheckboxColumn(['name' => 'MyForm[grid1]', 'grid' => $this->getGrid()]);
|
||
|
$this->assertContains('name="MyForm[grid1_all]"', $column->renderHeaderCell());
|
||
|
|
||
|
$column = new CheckboxColumn(['name' => 'MyForm[grid1][]', 'grid' => $this->getGrid()]);
|
||
|
$this->assertContains('name="MyForm[grid1_all]"', $column->renderHeaderCell());
|
||
|
|
||
|
$column = new CheckboxColumn(['name' => 'MyForm[grid1][key]', 'grid' => $this->getGrid()]);
|
||
|
$this->assertContains('name="MyForm[grid1][key_all]"', $column->renderHeaderCell());
|
||
|
|
||
|
$column = new CheckboxColumn(['name' => 'MyForm[grid1][key][]', 'grid' => $this->getGrid()]);
|
||
|
$this->assertContains('name="MyForm[grid1][key_all]"', $column->renderHeaderCell());
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return GridView a mock gridview
|
||
|
*/
|
||
|
protected function getGrid()
|
||
|
{
|
||
|
return new GridView([
|
||
|
'dataProvider' => new ArrayDataProvider(['allModels' => [], 'totalCount' => 0]),
|
||
|
]);
|
||
|
}
|
||
|
}
|