You are here

function sweaverThemeSettings::assertCSSFiles in Sweaver 7

Same name and namespace in other branches
  1. 6 tests/sweaver.themesettings.test \sweaverThemeSettings::assertCSSFiles()

Asserts for css files.

Parameters

$scenario: The id of the scenario.

$style_id: The id of the style.

$live: Whether the draft should exist or not.

$live: Whether the live should exist or not.

$equal_check: Whether to check on both files.

$equal: Whether they have to be equal or not.

3 calls to sweaverThemeSettings::assertCSSFiles()
sweaverThemeSettings::sweaverDeleteStyle in tests/sweaver.themesettings.test
Delete a style.
sweaverThemeSettings::sweaverPublishStyle in tests/sweaver.themesettings.test
Publish a style.
sweaverThemeSettings::sweaverSaveStyle in tests/sweaver.themesettings.test
Save a style.

File

tests/sweaver.themesettings.test, line 313
Advanced tests for sweaver editor + theme settings.

Class

sweaverThemeSettings
@file Advanced tests for sweaver editor + theme settings.

Code

function assertCSSFiles($scenario, $style_id, $draft, $live, $equal_check = FALSE, $equal = FALSE) {
  $draft_filename = $this
    ->sweaver_public_path() . '/sweaver/sweaver_bartik_' . $style_id . '_draft.css';
  $live_filename = $this
    ->sweaver_public_path() . '/sweaver/sweaver_bartik_' . $style_id . '_live.css';
  if ($draft) {
    $this
      ->assertTrue(file_exists($draft_filename), t('Draft css file exists for style id ' . $style_id . ' in scenario ' . $scenario));
  }
  else {
    $this
      ->assertFalse(file_exists($draft_filename), t('Draft css file does not exist for style id ' . $style_id . ' in scenario ' . $scenario));
  }
  if ($live) {
    $this
      ->assertTrue(file_exists($live_filename), t('Live css file exists for style id ' . $style_id . ' in scenario ' . $scenario));
  }
  else {
    $this
      ->assertFalse(file_exists($live_filename), t('Live css file does not exist for style id ' . $style_id . ' in scenario ' . $scenario));
  }
  if ($equal_check) {
    $draft_file_size = filesize($draft_filename);
    $live_file_size = filesize($live_filename);
    $this
      ->assertNotEqual($draft_file_size, 0, t('Draft CSS filesize is not 0 for style _id ' . $style_id . ' in scenario ' . $scenario . ' (' . $draft_file_size . ')'));
    $this
      ->assertNotEqual($live_file_size, 0, t('Live CSS filesize is not 0 for style _id ' . $style_id . ' in scenario ' . $scenario . ' (' . $live_file_size . ')'));
    if ($equal) {
      $this
        ->assertEqual($draft_file_size, $live_file_size, t('CSS files are equal for style id ' . $style_id . ' in scenario ' . $scenario . ' (' . $draft_file_size . ')'));
    }
    else {
      $this
        ->assertNotEqual($draft_file_size, $live_file_size, t('CSS files are not equal for style id ' . $style_id . ' in scenario ' . $scenario . '(d: ' . $draft_file_size . ' l: ' . $live_file_size . ')'));
    }
  }
}