\JImageTest
Test class for JImage.
Synopsis
class JImageTest
extends TestCase
{
- // Inherited members from TestCase
- protected $expectedErrors;
- // methods
- protected void setUp()
- public array getPrepareDimensionsData()
- public array getSanitizeDimensionData()
- public array getCropData()
- public array getSanitizeOffsetData()
- public void testConstructor()
- public void testloadFile()
- public void testloadFileGif()
- public void testloadFilePng()
- public void testloadFileBmp()
- public void testloadFileWithInvalidFile()
- public void testResize()
- public void testResizeTransparent()
- public void testResizeNoFile()
- public void testToFileInvalid()
- public void testToFileGif()
- public void testToFilePng()
- public void testToFileJpg()
- public void testToFileDefault()
- public void testGetFilterInstance()
- public void testGetHeight()
- public void testGetHeightWithoutLoadedImage()
- public void testGetWidth()
- public void testGetWidthWithoutLoadedImage()
- public void testGetImageFilePropertiesWithInvalidFile()
- public void testIsTransparentWithoutLoadedImage()
- public void testTransparentIsTransparent()
- public void testOpaqueIsNotTransparent()
- public void testCropWithoutLoadedImage()
- public void testCrop()
- public void testRotateWithoutLoadedImage()
- public void testRotate()
- public void testFilter()
- public void testFilterWithoutLoadedImage()
- public void testFilterWithInvalidFilterType()
- public void testPrepareDimensions()
- public void testPrepareDimensionsWithInvalidScale()
- public void testSanitizeHeight()
- public void testSanitizeWidth()
- public void testSanitizeOffset()
- public void testDestroy()
- // Inherited methods from TestCase
- public static boolean errorCallback()
- public void assignMockCallbacks()
- public void assignMockReturns()
- public JException expectedErrorCallback()
- public JApplication getMockApplication()
- public JApplicationCms getMockCmsApp()
- public JConfig getMockConfig()
- public JDatabase getMockDatabase()
- public JEventDispatcher getMockDispatcher()
- public JDocument getMockDocument()
- public JLanguage getMockLanguage()
- public JSession getMockSession()
- public JApplicationWeb getMockWeb()
- public void setExpectedError()
- protected void restoreErrorHandlers()
- protected void restoreFactoryState()
- protected void saveErrorHandlers()
- protected void saveFactoryState()
- protected void setErrorHandlers()
- protected void setErrorCallback()
- protected void setUp()
- protected void tearDown()
Hierarchy
Extends
Members
protected
- $expectedErrors — array
Methods
protected
- setUp() — Setup for testing.
public
- getCropData() — Data for crop method. Don't put percentages in here. We test elsewhere that percentages get sanitized into appropriate integer values based on scale. Here we just want to test the logic that actually crops the image.
- getPrepareDimensionsData() — Data for prepareDimensions method. Don't put percentages in here. We test elsewhere that percentages get sanitized into appropriate integer values based on scale. Here we just want to test the logic that calculates scale dimensions.
- getSanitizeDimensionData() — Data for sanitizeDimension methods.
- getSanitizeOffsetData() — Data for sanitizeOffset method.
- testConstructor() — Tests the JImage::__construct method.
- testCrop() — Tests the JImage::crop() method. To test this we create an image that contains a red rectangle of a certain size [Rectangle1]. Inside of that rectangle [Rectangle1] we draw a white rectangle [Rectangle2] that is exactly two pixels smaller in width and height than its parent rectangle [Rectangle1]. Then we crop the image to the exact coordinates of Rectangle1 and verify both it's corners and the corners inside of it.
- testCropWithoutLoadedImage() — Test the JImage::crop method without a loaded image.
- testDestroy() — Tests the JImage::destory method
- testFilter() — Test the JImage::filter method to make sure it behaves correctly
- testFilterWithInvalidFilterType() — Test the JImage::filter method with a bogus filer type so that we expect an exception.
- testFilterWithoutLoadedImage() — Test the JImage::filter method without a loaded image.
- testGetFilterInstance() — Test the JImage::getFilterInstance method to make sure it behaves correctly
- testGetHeight() — Test the JImage::getHeight method to make sure it gives the correct property from the source image.
- testGetHeightWithoutLoadedImage() — Test the JImage::getHeight method without a loaded image.
- testGetImageFilePropertiesWithInvalidFile() — Test the JImage::getImageFileProperties method without a valid image file.
- testGetWidth() — Test the JImage::getWidth method to make sure it gives the correct property from the source image
- testGetWidthWithoutLoadedImage() — Test the JImage::getWidth method without a loaded image.
- testIsTransparentWithoutLoadedImage() — Test the JImage::isTransparent method without a loaded image.
- testOpaqueIsNotTransparent() — Test the JImage::isTransparent method to make sure it gives the correct result if the image does not haave an alpha channel.
- testPrepareDimensions() — Tests the JImage::prepareDimensions method.
- testPrepareDimensionsWithInvalidScale() — Tests the JImage::prepareDimensions method with a bogus scale so that an exception is thrown.
- testResize() — Test the JImage::resize to make sure images are resized properly.
- testResizeNoFile() — Test the JImage::resize to make sure images are resized properly - no file loaded.
- testResizeTransparent() — Test the JImage::resize to make sure images are resized properly and transparency is properly set.
- testRotate() — Tests the JImage::rotate() method. To test this we create an image that contains a red horizontal line in the middle of the image, and a white vertical line in the middle of the image. Once the image is rotated 90 degrees we test the end points of the lines to ensure that the colors have swapped.
- testRotateWithoutLoadedImage() — Test the JImage::rotate method without a loaded image.
- testSanitizeHeight() — Tests the JImage::sanitizeHeight method.
- testSanitizeOffset() — Tests the JImage::sanitizeOffset method.
- testSanitizeWidth() — Tests the JImage::sanitizeWidth method.
- testToFileDefault() — Test the JImage::toFile to make sure that a new image is properly written to file, when performing this test using a lossy compression we are not able to open and save the same image and then compare the checksums as the checksums may have changed. Therefore we are limited to comparing the image properties.
- testToFileGif() — Test the JImage::toFile to make sure that a new image is properly written to file, when performing this test using a lossy compression we are not able to open and save the same image and then compare the checksums as the checksums may have changed. Therefore we are limited to comparing the image properties.
- testToFileInvalid() — Test the JImage::toFile when there is no image loaded. This should throw a LogicException since we cannot write an image out to file that we don't even have yet.
- testToFileJpg() — Test the JImage::toFile to make sure that a new image is properly written to file, when performing this test using a lossy compression we are not able to open and save the same image and then compare the checksums as the checksums may have changed. Therefore we are limited to comparing the image properties.
- testToFilePng() — Test the JImage::toFile to make sure that a new image is properly written to file, when performing this test using a lossy compression we are not able to open and save the same image and then compare the checksums as the checksums may have changed. Therefore we are limited to comparing the image properties.
- testTransparentIsTransparent() — Test the JImage::isTransparent method to make sure it gives the correct result if the image has an alpha channel.
- testloadFile() — Test the JImage::loadFile to makes sure images are loaded properly. In this case we are taking the simple approach of loading an image file and asserting that the dimensions are correct.
- testloadFileBmp() — Test the JImage::loadFile to makes sure XCF images are not loaded properly. In this case we are taking the simple approach of loading an image file and asserting that the dimensions are correct.
- testloadFileGif() — Test the JImage::loadFile to makes sure GIF images are loaded properly. In this case we are taking the simple approach of loading an image file and asserting that the dimensions are correct.
- testloadFilePng() — Test the JImage::loadFile to makes sure PNG images are loaded properly. In this case we are taking the simple approach of loading an image file and asserting that the dimensions are correct.
- testloadFileWithInvalidFile() — Test the JImage::loadFile to makes sure if a bogus image is given it throws an exception.
Inherited from TestCase
protected
- restoreErrorHandlers() — Sets the JError error handlers.
- restoreFactoryState() — Sets the Factory pointers
- saveErrorHandlers() — Saves the current state of the JError error handlers.
- saveFactoryState() — Saves the Factory pointers
- setErrorCallback() — Sets the JError error handlers to callback mode and points them at the test logging method.
- setErrorHandlers() — Sets the JError error handlers.
- setUp() — Overrides the parent setup method.
- tearDown() — Overrides the parent tearDown method.
public
- assignMockCallbacks() — Assigns mock callbacks to methods.
- assignMockReturns() — Assigns mock values to methods.
- errorCallback() — Receives the callback from JError and logs the required error information for the test.
- expectedErrorCallback() — Callback receives the error from JError and deals with it appropriately If a test expects a JError to be raised, it should call this setExpectedError first If you don't call this method first, the test will fail.
- getMockApplication() — Gets a mock application object.
- getMockCmsApp() — Gets a mock CMS application object.
- getMockConfig() — Gets a mock configuration object.
- getMockDatabase() — Gets a mock database object.
- getMockDispatcher() — Gets a mock dispatcher object.
- getMockDocument() — Gets a mock document object.
- getMockLanguage() — Gets a mock language object.
- getMockSession() — Gets a mock session object.
- getMockWeb() — Gets a mock web object.
- setExpectedError() — Tells the unit tests that a method or action you are about to attempt is expected to result in JError::raiseSomething being called.