
| Current Path : /var/www/html/dataninja.cn/core/modules/views/tests/src/Functional/Entity/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/dataninja.cn/core/modules/views/tests/src/Functional/Entity/BaseFieldAccessTest.php |
<?php
namespace Drupal\Tests\views\Functional\Entity;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\Tests\views\Functional\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
/**
* Tests views base field access.
*
* @group views
*/
class BaseFieldAccessTest extends ViewTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = ['test_entity_test_protected_access'];
/**
* Modules to enable
*
* @var array
*/
public static $modules = [
'views', 'views_test_config', 'entity_test', 'node', 'views_entity_test',
];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
ViewTestData::createTestViews(get_class($this), ['comment_test_views']);
\Drupal::state()->set('entity_test.views_data', [
'entity_test' => [
'test_text_access' => [
'field' => [
'id' => 'standard',
],
],
],
]);
$entity_1 = EntityTest::create([
'test_text_access' => 'no access value',
]);
$entity_1->save();
$entity_2 = EntityTest::create([
'test_text_access' => 'ok to see this one',
]);
$entity_2->save();
$this->drupalLogin($this->drupalCreateUser(['access content']));
}
/**
* Test access to protected base fields.
*/
public function testProtectedField() {
$this->drupalGet('test-entity-protected-access');
$this->assertText('ok to see this one');
$this->assertNoText('no access value');
}
}