You are here

public function ViewsLegacyTest::testTimeCache in Drupal 9

Tests the Time cache plugin.

File

core/modules/views/tests/src/Kernel/ViewsLegacyTest.php, line 26

Class

ViewsLegacyTest
Tests deprecated views functionality.

Namespace

Drupal\Tests\views\Kernel

Code

public function testTimeCache() {
  $request = Request::createFromGlobals();
  $this
    ->expectDeprecation('The request object must not be passed to Drupal\\views\\Plugin\\views\\cache\\Time::__construct(). It is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/3154016');
  $plugin = new Time([], 'time', \Drupal::service('plugin.manager.views.cache')
    ->getDefinition('time'), \Drupal::service('date.formatter'), $request);
  $view = $this
    ->prophesize(ViewExecutable::class);
  $view
    ->getRequest()
    ->willReturn($request);
  $plugin->view = $view
    ->reveal();
  $this
    ->assertInstanceOf(Request::class, $plugin->request);
  $this
    ->expectDeprecation('The request property of Drupal\\views\\Plugin\\views\\cache\\Time is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/3154016');
  $this
    ->assertSame($request, $plugin->request);
}