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.
66 lines
1.7 KiB
66 lines
1.7 KiB
<?php |
|
|
|
|
|
namespace yiiunit\framework\grid; |
|
|
|
use yii\data\ArrayDataProvider; |
|
use yii\grid\GridView; |
|
use yiiunit\data\ar\Order; |
|
|
|
/** |
|
* @author Dmitry Naumenko <d.naumenko.a@gmail.com> |
|
* |
|
* @group grid |
|
*/ |
|
class DataColumnTest extends \yiiunit\TestCase |
|
{ |
|
public function setUp() |
|
{ |
|
parent::setUp(); |
|
$this->mockApplication(); |
|
} |
|
|
|
public function testColumnLabelsOnEmptyArrayProvider() |
|
{ |
|
$grid = new GridView([ |
|
'dataProvider' => new ArrayDataProvider([ |
|
'allModels' => [], |
|
'totalCount' => 0, |
|
'modelClass' => Order::className() |
|
]), |
|
'columns' => ['customer_id', 'total'] |
|
]); |
|
|
|
$labels = []; |
|
foreach ($grid->columns as $column) { |
|
$method = new \ReflectionMethod($column, 'getHeaderCellLabel'); |
|
$method->setAccessible(true); |
|
$labels[] = $method->invoke($column); |
|
$method->setAccessible(false); |
|
} |
|
|
|
$this->assertEquals(['Customer', 'Invoice Total'], $labels); |
|
} |
|
|
|
public function testColumnLabelsOnEmptyArrayProviderWithFilterModel() |
|
{ |
|
$grid = new GridView([ |
|
'dataProvider' => new ArrayDataProvider([ |
|
'allModels' => [], |
|
'totalCount' => 0, |
|
]), |
|
'columns' => ['customer_id', 'total'], |
|
'filterModel' => new Order |
|
]); |
|
|
|
$labels = []; |
|
foreach ($grid->columns as $column) { |
|
$method = new \ReflectionMethod($column, 'getHeaderCellLabel'); |
|
$method->setAccessible(true); |
|
$labels[] = $method->invoke($column); |
|
$method->setAccessible(false); |
|
} |
|
|
|
$this->assertEquals(['Customer', 'Invoice Total'], $labels); |
|
} |
|
}
|
|
|