home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / Word.phpt < prev    next >
Encoding:
Text File  |  2004-03-24  |  2.7 KB  |  62 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩|
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2002 The PHP Group╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩|
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,╩╩╩╩╩╩╩|
  9. // | that is bundled with this package in the file LICENSE, and is╩╩╩╩╩╩╩╩|
  10. // | available at through the world-wide-web at╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩|
  11. // | http://www.php.net/license/2_02.txt.╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩|
  12. // | If you did not receive a copy of the PHP license and are unable to╩╩╩|
  13. // | obtain it through the world-wide-web, please send a note to╩╩╩╩╩╩╩╩╩╩|
  14. // | license@php.net so we can mail you a copy immediately.╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩|
  15. // +----------------------------------------------------------------------+
  16. // | Author: George Schlossnagle <george@omniti.com>                      | 
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id$
  20.  
  21.   require_once "PHPUnit.php";
  22.   require_once "Text/Word.php";
  23.  
  24.   class Text_WordTestCase extends PHPUnit_TestCase {
  25.     var $known_words   = array ( 'the' => 1,
  26.                                  'late' => '1',
  27.                                  'hello' => '2',
  28.                                  'frantic' => '2',
  29.                                  'programmer' => '3');
  30.     var $special_words = array ( 'absolutely' => 4,
  31.                                  'alien' => 3,
  32.                                  'ion' => 2,
  33.                                  'tortion' => 2,
  34.                                  'gracious' => 2,
  35.                                  'lien' => 1,
  36.                                  'syllable' => 3);
  37.                    
  38.     function Text_WordTestCase($name) {
  39.       $this->PHPUnit_TestCase($name);
  40.     }
  41.     function testKnownWords() {
  42.       foreach ($this->known_words as $word => $syllables) {
  43.         $obj = new Text_Word($word);
  44.         $this->assertEquals($syllables, $obj->numSyllables(), 
  45.                             "$word has incorrect syllable count");
  46.       }
  47.     }
  48.     function testSpecialWords() {
  49.       foreach ($this->special_words as $word => $syllables) {
  50.         $obj = new Text_Word($word);
  51.         $this->assertEquals($syllables, $obj->numSyllables(), 
  52.                             "$word has incorrect syllable count");
  53.       }
  54.     }
  55.   }
  56. if(realpath($_SERVER[PHP_SELF]) == __FILE__) {
  57.   $suite = new PHPUnit_TestSuite('Text_WordTestCase');
  58.   $result = PHPUnit::run($suite);
  59.   echo $result->toString();
  60. }
  61. ?>
  62.