O'Reilly logo

Real-World Solutions for Developing High-Quality PHP Frameworks and Applications by Stefan Priebsch, Sebastian Bergmann

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Testing the ezcGraph Component

Kore Nordmann

WHAT'S IN THIS CHAPTER?

  • Overview of the ezcGraph component

  • Testing requirements for image-generating components

  • Using mock drivers to test the render class

  • Testing the output drivers

  • Working with SVG images

  • Working with bitmap images

  • Working with Adobe Flash graphics

In early 2007, I was asked to design and develop a component to generate graphs for the eZ Components project,[90] for several reasons. I already had lots of experience with image generation, I had already developed a chart library, and a chart library had been requested by the users of eZ Publish several times.

The requirements for components in the eZ Components were a bit different compared to the image libraries I developed before. The eZ Components project focuses on full backward compatibility, ease of use of all APIs, and stability. Backward compatibility and stability can be ensured by well-written unit tests, so all components are intended to be developed via test-driven methodology. Test-driven development of a component purely intended to generate images, which are nothing but binary data, resulted in some problems that had to be solved:

  • Test expectations are hard to craft beforehand.

  • The generated binary data may depend on aspects not defined in the test, such as library versions, dates, or some internal state in the library.

  • Proper comparison methods on binary data can be quite time-consuming.

This chapter shows how these problems were solved while developing the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required