You are here

filtersie.test in FiltersIE 7

Tests for image.module.

File

filtersie.test
View source
<?php

/**
 * @file
 * Tests for image.module.
 */

/**
 * Use the image_test.module's mock toolkit to ensure that the effects are
 * properly passing parameters to the image toolkit.
 */
class FilterIEImageEffectsUnitTest extends ImageToolkitTestCase {
  public static function getInfo() {
    return array(
      'name' => 'FiltersIE Image effects',
      'description' => 'Test that the image effects pass parameters to the toolkit correctly.',
      'group' => 'Image',
    );
  }
  function setUp() {
    parent::setUp('image_module_test');
    module_load_include('module', 'filtersie');
  }

  /**
   * Test the filtersie_sharpenUSM_effect() function.
   */
  function testfiltersie_UnsharpMaskEffect() {

    // Test wihout sigma parameter
    $this
      ->assertTrue(filtersie_sharpenUSM_effect($this->image, array(
      'amount' => 50,
      'radius' => 1,
      'threshold' => 3,
    )), 'filtersie_UnsharpMask Function returned the expected value.');
    $this
      ->assertToolkitOperationsCalled(array(
      'filtersie_UnsharpMask',
    ));

    // Check the parameters.
    $calls = image_test_get_all_calls();
    $this
      ->assertEqual($calls['filtersie_UnsharpMask'][0][1], 50, 'Amount was passed correctly');
    $this
      ->assertEqual($calls['filtersie_UnsharpMask'][0][2], 1, 'Radius was passed correctly');
    $this
      ->assertEqual($calls['filtersie_UnsharpMask'][0][3], 3, 'Threshold was passed correctly');
    $this
      ->assertEqual($calls['filtersie_UnsharpMask'][0][4], NULL, 'Sigma was passed correctly');

    // Test with sigma parameter
    $this
      ->assertTrue(filtersie_sharpenUSM_effect($this->image, array(
      'amount' => 50,
      'radius' => 1,
      'threshold' => 3,
      'sigma' => 4,
    )), 'filtersie_UnsharpMask Function returned the expected value.');
    $this
      ->assertToolkitOperationsCalled(array(
      'filtersie_UnsharpMask',
    ));

    // Check the parameters.
    $calls = image_test_get_all_calls();
    $this
      ->assertEqual($calls['filtersie_UnsharpMask'][1][1], 50, 'Amount was passed correctly');
    $this
      ->assertEqual($calls['filtersie_UnsharpMask'][1][2], 1, 'Radius was passed correctly');
    $this
      ->assertEqual($calls['filtersie_UnsharpMask'][1][3], 3, 'Threshold was passed correctly');
    $this
      ->assertEqual($calls['filtersie_UnsharpMask'][1][4], 4, 'Sigma was passed correctly');
  }

}

/**
 * Image tookit's resize operation.
 */
function image_test_filtersie_UnsharpMask(stdClass $image, $amount, $radius, $threshold, $sigma) {
  _image_test_log_call('filtersie_UnsharpMask', array(
    $image,
    $amount,
    $radius,
    $threshold,
    $sigma,
  ));
  return TRUE;
}

Functions

Namesort descending Description
image_test_filtersie_UnsharpMask Image tookit's resize operation.

Classes

Namesort descending Description
FilterIEImageEffectsUnitTest Use the image_test.module's mock toolkit to ensure that the effects are properly passing parameters to the image toolkit.