You are here

public function CacheTest::test_keyFromQuery in Render cache 7.2

Tests ::keyFromQuery() method. @covers ::keyFromQuery()

File

tests/src/Cache/CacheTest.php, line 24
Contains \Drupal\render_cache\Tests\Cache\CacheTest

Class

CacheTest
@coversDefaultClass \Drupal\render_cache\Cache\Cache @group cache

Namespace

Drupal\render_cache\Tests\Cache

Code

public function test_keyFromQuery() {
  $query = Mockery::mock('\\SelectQueryInterface');
  $query
    ->shouldReceive('preExecute')
    ->once();
  $query
    ->shouldReceive('getArguments')
    ->once()
    ->andReturn(array(
    ':foo' => 'bar',
  ));
  $query
    ->shouldReceive('__toString')
    ->once()
    ->andReturn('SELECT * from {node} WHERE nid = :foo');
  $this
    ->assertEquals('46387e3c7711dfd22bf707bcd79fe77bd652741b9b53a7adeb9be32fa3e010bb', Cache::keyFromQuery($query), 'Key from query returns the right hash.');
}