cvs: peardoc /ja/package/php/phpunit intro.xml run.xml testcase.xml
| From: | Rui Hirokawa | Date: | Sat, 05 Apr 2003 05:31:39 +0000 |
| Subject: | cvs: peardoc /ja/package/php/phpunit intro.xml run.xml testcase.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-605@lists.php.net to get a copy of this message | ||
hirokawa Sat Apr 5 00:31:39 2003 EDT
Added files:
/peardoc/ja/package/php/phpunit intro.xml run.xml testcase.xml
Log:
added phpunit/*.xml
Index: peardoc/ja/package/php/phpunit/intro.xml +++ peardoc/ja/package/php/phpunit/intro.xml <?xml version="1.0" encoding="utf-8" ?> <!-- $Revision: 1.1 $ --> <refentry id="packages.php.phpunit.intro"> <refnamediv> <refname>ãã¥ã¼ããªã¢ã«</refname> <refpurpose> PHPUnitã«é¢ããç°¡æãã¥ã¼ããªã¢ã« </refpurpose> </refnamediv> <refsect1> <title>試é¨ãã¬ã¼ã ã¯ã¼ã¯ã®ç´¹ä»</title> <para> <classname>PHPUnit</classname>ã¯ã颿°ãã¯ã©ã¹ã®ãã¹ããèªåçã«è¡ ããã¹ãã¢ããªã±ã¼ã·ã§ã³ã使ããç°¡åãªä»çµã¿ãæä¾ãã¾ãã PHPUnitã¯ã<ulink url="http://www.junit.org">JUnit</ulink>ãããã³ ããå¾ã¦ãã¾ããKent Beckã¨Erich Gammaãã <ulink url="http://xprogramming.com">eXtreme Programming</ulink> ç¨ã®ãã¼ã«ã¨ãã¦JUnitã使ãã¾ãããXPã®è¦ç´ ã®1ã¤ã¯ã å°ããªã½ããã¦ã¨ã¢ã³ã³ãã¼ãã³ããå¯è½ãªéãé »ç¹ã«ãããã¦ãæ©æã« è©¦é¨ããã¢ããªã±ã¼ã·ã§ã³å ¨ä½ãè¨å®ã試é¨ããéã«APIã®ãã°ãã¨ã©ã¼ã ãä¿®æ£ããªããã¨ã§ãã PHPUnitããå©çãå¾ãããã«XPã«ç§»è¡ããå¿ è¦ã¯ããã¾ããã PHPUnitã¯ãã¯ã©ã¹ã¾ãã¯é¢æ°ã®éã¾ãããã¹ãããããã®æå¹ãªãã¼ã«ã§ ããããããã°ãééãªãç¶ãããã¨ãé¿ããæå©ãã¨ãªãã¾ãã </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.workroutine"> <title>å®è¡æé </title> <para> é常ãã¯ã©ã¹ã使ãã<function>echo</function> ã¾ã㯠<function>var_dump</function> ãç¨ãã¦ã·ã¹ãã åããã¦ããªããã㤠ãã®ãã¹ããè¡ããå ¨ã¦ããã¾ãè¡ããã¨ãé¡ãã¾ããPHPUnitã«ããæ©æµ ãå¾ãããã«ã¯ããã®æµããåèããå¿ è¦ãããã¾ããæåã®æ¹æ³ã¯ã以 ä¸ã®ããã«è¡ããã¨ã§ãã <itemizedlist> <listitem> <para>1. ã¯ã©ã¹/APIãè¨è¨</para> </listitem> <listitem> <para>2. ãã¹ãç¨ãã¼ã«ã使</para> </listitem> <listitem> <para>3. ã¯ã©ã¹/APIãå®è£ </para> </listitem> <listitem> <para>4. ãã¹ãç¨ãã¼ã«ãå®è¡</para> </listitem> <listitem> <para>5. 失æã¾ãã¯ã¨ã©ã¼ãä¿®æ£ããå度#4ã¸é²ã</para> </listitem> </itemizedlist> ãã®æé ã¯ãå¤ãã®æéãå¿ è¦ã¨ããããã«è¦ãã¾ããããã®å°è±¡ã¯èª¤ã ã§ããPHPUnitãç¨ãã¦ãã¹ãç¨ãã¼ã«ã使ããã«ã¯æ°åããããããã ãã¹ãç¨ãã¼ã«ãå®è¡ããã®ã«ã¯ãæ°ç§ãããããã¾ããã </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.design"> <title>ã¯ã©ã¹ã®è¨è¨</title> <para> ç°¡åãªä¾ã¨ãã¦ãæååå¦çã¯ã©ã¹ããå§ãã¦ã¿ã¾ããããã¾ããæåå å¦çãè¡ãä¸é£ã®é¢æ°ã颿°ã®å®£è¨ã以ä¸ã®ããã«ä½æãã¾ãã <programlisting role="php"> <![CDATA[ ---- string.php ---- <?php class String { //contains the internal data var $data; // constructor function String($data) { $this->data = $data; } // creates a deep copy of the string object function copy() { } // adds another string object to this class function add($string) { } // returns the formated string function toString($format) { } } ?> ]]> </programlisting> </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.testsuite"> <title>ãã¹ãç¨ã¹ã¼ãã®ä½æ</title> <para> Now we can create a test suite, which checks every function of your string class. A test suite is normal PHP class inherited from <classname>PHPUnit_TestCase </classname> containing test functions, identified by a leading 'test' in the function name. In the test function an expected value has to be compared with the result of the function to test. The result of this compare must delegate to a function of the <function>assert*</function>-family, which decides if a function pass or fail the test. <programlisting role="php"> <![CDATA[ ---- testcase.php ---- <?php require_once 'string.php'; require_once 'PHPUnit.php'; class StringTest extends PHPUnit_TestCase { // contains the object handle of the string class var $abc; // constructor of the test suite function StringTest($name) { $this->PHPUnit_TestCase($name); } // called before the test functions will be executed // this function is defined in PHPUnit_TestCase and overwritten // here function setUp() { // create a new instance of String with the // string 'abc' $this->abc = new String("abc"); } // called after the test functions are executed // this function is defined in PHPUnit_TestCase and overwritten // here function tearDown() { // delete your instance unset($this->abc); } // test the toString function function testToString() { $result = $this->abc->toString('contains %s'); $expected = 'contains abc'; $this->assertTrue($result == $expected); } // test the copy function function testCopy() { $abc2 = $this->abc->copy(); $this->assertEquals($abc2, $this->abc); } // test the add function function testAdd() { $abc2 = new String('123'); $this->abc->add($abc2); $result = $this->abc->toString("%s"); $expected = "abc123"; $this->assertTrue($result == $expected); } } ?> ]]> </programlisting> </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.firstrun"> <title>The first test run</title> <para> Now, we can run a first test. Execute this PHP program. Make sure that the paths are correct. <programlisting role="php"> <![CDATA[ ---- stringtest.php ---- <?php require_once 'testcase.php'; require_once 'PHPUnit.php'; $suite = new PHPUnit_TestSuite("StringTest"); $result = PHPUnit::run($suite); echo $result -> toString(); ?> ]]> </programlisting> </para> <para> If you call this script through commandline, you will get this output: <programlisting> <![CDATA[ TestCase stringtest->testtostring() failed: expected true, actual false TestCase stringtest->testcopy() failed: expected , actual Object TestCase stringtest->testadd() failed: expected true, actual false ]]> </programlisting> Every function fails the test, because your string functions didn't returned what we defined as the expected value. </para> <para> If you want to call the script through your browser, you have to put the script in a correct html page and call <function>$result->toHTML </function> instead of <function>$result->toString</function>. </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.implement"> <title>Implementation</title> <para> Ok, let's start with implementation of the our string class. <programlisting role="php"> <![CDATA[ ---- string.php ---- <?php class String { //contains the internal data var $data; // constructor function String($data) { $this->data = $data; } // creates a deep copy of the string object function copy() { $ret = new String($this->data); return $ret; } // adds another string object to this class function add($string) { $this->data = $this->data.$string->toString("%ss"); } // returns the formated string function toString($format) { $ret = sprintf($format, $this->data); return $ret; } } ?> ]]> </programlisting> </para> <para> Implementing is done and run the test again: <programlisting> ~> <command>php -f stringtest.php</command> TestCase stringtest->testtostring() passed TestCase stringtest->testcopy() passed TestCase stringtest->testadd() failed: expected true, actual false </programlisting> D'oh! the last test failed! We did a typing mistake. Change line 16 in <filename>string.php</filename> to <programlisting role="php"> <![CDATA[ $this->data = $this->data.$string->toString("%s"); ]]> </programlisting> and run the test again: <programlisting> ~> <command>php -f stringtest.php</command> TestCase stringtest->testtostring() passed TestCase stringtest->testcopy() passed TestCase stringtest->testadd() passed </programlisting> Everything is ok now! </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.conclusion"> <title>Conclusion</title> <para> Hm, such a big expenditure for testing three simple functions? Don't forget, this is a small example. Think about bigger, complexer API's like database abstraction or basket classes in a shop application. PHPUnit is an excellent tool to detect errors in the implementation. Maybe you have a big class used in a few applications and you want to reimplement the class. With a test suite, you can easily check and fix the new implementation in a short session. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/ja/package/php/phpunit/run.xml +++ peardoc/ja/package/php/phpunit/run.xml <!-- $Revision: 1.1 $ --> <refentry id="package.php.phpunit.run"> <refnamediv> <refname>PHPUnit::run()</refname> <refpurpose>runs a TestSuite and returns a TestResult object.</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcsynopsisinfo> require_once 'PHPUnit.php'; </funcsynopsisinfo> <funcprototype> <funcdef>object <function>PHPUnit::run</function></funcdef> <paramdef> object <parameter>$suite</parameter> </paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.php.phpunit.run.desc"> &title.desc; <para> Executes the given test suite </para> </refsect1> <refsect1 id="package.php.phpunit.run.parameter"> &title.param; <para> <itemizedlist> <listitem> <para> <parameter>object $suite</parameter> - an object of <link linkend="packages.phpunit.phpunit-testsuite">PHPUnit_TestSuite</link> </para> </listitem> </itemizedlist> </para> </refsect1> <refsect1 id="package.categorie.mypackage.myfunction.return"> &title.returns; <para> <parameter>&PHPUnit_Result</parameter> - A reference to a <link linkend="packages.phpunit.phpunit-result">PHPUnit_Result</link>. </para> </refsect1> <refsect1 id="packages.php.phpunit.run.example"> &title.example; <example> <title>Using <function>PHPUnit::run</function></title> <programlisting role="php"> <![CDATA[ <?php require_once "PHPUnit.php"; $suite = New PHPUnit_TestSuite('Mathtest'); $result = PHPUnit::run($suite); echo $result->toHtml(); ?> ]]> </programlisting> </example> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/ja/package/php/phpunit/testcase.xml +++ peardoc/ja/package/php/phpunit/testcase.xml <refentry id="package.php.phpunit.testcase"> <refnamediv> <refname><classname>TestCase</classname></refname> <refpurpose>A TestCase defines the fixture to run multiple tests.</refpurpose> </refnamediv> <refsect1 id="package.php.phpunit.testcase.desc"> &title.desc; <para> &class.testcase; To define a TestCase 1) Implement a subclass of PHPUnit_TestCase. 2) Define instance variables that store the state of the fixture. 3) Initialize the fixture state by overriding setUp(). 4) Clean-up after a test by overriding tearDown(). Each test runs in its own fixture so there can be no side effects among test runs. </para> </refsect1> </refentry> &package.php.phpunit.testcase.example; &package.php.phpunit.testcase.counttestcases; <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
Index: peardoc/ja/package/php/phpunit/intro.xml +++ peardoc/ja/package/php/phpunit/intro.xml <?xml version="1.0" encoding="utf-8" ?> <!-- $Revision: 1.1 $ --> <refentry id="packages.php.phpunit.intro"> <refnamediv> <refname>ãã¥ã¼ããªã¢ã«</refname> <refpurpose> PHPUnitã«é¢ããç°¡æãã¥ã¼ããªã¢ã« </refpurpose> </refnamediv> <refsect1> <title>試é¨ãã¬ã¼ã ã¯ã¼ã¯ã®ç´¹ä»</title> <para> <classname>PHPUnit</classname>ã¯ã颿°ãã¯ã©ã¹ã®ãã¹ããèªåçã«è¡ ããã¹ãã¢ããªã±ã¼ã·ã§ã³ã使ããç°¡åãªä»çµã¿ãæä¾ãã¾ãã PHPUnitã¯ã<ulink url="http://www.junit.org">JUnit</ulink>ãããã³ ããå¾ã¦ãã¾ããKent Beckã¨Erich Gammaãã <ulink url="http://xprogramming.com">eXtreme Programming</ulink> ç¨ã®ãã¼ã«ã¨ãã¦JUnitã使ãã¾ãããXPã®è¦ç´ ã®1ã¤ã¯ã å°ããªã½ããã¦ã¨ã¢ã³ã³ãã¼ãã³ããå¯è½ãªéãé »ç¹ã«ãããã¦ãæ©æã« è©¦é¨ããã¢ããªã±ã¼ã·ã§ã³å ¨ä½ãè¨å®ã試é¨ããéã«APIã®ãã°ãã¨ã©ã¼ã ãä¿®æ£ããªããã¨ã§ãã PHPUnitããå©çãå¾ãããã«XPã«ç§»è¡ããå¿ è¦ã¯ããã¾ããã PHPUnitã¯ãã¯ã©ã¹ã¾ãã¯é¢æ°ã®éã¾ãããã¹ãããããã®æå¹ãªãã¼ã«ã§ ããããããã°ãééãªãç¶ãããã¨ãé¿ããæå©ãã¨ãªãã¾ãã </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.workroutine"> <title>å®è¡æé </title> <para> é常ãã¯ã©ã¹ã使ãã<function>echo</function> ã¾ã㯠<function>var_dump</function> ãç¨ãã¦ã·ã¹ãã åããã¦ããªããã㤠ãã®ãã¹ããè¡ããå ¨ã¦ããã¾ãè¡ããã¨ãé¡ãã¾ããPHPUnitã«ããæ©æµ ãå¾ãããã«ã¯ããã®æµããåèããå¿ è¦ãããã¾ããæåã®æ¹æ³ã¯ã以 ä¸ã®ããã«è¡ããã¨ã§ãã <itemizedlist> <listitem> <para>1. ã¯ã©ã¹/APIãè¨è¨</para> </listitem> <listitem> <para>2. ãã¹ãç¨ãã¼ã«ã使</para> </listitem> <listitem> <para>3. ã¯ã©ã¹/APIãå®è£ </para> </listitem> <listitem> <para>4. ãã¹ãç¨ãã¼ã«ãå®è¡</para> </listitem> <listitem> <para>5. 失æã¾ãã¯ã¨ã©ã¼ãä¿®æ£ããå度#4ã¸é²ã</para> </listitem> </itemizedlist> ãã®æé ã¯ãå¤ãã®æéãå¿ è¦ã¨ããããã«è¦ãã¾ããããã®å°è±¡ã¯èª¤ã ã§ããPHPUnitãç¨ãã¦ãã¹ãç¨ãã¼ã«ã使ããã«ã¯æ°åããããããã ãã¹ãç¨ãã¼ã«ãå®è¡ããã®ã«ã¯ãæ°ç§ãããããã¾ããã </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.design"> <title>ã¯ã©ã¹ã®è¨è¨</title> <para> ç°¡åãªä¾ã¨ãã¦ãæååå¦çã¯ã©ã¹ããå§ãã¦ã¿ã¾ããããã¾ããæåå å¦çãè¡ãä¸é£ã®é¢æ°ã颿°ã®å®£è¨ã以ä¸ã®ããã«ä½æãã¾ãã <programlisting role="php"> <![CDATA[ ---- string.php ---- <?php class String { //contains the internal data var $data; // constructor function String($data) { $this->data = $data; } // creates a deep copy of the string object function copy() { } // adds another string object to this class function add($string) { } // returns the formated string function toString($format) { } } ?> ]]> </programlisting> </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.testsuite"> <title>ãã¹ãç¨ã¹ã¼ãã®ä½æ</title> <para> Now we can create a test suite, which checks every function of your string class. A test suite is normal PHP class inherited from <classname>PHPUnit_TestCase </classname> containing test functions, identified by a leading 'test' in the function name. In the test function an expected value has to be compared with the result of the function to test. The result of this compare must delegate to a function of the <function>assert*</function>-family, which decides if a function pass or fail the test. <programlisting role="php"> <![CDATA[ ---- testcase.php ---- <?php require_once 'string.php'; require_once 'PHPUnit.php'; class StringTest extends PHPUnit_TestCase { // contains the object handle of the string class var $abc; // constructor of the test suite function StringTest($name) { $this->PHPUnit_TestCase($name); } // called before the test functions will be executed // this function is defined in PHPUnit_TestCase and overwritten // here function setUp() { // create a new instance of String with the // string 'abc' $this->abc = new String("abc"); } // called after the test functions are executed // this function is defined in PHPUnit_TestCase and overwritten // here function tearDown() { // delete your instance unset($this->abc); } // test the toString function function testToString() { $result = $this->abc->toString('contains %s'); $expected = 'contains abc'; $this->assertTrue($result == $expected); } // test the copy function function testCopy() { $abc2 = $this->abc->copy(); $this->assertEquals($abc2, $this->abc); } // test the add function function testAdd() { $abc2 = new String('123'); $this->abc->add($abc2); $result = $this->abc->toString("%s"); $expected = "abc123"; $this->assertTrue($result == $expected); } } ?> ]]> </programlisting> </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.firstrun"> <title>The first test run</title> <para> Now, we can run a first test. Execute this PHP program. Make sure that the paths are correct. <programlisting role="php"> <![CDATA[ ---- stringtest.php ---- <?php require_once 'testcase.php'; require_once 'PHPUnit.php'; $suite = new PHPUnit_TestSuite("StringTest"); $result = PHPUnit::run($suite); echo $result -> toString(); ?> ]]> </programlisting> </para> <para> If you call this script through commandline, you will get this output: <programlisting> <![CDATA[ TestCase stringtest->testtostring() failed: expected true, actual false TestCase stringtest->testcopy() failed: expected , actual Object TestCase stringtest->testadd() failed: expected true, actual false ]]> </programlisting> Every function fails the test, because your string functions didn't returned what we defined as the expected value. </para> <para> If you want to call the script through your browser, you have to put the script in a correct html page and call <function>$result->toHTML </function> instead of <function>$result->toString</function>. </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.implement"> <title>Implementation</title> <para> Ok, let's start with implementation of the our string class. <programlisting role="php"> <![CDATA[ ---- string.php ---- <?php class String { //contains the internal data var $data; // constructor function String($data) { $this->data = $data; } // creates a deep copy of the string object function copy() { $ret = new String($this->data); return $ret; } // adds another string object to this class function add($string) { $this->data = $this->data.$string->toString("%ss"); } // returns the formated string function toString($format) { $ret = sprintf($format, $this->data); return $ret; } } ?> ]]> </programlisting> </para> <para> Implementing is done and run the test again: <programlisting> ~> <command>php -f stringtest.php</command> TestCase stringtest->testtostring() passed TestCase stringtest->testcopy() passed TestCase stringtest->testadd() failed: expected true, actual false </programlisting> D'oh! the last test failed! We did a typing mistake. Change line 16 in <filename>string.php</filename> to <programlisting role="php"> <![CDATA[ $this->data = $this->data.$string->toString("%s"); ]]> </programlisting> and run the test again: <programlisting> ~> <command>php -f stringtest.php</command> TestCase stringtest->testtostring() passed TestCase stringtest->testcopy() passed TestCase stringtest->testadd() passed </programlisting> Everything is ok now! </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.conclusion"> <title>Conclusion</title> <para> Hm, such a big expenditure for testing three simple functions? Don't forget, this is a small example. Think about bigger, complexer API's like database abstraction or basket classes in a shop application. PHPUnit is an excellent tool to detect errors in the implementation. Maybe you have a big class used in a few applications and you want to reimplement the class. With a test suite, you can easily check and fix the new implementation in a short session. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/ja/package/php/phpunit/run.xml +++ peardoc/ja/package/php/phpunit/run.xml <!-- $Revision: 1.1 $ --> <refentry id="package.php.phpunit.run"> <refnamediv> <refname>PHPUnit::run()</refname> <refpurpose>runs a TestSuite and returns a TestResult object.</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcsynopsisinfo> require_once 'PHPUnit.php'; </funcsynopsisinfo> <funcprototype> <funcdef>object <function>PHPUnit::run</function></funcdef> <paramdef> object <parameter>$suite</parameter> </paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.php.phpunit.run.desc"> &title.desc; <para> Executes the given test suite </para> </refsect1> <refsect1 id="package.php.phpunit.run.parameter"> &title.param; <para> <itemizedlist> <listitem> <para> <parameter>object $suite</parameter> - an object of <link linkend="packages.phpunit.phpunit-testsuite">PHPUnit_TestSuite</link> </para> </listitem> </itemizedlist> </para> </refsect1> <refsect1 id="package.categorie.mypackage.myfunction.return"> &title.returns; <para> <parameter>&PHPUnit_Result</parameter> - A reference to a <link linkend="packages.phpunit.phpunit-result">PHPUnit_Result</link>. </para> </refsect1> <refsect1 id="packages.php.phpunit.run.example"> &title.example; <example> <title>Using <function>PHPUnit::run</function></title> <programlisting role="php"> <![CDATA[ <?php require_once "PHPUnit.php"; $suite = New PHPUnit_TestSuite('Mathtest'); $result = PHPUnit::run($suite); echo $result->toHtml(); ?> ]]> </programlisting> </example> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/ja/package/php/phpunit/testcase.xml +++ peardoc/ja/package/php/phpunit/testcase.xml <refentry id="package.php.phpunit.testcase"> <refnamediv> <refname><classname>TestCase</classname></refname> <refpurpose>A TestCase defines the fixture to run multiple tests.</refpurpose> </refnamediv> <refsect1 id="package.php.phpunit.testcase.desc"> &title.desc; <para> &class.testcase; To define a TestCase 1) Implement a subclass of PHPUnit_TestCase. 2) Define instance variables that store the state of the fixture. 3) Initialize the fixture state by overriding setUp(). 4) Clean-up after a test by overriding tearDown(). Each test runs in its own fixture so there can be no side effects among test runs. </para> </refsect1> </refentry> &package.php.phpunit.testcase.example; &package.php.phpunit.testcase.counttestcases; <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->