You are here

function imagecache_testsuite_positioning_get_tests in ImageCache Actions 7

Same name and namespace in other branches
  1. 8 tests/imagecache_testsuite.module \imagecache_testsuite_positioning_get_tests()
  2. 6.2 tests/imagecache_testsuite.module \imagecache_testsuite_positioning_get_tests()
1 call to imagecache_testsuite_positioning_get_tests()
imagecache_testsuite_positioning in tests/imagecache_testsuite.module
Display a page demonstrating a number of positioning tests

File

tests/imagecache_testsuite.module, line 429

Code

function imagecache_testsuite_positioning_get_tests() {
  return array(
    'base' => array(
      'parameters' => array(
        'x' => '0',
        'y' => '0',
      ),
      'description' => '0 is top left.',
      'expected' => array(
        'x' => '0',
        'y' => '0',
      ),
    ),
    'numbers' => array(
      'parameters' => array(
        'x' => '50',
        'y' => '-50',
      ),
      'description' => 'Basic numbers indicate distance and direction from top left.',
      'expected' => array(
        'x' => '50',
        'y' => '-50',
      ),
    ),
    'keywords' => array(
      'parameters' => array(
        'x' => 'center',
        'y' => 'bottom',
      ),
      'description' => "Plain keywords will align against the region",
      'expected' => array(
        'x' => '62.5',
        'y' => '50',
      ),
    ),
    'keyword with offsets' => array(
      'parameters' => array(
        'x' => 'right+10',
        'y' => 'bottom+10',
      ),
      'description' => "Keywords can be used with offsets. Positive numbers are in from the named side",
      'expected' => array(
        'x' => '115',
        'y' => '40',
      ),
    ),
    'keyword with negative offsets' => array(
      'parameters' => array(
        'x' => 'right-10',
        'y' => 'bottom-10',
      ),
      'description' => "Negative numbers place the item outside the boundry",
      'expected' => array(
        'x' => '135',
        'y' => '60',
      ),
    ),
    'percent' => array(
      'parameters' => array(
        'x' => '50%',
        'y' => '50%',
      ),
      'description' => "Percentages on their own will CENTER on both the source and destination items",
      'expected' => array(
        'x' => '62.5',
        'y' => '25',
      ),
    ),
    'keyword with percent' => array(
      'parameters' => array(
        'x' => 'right+10%',
        'y' => 'bottom+10%',
      ),
      'description' => "Percentages can be used with keywords, though the placed image will be centered on the calculated position.",
      'expected' => array(
        'x' => '142.5',
        'y' => '85',
      ),
    ),
    'css styles' => array(
      'parameters' => array(
        'left' => '10px',
        'bottom' => '10px',
      ),
      'description' => "A different method uses css-like parameters.",
      'expected' => array(
        'x' => '10',
        'y' => '40',
      ),
    ),
    'css negatives' => array(
      'parameters' => array(
        'left' => '-10px',
        'bottom' => '-10px',
      ),
      'description' => "Negative numbers from sides always move outside of the boundries.",
      'expected' => array(
        'x' => '-10',
        'y' => '60',
      ),
    ),
    'css with percents' => array(
      'parameters' => array(
        'right' => '+10%',
        'bottom' => '+10%',
      ),
      'description' => "Using percents with sides calculates the percent location on the base, then centers the source item on that point.",
      'expected' => array(
        'x' => '142.5',
        'y' => '85',
      ),
    ),
    'css centering' => array(
      'parameters' => array(
        'right' => '50%',
        'top' => '50%',
      ),
      'description' => "The auto-centering that happens when percents are used means you can easily center things at 50%.",
      'expected' => array(
        'x' => '62.5',
        'y' => '25',
      ),
    ),
    'css positioning' => array(
      'parameters' => array(
        'right' => 'left+20',
        'top' => 'bottom-20',
      ),
      'description' => "It's also possible to use keywords there, though it's not smart to do so",
      'expected' => array(
        'x' => '-55',
        'y' => '130',
      ),
    ),
  );
}