function ViewsDataTest::testFullGetCache

Same name and namespace in other branches
  1. 8.9.x core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testFullGetCache()
  2. 10 core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testFullGetCache()
  3. 11.x core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::testFullGetCache()

Tests the caching of the full views data.

File

core/modules/views/tests/src/Unit/ViewsDataTest.php, line 269

Class

ViewsDataTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21views%21src%21ViewsData.php/class/ViewsData/9" title="Class to manage and lazy load cached views data." class="local">\Drupal\views\ViewsData</a> @group views

Namespace

Drupal\Tests\views\Unit

Code

public function testFullGetCache() {
    $expected_views_data = $this->viewsDataWithProvider();
    // Views data should be invoked once.
    $this->setupMockedModuleHandler();
    $this->moduleHandler
        ->expects($this->once())
        ->method('alter')
        ->with('views_data', $expected_views_data);
    $this->cacheBackend
        ->expects($this->once())
        ->method('get')
        ->with("views_data:en")
        ->willReturn(FALSE);
    $views_data = $this->viewsData
        ->getAll();
    $this->assertSame($expected_views_data, $views_data);
    $views_data = $this->viewsData
        ->getAll();
    $this->assertSame($expected_views_data, $views_data);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.