mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 06:11:35 +08:00
59 lines
1.1 KiB
PHP
59 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* @link https://www.yiiframework.com/
|
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
|
* @license https://www.yiiframework.com/license/
|
|
*/
|
|
|
|
namespace yiiunit\framework\data;
|
|
|
|
use yii\data\BaseDataProvider;
|
|
use yiiunit\TestCase;
|
|
|
|
/**
|
|
* @group data
|
|
*/
|
|
class BaseDataProviderTest extends TestCase
|
|
{
|
|
public function testGenerateId(): void
|
|
{
|
|
$rc = new \ReflectionClass(BaseDataProvider::class);
|
|
$rp = $rc->getProperty('counter');
|
|
$rp->setAccessible(true);
|
|
$rp->setValue(new ConcreteDataProvider(), null);
|
|
|
|
$this->assertNull((new ConcreteDataProvider())->id);
|
|
$this->assertNotNull((new ConcreteDataProvider())->id);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* ConcreteDataProvider.
|
|
*/
|
|
class ConcreteDataProvider extends BaseDataProvider
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function prepareModels()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function prepareKeys($models)
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function prepareTotalCount()
|
|
{
|
|
return 0;
|
|
}
|
|
}
|