O'Reilly logo

Drupal 7 Development by Example Beginner's Guide by Kurt Madel

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

Time for action — creating a unit test case for the D7Dev duration formatter

If you recall, the duration formatter (d7dev_integer_duration) is defined in the d7dev module. The GCD function used in the d7dev_field_formatter_view function is a perfect candidate for a unit test, as it is completely self-contained, and does not depend on any external modules nor database interaction.

  1. Expand the sites/all/modules/custom/d7dev folder in Aptana Studio, then right-click on that folder, and create a new folder named tests.
  2. Next, right-click on the newly created tests folder, and create a new file named d7dev.test.
  3. Now, open up the d7dev.info file, and add the following file setting:
    files[] = tests/d7dev.test
    

    Remember, it doesn't matter where you place your ...

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