You are here

function ImagecacheProportionsTestCase::testCalculateProportions in Imagecache Proportions 7

Tests if the image style is well calculated from image size.

File

./imagecache_proportions.test, line 21
Tests for imagecache_proportions

Class

ImagecacheProportionsTestCase
@file Tests for imagecache_proportions

Code

function testCalculateProportions() {
  $cases = array();
  $cases[] = array(
    'width' => 100,
    'height' => 100,
    'looseness' => 0,
    'style' => 'squared_preset',
  );
  $cases[] = array(
    'width' => 200,
    'height' => 100,
    'looseness' => 0,
    'style' => 'horizontal_preset',
  );
  $cases[] = array(
    'width' => 100,
    'height' => 200,
    'looseness' => 0,
    'style' => 'vertical_preset',
  );
  $cases[] = array(
    'width' => 120,
    'height' => 100,
    'looseness' => 20,
    'style' => 'squared_preset',
  );
  $cases[] = array(
    'width' => 100,
    'height' => 120,
    'looseness' => 20,
    'style' => 'squared_preset',
  );
  $cases[] = array(
    'width' => 121,
    'height' => 100,
    'looseness' => 20,
    'style' => 'horizontal_preset',
  );
  $cases[] = array(
    'width' => 100,
    'height' => 121,
    'looseness' => 20,
    'style' => 'vertical_preset',
  );
  foreach ($cases as $case) {
    $style = imagecache_proportions_calculate_proportions($case['width'], $case['height'], $case['looseness']);
    $this
      ->assertEqual($style, $case['style'], t('Styles Match'));
  }
}