Skip to content
Snippets Groups Projects

Issue #3499478:Add NodeAccessTrait.

1 unresolved thread
1 file
+ 15
1
Compare changes
  • Side-by-side
  • Inline
@@ -9,6 +9,7 @@ use Drupal\file\Entity\File;
use Drupal\media\MediaTypeInterface;
use Drupal\node\Entity\NodeType;
use Drupal\views\Entity\View;
use Drupal\Tests\node\Traits\NodeAccessTrait;
/**
* Private test file for File to Media module.
@@ -18,6 +19,7 @@ use Drupal\views\Entity\View;
class PrivateFileTest extends FileFieldTestBase {
use MediaTypeCreationTrait;
use NodeAccessTrait;
/**
* Modules to enable.
@@ -55,8 +57,20 @@ class PrivateFileTest extends FileFieldTestBase {
*/
protected function setUp(): void {
parent::setUp();
node_access_test_add_field(NodeType::load('article'));
node_access_rebuild();
$drupal_version = \Drupal::VERSION;
$article_node_type = NodeType::load('article');
if (version_compare($drupal_version, '11.2', '>=')) {
// For Drupal 11.2 and later, use the new method for adding a private field.
$this->addPrivateField($article_node_type);
}
else {
// For versions before 11.2, continue using the old method.
node_access_test_add_field($article_node_type);
}
\Drupal::state()->set('node_access_test.private', TRUE);
// This test expects unused managed files to be marked as a temporary file.
$this->config('file.settings')
Loading