Plugins::unitTests

From ZenMagick Wiki

(Redirected from Plugins::zm tests)
Jump to: navigation, search

Contents

Description

A framework to easily write and run PHP unit tests. The plugin contains a growing number of unit tests for ZenMagick itself.

The unit testing code uses the SimpleTest framework for the actual execution of tests.

Examples

Simple test case

/**
 * Example test case.
 */
class TestExample extends ZMTestCase {
   /**
    * A single test.
    */
   public function testTrue() {
       $this->assertTrue(1==1);
   }
}

Real life example

/**
 * Test countries service.
 *
 * @package org.zenmagick.plugins.zm_tests.tests
 * @author DerManoMann
 * @version $Id: TestZMCountries.php 1600 2008-10-03 01:02:19Z dermanomann $
 */
class TestZMCountries extends ZMTestCase {
   /**
    * Test load country.
    */
   public function testLoadCountry() {
       $country = ZMCountries::instance()->getCountryForId(14);
       $this->assertNotNull($country);
       $this->assertEqual(14, $country->getId());
       $this->assertEqual('Austria', $country->getName());
   }

   /**
    * Test get zones.
    */
   public function testGetZones() {
       $zones = ZMCountries::instance()->getZonesForCountryId(14);
       $this->assertNotNull($zones);
       $this->assertEqual(9, count($zones));
   }

   /**
    * Test get zone.
    */
   public function testGetZoneCode() {
       $this->assertEqual('BL', ZMCountries::instance()->getZoneCode(14, 102));
   }
}

Demo

The demo store contains a, ahem, demo installation (less tests) of this plugin.

Personal tools