You are here

public function ScaldBaseTestCase::testScaldCache in Scald: Media Management made easy 7

Test Scald caching system.

File

tests/scald.test, line 256
Tests for scald.module.

Class

ScaldBaseTestCase
Test the Scald base functionality.

Code

public function testScaldCache() {
  global $is_https, $base_url;
  module_enable(array(
    'scald_image',
  ));
  $image = $this
    ->getTestFile('image');
  $web_user = $this
    ->drupalCreateUser(array(
    'view any atom',
    'fetch any atom',
    'create atom of any type',
  ));
  $this
    ->drupalLogin($web_user);
  $atom = $this
    ->createAtom();
  $output1 = scald_render($atom->sid, 'full');
  $is_https = !$is_https;
  $base_url = str_replace('http://', 'https://', $base_url);
  $output2 = scald_render($atom->sid, 'full');
  $is_https = !$is_https;
  $base_url = str_replace('https://', 'http://', $base_url);
  $this
    ->assertNotIdentical($output1, $output2, 'Different renders in http and https versions.');

  // Check if cached content is served. Change the atom directly from the
  // database to avoid cached content being changed.
  $title = 'Title has been changed';
  db_query('UPDATE {scald_atoms} SET title = :title WHERE sid = :sid', array(
    ':title' => $title,
    ':sid' => $atom->sid,
  ));
  $atom = scald_fetch($atom->sid, TRUE);
  $this
    ->assertIdentical($title, $atom->title);
  $output3 = scald_render($atom->sid, 'full');
  $this
    ->assertIdentical($output1, $output3);
}