📄 word.phpt
字号:
<?php/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */// +----------------------------------------------------------------------+// | PHP version 4适适适适适适适适适适适适适适适适适适适适适适适适适适适适|// +----------------------------------------------------------------------+// | Copyright (c) 1997-2002 The PHP Group适适适适适适适适适适适适适适适适|// +----------------------------------------------------------------------+// | This source file is subject to version 2.0 of the PHP license,适适适蕓// | that is bundled with this package in the file LICENSE, and is适适适适|// | available at through the world-wide-web at适适适适适适适适适适适适适蕓// | http://www.php.net/license/2_02.txt.适适适适适适适适适适适适适适适适蕓// | If you did not receive a copy of the PHP license and are unable to适蕓// | obtain it through the world-wide-web, please send a note to适适适适适|// | license@php.net so we can mail you a copy immediately.适适适适适适适蕓// +----------------------------------------------------------------------+// | Author: George Schlossnagle <george@omniti.com> | // +----------------------------------------------------------------------+//// $Id$ require_once "PHPUnit.php"; require_once "Text/Word.php"; class Text_WordTestCase extends PHPUnit_TestCase { var $known_words = array ( 'the' => 1, 'late' => '1', 'hello' => '2', 'frantic' => '2', 'programmer' => '3'); var $special_words = array ( 'absolutely' => 4, 'alien' => 3, 'ion' => 2, 'tortion' => 2, 'gracious' => 2, 'lien' => 1, 'syllable' => 3); function Text_WordTestCase($name) { $this->PHPUnit_TestCase($name); } function testKnownWords() { foreach ($this->known_words as $word => $syllables) { $obj = new Text_Word($word); $this->assertEquals($syllables, $obj->numSyllables(), "$word has incorrect syllable count"); } } function testSpecialWords() { foreach ($this->special_words as $word => $syllables) { $obj = new Text_Word($word); $this->assertEquals($syllables, $obj->numSyllables(), "$word has incorrect syllable count"); } } }if(realpath($_SERVER[PHP_SELF]) == __FILE__) { $suite = new PHPUnit_TestSuite('Text_WordTestCase'); $result = PHPUnit::run($suite); echo $result->toString();}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -