cvs: peardoc /ja/package/php/phpunit intro.xml run.xml testcase.xml /ja/package/php/phpunit/testcase intro.xml
| From: | Haruki Setoyama | Date: | Wed, 20 Oct 2004 11:09:00 +0000 |
| Subject: | cvs: peardoc /ja/package/php/phpunit intro.xml run.xml testcase.xml /ja/package/php/phpunit/testcase intro.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-5005@lists.php.net to get a copy of this message | ||
haruki Wed Oct 20 07:09:00 2004 EDT
Added files:
/peardoc/ja/package/php/phpunit/testcase intro.xml
Modified files:
/peardoc/ja/package/php/phpunit intro.xml run.xml testcase.xml
Log:
translate the remains
http://cvs.php.net/diff.php/peardoc/ja/package/php/phpunit/intro.xml?r1=1.2&r2=1.3&ty=u Index: peardoc/ja/package/php/phpunit/intro.xml diff -u peardoc/ja/package/php/phpunit/intro.xml:1.2 peardoc/ja/package/php/phpunit/intro.xml:1.3 --- peardoc/ja/package/php/phpunit/intro.xml:1.2 Wed Oct 22 11:18:32 2003 +++ peardoc/ja/package/php/phpunit/intro.xml Wed Oct 20 07:09:00 2004 @@ -1,160 +1,156 @@ <?xml encoding="utf-8" ?> -<!-- sync: 1.4 --> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> +<!-- EN-Revision: 1.5 Maintainer: haruki Status: ready --> +<!-- CREDITS: hirokawa --> <refentry id="packages.php.phpunit.intro"> <refnamediv> <refname>ãã¥ã¼ããªã¢ã«</refname> <refpurpose> - PHPUnitã«é¢ããç°¡æãã¥ã¼ããªã¢ã« + PHPUnit ç°¡æãã¥ã¼ããªã¢ã« </refpurpose> </refnamediv> <refsect1> - <title>試é¨ãã¬ã¼ã ã¯ã¼ã¯ã®ç´¹ä»</title> + <title>ãã¹ããã¬ã¼ã ã¯ã¼ã¯ã®ç´¹ä»</title> <para> - <classname>PHPUnit</classname>ã¯ã颿°ãã¯ã©ã¹ã®ãã¹ããèªåçã«è¡ - ããã¹ãã¢ããªã±ã¼ã·ã§ã³ã使ããç°¡åãªä»çµã¿ãæä¾ãã¾ãã - PHPUnitã¯ã<ulink url="&url.junit;">JUnit</ulink>ãããã³ - ããå¾ã¦ãã¾ããKent Beckã¨Erich Gammaãã - <ulink url="&url.extreme.prog;">eXtreme Programming</ulink> - ç¨ã®ãã¼ã«ã¨ãã¦JUnitã使ãã¾ãããXPã®è¦ç´ ã®1ã¤ã¯ã - å°ããªã½ããã¦ã¨ã¢ã³ã³ãã¼ãã³ããå¯è½ãªéãé »ç¹ã«ãããã¦ãæ©æã« - 試é¨ããã¢ããªã±ã¼ã·ã§ã³å ¨ä½ãè¨å®ã試é¨ããéã«APIã®ãã°ãã¨ã©ã¼ã - ãä¿®æ£ããªããã¨ã§ãã - PHPUnitããå©çãå¾ãããã«XPã«ç§»è¡ããå¿ è¦ã¯ããã¾ããã - PHPUnitã¯ãã¯ã©ã¹ã¾ãã¯é¢æ°ã®éã¾ãããã¹ãããããã®æå¹ãªãã¼ã«ã§ - ããããããã°ãééãªãç¶ãããã¨ãé¿ããæå©ãã¨ãªãã¾ãã + <classname>PHPUnit</classname> ã¯ã颿°ãã¯ã©ã¹ãèªåçã«ãã¹ããã + "ãã¹ãã¹ã¤ã¼ã" ã使ããããã®ã·ã³ãã«ãªãã¬ã¼ã ã¯ã¼ã¯ãæä¾ãã¾ãã + PHPUnit ã¯ã<ulink url="&url.junit;">JUnit</ulink> ãããã³ããå¾ã¦ãã¾ãã + JUnit ã¯ãKent Beck 㨠Erich Gamma ãã + <ulink url="&url.extreme.prog;">eXtreme Programming</ulink> (XP) + ç¨ã®ãã¼ã«ã¨ãã¦ä½æããã½ããã¦ã¨ã¢ã§ããXP ã«ããã¦ã¯ã + å°ããªã½ããã¦ã¨ã¢ã³ã³ãã¼ãã³ããå¯è½ãªéãæ©æã«é »ç¹ã«è©¦é¨ãããã¨ã + ã¨ããã«ã¼ã«ãå®ãããã¦ãã¾ãããããããã¨ã§ã + ã¢ããªã±ã¼ã·ã§ã³å ¨ä½ãè¨å®ã試é¨ããéã«ãªã£ã¦ã¾ã§ãã³ã³ãã¼ãã³ãå é¨ã®ãã°ãã¨ã©ã¼ã + ä¿®æ£ããç ´ç®ã«ãªããªãã¦ãã¿ã¾ããã¦ããããã¹ãã¨å¼ã°ãããããã£ãã³ã³ãã¼ãã³ãæ¯ã® + ãã¹ã㯠XP ã®åºæ¬ååã®ã²ã¨ã¤ã§ãããã ããã¨ãã£ã¦ + PHPUnit ãå©ç¨ããããã« XP ãå®è¡ããªãã¨ãããªã訳ã§ã¯ããã¾ããã + PHPUnitã¯ãåä½ã¨ãã¦ãã¯ã©ã¹ã颿°ããã¹ãããæå¹ãªãã¼ã«ã§ããã + ééã®ãªããããã°ä½æ¥ãé¿ããã®ã«æç¨ã§ãã </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.workroutine"> <title>å®è¡æé </title> <para> - é常ãã¯ã©ã¹ã使ãã<function>echo</function> ã¾ã㯠- <function>var_dump</function> ãç¨ãã¦ã·ã¹ãã åããã¦ããªããã㤠- ãã®ãã¹ããè¡ããå ¨ã¦ããã¾ãè¡ããã¨ãé¡ãã¾ããPHPUnitã«ããæ©æµ - ãå¾ãããã«ã¯ããã®æµããåèããå¿ è¦ãããã¾ããæåã®æ¹æ³ã¯ã以 - ä¸ã®ããã«è¡ããã¨ã§ãã + ããã¾ã§ã«è¡ããã¦ããè¯ããããã¹ãæé ã¯ãä½ããã®ã¯ã©ã¹ã使ããå¾ã + <function>echo</function> ã <function>var_dump</function> + ãç¨ãã¦éä½ç³»çã«ãã¹ããè¡ããä¸å ·åãçºçããªããã¨ãé¡ããã¨ããæµãã§ãããã + PHPUnit ã使ã£ã¦å©çãå¾ãããã«ã¯ããã®æµããåèããå¿ è¦ãããã¾ãã + æåã®æé ã¯ã以ä¸ã®éãè¡ããã¨ã§ãã <itemizedlist> <listitem> - <para>1. ã¯ã©ã¹/APIãè¨è¨</para> + <para>1. ã¯ã©ã¹/ API ãè¨è¨</para> </listitem> <listitem> <para>2. ãã¹ãç¨ãã¼ã«ã使</para> </listitem> <listitem> - <para>3. ã¯ã©ã¹/APIãå®è£ </para> + <para>3. ã¯ã©ã¹/ API ãå®è£ </para> </listitem> <listitem> <para>4. ãã¹ãç¨ãã¼ã«ãå®è¡</para> </listitem> <listitem> - <para>5. 失æã¾ãã¯ã¨ã©ã¼ãä¿®æ£ããå度#4ã¸é²ã</para> + <para>5. 失æã¾ãã¯ã¨ã©ã¼ãä¿®æ£ããå度 #4 ã¸é²ã</para> </listitem> </itemizedlist> - ãã®æé ã¯ãå¤ãã®æéãå¿ è¦ã¨ããããã«è¦ãã¾ããããã®å°è±¡ã¯èª¤ã - ã§ããPHPUnitãç¨ãã¦ãã¹ãç¨ãã¼ã«ã使ããã«ã¯æ°åããããããã - ãã¹ãç¨ãã¼ã«ãå®è¡ããã®ã«ã¯ãæ°ç§ãããããã¾ããã + ãã®æé ãè¸ãã¨æéãå¤ãå¿ è¦ã¨ãªãããã«è¦ãã¾ããããã®å°è±¡ã¯èª¤ãã§ãã + PHPUnit ã使ã£ã¦ãã¹ãã¹ã¤ã¼ãã使ããã«ã¯æ°åããããããã + ãã¹ãã¹ã¤ã¼ãã®å®è¡ã«ããæ°ç§ãããããã¾ããã </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.design"> <title>ã¯ã©ã¹ã®è¨è¨</title> <para> - ç°¡åãªä¾ã¨ãã¦ãæååå¦çã¯ã©ã¹ããå§ãã¦ã¿ã¾ããããã¾ããæåå - å¦çãè¡ãä¸é£ã®é¢æ°ã颿°ã®å®£è¨ã以ä¸ã®ããã«ä½æãã¾ãã + ç°¡åãªä¾ã¨ãã¦ãæååãå¦çããã¯ã©ã¹ãåãä¸ãã¾ãã + ã¾ããæååå¦çãè¡ãä¸é£ã®é¢æ°ã®å®£è¨ã以ä¸ã®ããã«ä½æãã¾ãã <programlisting role="php"> <![CDATA[ ----- string.php ---- +//---- 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> + <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. + 次ã«ããã®æååå¦çã¯ã©ã¹ã®å颿°ããã¹ããããã¹ãã¹ã¤ã¼ãã使ãã¾ãã + ãã¹ãã¹ã¤ã¼ãã¯ã <classname>PHPUnit_TestCase + </classname> ãç¶æ¿ããé常㮠PHP ã¯ã©ã¹ã§ããã®ã¯ã©ã¹ä¸ã« + åç§°ã 'test' ã§å§ã¾ã "ãã¹ã颿°" ãå®ç¾©ãã¦ããã¾ãã + ãã¹ã颿°ã«ããã¦ã¯ããã¹ã対象ã®é¢æ°ã®å¸°ãå¤ã¨ + ãããã¹ãæ£ããå¤ã¨ã®æ¯è¼ãè¡ãã¾ãã + ãã®æ¯è¼ã¯ã<function>assert*</function> ç³»ã®é¢æ°ã使ã£ã¦è¡ãã + ãã¹ãã«åæ ¼ãããã©ããã®å¤æãè¡ããã¾ãã <programlisting role="php"> <![CDATA[ ----- testcase.php ---- - -<?php +//---- testcase.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 + // ãã¹ã颿°ãå®è¡ãããåã«ã³ã¼ã«ããã + // ãã®é¢æ°ã¯ PHPUnit_TestCase ã«ã¦å®ç¾©ããã¦ããã + // ããã§ãªã¼ãã¼ã©ã¤ããã¦ãã function setUp() { - // create a new instance of String with the - // string 'abc' + // æ°ããã¤ã³ã¹ã¿ã³ã¹ãæåå'abc'ãè¨å®ãã¦ä½æ $this->abc = new String("abc"); } - // called after the test functions are executed - // this function is defined in PHPUnit_TestCase and overwritten - // here + // ãã¹ã颿°ãå®è¡ãããå¾ã«ã³ã¼ã«ããã + // ãã®é¢æ°ã¯ PHPUnit_TestCase ã«ã¦å®ç¾©ããã¦ããã + // ããã§ãªã¼ãã¼ã©ã¤ããã¦ãã function tearDown() { - // delete your instance + // ã¤ã³ã¹ã¿ã³ã¹ã®åé¤ unset($this->abc); } - // test the toString function + // toString 颿°ã®ãã¹ã function testToString() { $result = $this->abc->toString('contains %s'); $expected = 'contains abc'; $this->assertTrue($result == $expected); } - // test the copy function + // copy 颿°ã®ãã¹ã function testCopy() { $abc2 = $this->abc->copy(); $this->assertEquals($abc2, $this->abc); } - // test the add function + // add 颿°ã®ãã¹ã function testAdd() { $abc2 = new String('123'); $this->abc->add($abc2); @@ -163,21 +159,18 @@ $this->assertTrue($result == $expected); } } -?> ]]> </programlisting> </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.firstrun"> - <title>The first test run</title> + <title>ãã¹ãã®å®è¡</title> <para> - Now, we can run a first test. Execute this PHP program. - Make sure that the paths are correct. + ããã§ã¯ããã¹ããå®è¡ãã¦ã¿ã¾ãããã + ãã¹ãæ£ããã確èªãããã® PHP ããã°ã©ã ãå®è¡ãã¦ãã ããã <programlisting role="php"> <![CDATA[ ----- stringtest.php ---- - -<?php +//---- stringtest.php ---- require_once 'testcase.php'; require_once 'PHPUnit.php'; @@ -186,13 +179,11 @@ $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 @@ -200,93 +191,94 @@ 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>. + ãã©ã¦ã¶ããå®è¡ãããå ´åã¯ã + <function>$result->toString</function> ã <function>$result->toHTML + </function> ã¸å¤æ´ãã¦ãã ãããHTML ãã¼ã¸ãåºåããã¾ãã </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.implement"> - <title>Implementation</title> + <title>å®è£ </title> <para> - Ok, let's start with implementation of the our string class. + æååå¦çã¯ã©ã¹ã®å®è£ ãè¡ãã¾ãããã <programlisting role="php"> <![CDATA[ ----- string.php ---- +//---- 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 + ãããæå¾ã®ãã¹ããä¸åæ ¼ã§ããã¿ã¤ããã¹ãããããã§ãã + <filename>string.php</filename> ã® 16 è¡ç®ã以ä¸ã®æ§ã«ä¿®æ£ãã¾ãã <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>ã¾ã¨ã</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. + ãã£ãï¼ã¤ã®åç´ãªé¢æ°ãããªãã¯ã©ã¹ã«å¯¾ãã¦ã¯ã大è¢è£ãªæé ããç¥ãã¾ããã + ããããä¸è¨ã¯çãä¾ã«éããªãã®ã§ãã£ã¦ããªã³ã©ã¤ã³ã·ã§ããã® + ã·ã§ããã³ã°ã«ã¼ãããã¼ã¿ãã¼ã¹æ½è±¡åã¯ã©ã¹ãªã©ã®ã + 大ããã¦è¤é㪠API ãæã¤ã¯ã©ã¹ãèãã¦è¦ã¦ãã ããã + PHPUnit ã¯ãå®è£ ä¸ã«æ½ããã°ãè¦ã¤ããã®ã«éå¸¸ã«æç¨ãªãã¼ã«ãªã®ã§ãã + </para> + <para> + ã¾ãã以åã«ä½¿ã£ãã¯ã©ã¹ã®åå®è£ ããããããªå ´åãèããã¨ã + ãã¹ãã¹ã¤ã¼ãç¡ãã§ã¯ããã®ã¯ã©ã¹ã«ä¾åããã¢ããªã±ã¼ã·ã§ã³ã« + ä¸å ·åãçºçãããå¯è½æ§ãé«ããªãã¾ãã + ã¾ããã¹ãã¹ã¤ã¼ãã使ããæ°ããã¯ã©ã¹ããã¹ãã«ãã¹ã¦åæ ¼ããããã«ä¿ã£ãã¾ã¾ + åå®è£ ãè¡ã£ã¦ããã°ãã¢ããªã±ã¼ã·ã§ã³ã«ä¸å ·åãèµ·ããäºã¯ãªãã§ãããã </para> </refsect1> </refentry> http://cvs.php.net/diff.php/peardoc/ja/package/php/phpunit/run.xml?r1=1.2&r2=1.3&ty=u Index: peardoc/ja/package/php/phpunit/run.xml diff -u peardoc/ja/package/php/phpunit/run.xml:1.2 peardoc/ja/package/php/phpunit/run.xml:1.3 --- peardoc/ja/package/php/phpunit/run.xml:1.2 Wed Oct 22 11:18:32 2003 +++ peardoc/ja/package/php/phpunit/run.xml Wed Oct 20 07:09:00 2004 @@ -1,10 +1,11 @@ <?xml encoding="utf-8"?> -<!-- sync: 1.4 --> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> +<!-- EN-Revision: 1.4 Maintainer: haruki Status: ready --> +<!-- CREDITS: hirokawa --> <refentry id="package.php.phpunit.run"> <refnamediv> <refname>PHPUnit::run()</refname> - <refpurpose>TestSuiteãå®è¡ããTestResultãªãã¸ã§ã¯ããè¿ã</refpurpose> + <refpurpose>ãã¹ãã¹ã¤ã¼ããå®è¡ããTestResult ãªãã¸ã§ã¯ããè¿ã</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> @@ -22,7 +23,7 @@ <refsect1 id="package.php.phpunit.run.desc"> &title.desc; <para> - æå®ãããã¹ãã¹ã¼ããå®è¡ãã¾ãã + æå®ãããã¹ãã¹ã¤ã¼ããå®è¡ãã¾ãã </para> </refsect1> <refsect1 id="package.php.phpunit.run.parameter"> @@ -31,7 +32,7 @@ <itemizedlist> <listitem> <para> - <parameter>object $suite</parameter> - PHPUnit_TestSuiteã®ãªãã¸ã§ã¯ã + <parameter>object $suite</parameter> - PHPUnit_TestSuite ã®ãªãã¸ã§ã¯ã <!-- <link linkend="package.phpunit.phpunit-testsuite"></link> --> </para> </listitem> @@ -41,7 +42,7 @@ <refsect1 id="package.categorie.mypackage.myfunction.return"> &title.returns; <para> - <parameter>&PHPUnit_Result</parameter> - PHPUnit_Resultã¸ã®ãªãã¡ã¬ã³ã¹ã + <parameter>&PHPUnit_Result</parameter> - PHPUnit_Result ã¸ã®ãªãã¡ã¬ã³ã¹ã <!-- <link linkend="package.phpunit.phpunit-result">PHPUnit_Result</link>. --> </para> </refsect1> @@ -51,12 +52,10 @@ <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> http://cvs.php.net/diff.php/peardoc/ja/package/php/phpunit/testcase.xml?r1=1.3&r2=1.4&ty=u Index: peardoc/ja/package/php/phpunit/testcase.xml diff -u peardoc/ja/package/php/phpunit/testcase.xml:1.3 peardoc/ja/package/php/phpunit/testcase.xml:1.4 --- peardoc/ja/package/php/phpunit/testcase.xml:1.3 Wed Oct 22 11:18:32 2003 +++ peardoc/ja/package/php/phpunit/testcase.xml Wed Oct 20 07:09:00 2004 @@ -1,29 +1,30 @@ <?xml encoding="utf-8" ?> -<!-- sync: 1.2 --> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> +<!-- EN-Revision: 1.2 Maintainer: haruki Status: ready --> +<!-- CREDITS: hirokawa --> <refentry id="package.php.phpunit.testcase"> <refnamediv> <refname><classname>TestCase</classname></refname> - <refpurpose>TestCase: è¤æ°ã®ãã¹ããå®è¡ããããã®è¨å(fixture)ãå®ç¾©ãã</refpurpose> + <refpurpose>TestCase: è¤æ°ã®ãã¹ããå®è¡ããããã®è©¦é¨è£ ç½®</refpurpose> </refnamediv> <refsect1 id="package.php.phpunit.testcase.desc"> &title.desc; <para> &class.testcase; - TestCaseãå®ç¾©ããæé ï¼ + TestCase ãå®ç¾©ããæé ï¼ - 1) PHPUnit_TestCaseã®ãµãã¯ã©ã¹ãå®è£ ãã¾ãã - 2) è¨åã®ç¶æ ãä¿åããã¤ã³ã¹ã¿ã³ã¹å¤æ°ãå®ç¾©ãã¾ãã - 3) setUp()ããªã¼ãã¼ã©ã¤ããããã¨ã«ããè¨åã®ç¶æ ãåæåãã¾ãã - 4) tearDown()ã䏿¸ããããã¨ã«ãããã¹ãå¾ã®æ¸ æãè¡ãã¾ãã + 1) PHPUnit_TestCase ã®ãµãã¯ã©ã¹ãä½ãã¾ã + 2) 試é¨è£ ç½®ã®ç¶æ ãä¿åããã¯ã©ã¹å¤æ°ãå®ç¾©ãã¾ã + 3) setUp() ããªã¼ãã¼ã©ã¤ããããã¨ã«ãã試é¨è£ ç½®ã®ç¶æ ãåæåãã¾ã + 4) tearDown() ã䏿¸ããããã¨ã«ãããã¹ãå¾ã®å¾çä»ããè¡ãã¾ã - åãã¹ãã¯ãåèªã®è¨åã«ããã¦å®è¡ãããããããã¹ãã®å®è¡ã«ããå¯ - ä½ç¨ã¯ããã¾ããã + åãã¹ãã¯ãåèªã®è©¦é¨è£ ç½®ã«ããã¦å®è¡ãããããããã¹ãã®å®è¡ã«ãã + å¯ä½ç¨ã¯ããã¾ããã </para> </refsect1> </refentry> - &package.php.phpunit.testcase.example; + <!-- &package.php.phpunit.testcase.example; --> &package.php.phpunit.testcase.counttestcases; <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/co.php/peardoc/ja/package/php/phpunit/testcase/intro.xml?r=1.1&p=1 Index: peardoc/ja/package/php/phpunit/testcase/intro.xml +++ peardoc/ja/package/php/phpunit/testcase/intro.xml <?xml encoding="utf-8" ?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.3 Maintainer: haruki Status: ready --> <!-- CREDITS: hirokawa --> <refentry id="packages.php.phpunit.testcase.intro"> <refnamediv> <refname>PHPUnit::TestCase</refname> <refpurpose> TestCase: è¤æ°ã®ãã¹ããå®è¡ããããã®è©¦é¨è£ ç½®ã®æ½è±¡å </refpurpose> </refnamediv> <refsect1> <title>TestCase ãå®ç¾©ããæé </title> <para> <itemizedlist> <listitem> <para>1) PHPUnit_TestCase ã®ãµãã¯ã©ã¹ãä½ãã¾ã</para> </listitem> <listitem> <para>2) ã¯ã©ã¹å¤æ°ãå®ç¾©ããããã«è©¦é¨è£ ç½®ã®ç¶æ ãä¿åã§ããããã«ãã¾ã</para> </listitem> <listitem> <para>3) setUp() ããªã¼ãã¼ã©ã¤ããããã¨ã«ãã試é¨è£ ç½®ã®ç¶æ ãåæåãã¾ã</para> </listitem> <listitem> <para>4) tearDown() ã䏿¸ããããã¨ã«ãããã¹ãå¾ã®å¾çä»ããè¡ãã¾ã</para> </listitem> </itemizedlist> åãã¹ãã¯ãå¥åã®è©¦é¨è£ ç½®ã«ããã¦å®è¡ãããããããã¹ãã®å®è¡ã«ãã å¯ä½ç¨ã¯ããã¾ããã </para> </refsect1> <refsect1> <title>PHPUnit::TestCase</title> <para> <programlisting role="php"> <![CDATA[ class MathTest extends PHPUnit_TestCase { var $fValue1; var $fValue2; function MathTest($name) { $this->PHPUnit_TestCase($name); } function setUp() { $this->fValue1 = 2; $this->fValue2 = 3; } } ]]> </programlisting> </para> <para> åãã¹ãã«ããã¦ã¯ã試é¨è£ ç½®ãå©ç¨ãã¦ã¡ã½ãããå®è£ ãã¾ãã æ£ããå¤ãè¿ããããã©ããã¯ãassert 颿°ã« boolean ãæ¸¡ããã¨ã§ 確èªãã¾ãã </para> <para> <programlisting role="php"> <![CDATA[ function testPass() { $this->assertTrue($this->fValue1 + $this->fValue2 == 5); } ]]> </programlisting> </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 -->
http://cvs.php.net/diff.php/peardoc/ja/package/php/phpunit/intro.xml?r1=1.2&r2=1.3&ty=u Index: peardoc/ja/package/php/phpunit/intro.xml diff -u peardoc/ja/package/php/phpunit/intro.xml:1.2 peardoc/ja/package/php/phpunit/intro.xml:1.3 --- peardoc/ja/package/php/phpunit/intro.xml:1.2 Wed Oct 22 11:18:32 2003 +++ peardoc/ja/package/php/phpunit/intro.xml Wed Oct 20 07:09:00 2004 @@ -1,160 +1,156 @@ <?xml encoding="utf-8" ?> -<!-- sync: 1.4 --> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> +<!-- EN-Revision: 1.5 Maintainer: haruki Status: ready --> +<!-- CREDITS: hirokawa --> <refentry id="packages.php.phpunit.intro"> <refnamediv> <refname>ãã¥ã¼ããªã¢ã«</refname> <refpurpose> - PHPUnitã«é¢ããç°¡æãã¥ã¼ããªã¢ã« + PHPUnit ç°¡æãã¥ã¼ããªã¢ã« </refpurpose> </refnamediv> <refsect1> - <title>試é¨ãã¬ã¼ã ã¯ã¼ã¯ã®ç´¹ä»</title> + <title>ãã¹ããã¬ã¼ã ã¯ã¼ã¯ã®ç´¹ä»</title> <para> - <classname>PHPUnit</classname>ã¯ã颿°ãã¯ã©ã¹ã®ãã¹ããèªåçã«è¡ - ããã¹ãã¢ããªã±ã¼ã·ã§ã³ã使ããç°¡åãªä»çµã¿ãæä¾ãã¾ãã - PHPUnitã¯ã<ulink url="&url.junit;">JUnit</ulink>ãããã³ - ããå¾ã¦ãã¾ããKent Beckã¨Erich Gammaãã - <ulink url="&url.extreme.prog;">eXtreme Programming</ulink> - ç¨ã®ãã¼ã«ã¨ãã¦JUnitã使ãã¾ãããXPã®è¦ç´ ã®1ã¤ã¯ã - å°ããªã½ããã¦ã¨ã¢ã³ã³ãã¼ãã³ããå¯è½ãªéãé »ç¹ã«ãããã¦ãæ©æã« - 試é¨ããã¢ããªã±ã¼ã·ã§ã³å ¨ä½ãè¨å®ã試é¨ããéã«APIã®ãã°ãã¨ã©ã¼ã - ãä¿®æ£ããªããã¨ã§ãã - PHPUnitããå©çãå¾ãããã«XPã«ç§»è¡ããå¿ è¦ã¯ããã¾ããã - PHPUnitã¯ãã¯ã©ã¹ã¾ãã¯é¢æ°ã®éã¾ãããã¹ãããããã®æå¹ãªãã¼ã«ã§ - ããããããã°ãééãªãç¶ãããã¨ãé¿ããæå©ãã¨ãªãã¾ãã + <classname>PHPUnit</classname> ã¯ã颿°ãã¯ã©ã¹ãèªåçã«ãã¹ããã + "ãã¹ãã¹ã¤ã¼ã" ã使ããããã®ã·ã³ãã«ãªãã¬ã¼ã ã¯ã¼ã¯ãæä¾ãã¾ãã + PHPUnit ã¯ã<ulink url="&url.junit;">JUnit</ulink> ãããã³ããå¾ã¦ãã¾ãã + JUnit ã¯ãKent Beck 㨠Erich Gamma ãã + <ulink url="&url.extreme.prog;">eXtreme Programming</ulink> (XP) + ç¨ã®ãã¼ã«ã¨ãã¦ä½æããã½ããã¦ã¨ã¢ã§ããXP ã«ããã¦ã¯ã + å°ããªã½ããã¦ã¨ã¢ã³ã³ãã¼ãã³ããå¯è½ãªéãæ©æã«é »ç¹ã«è©¦é¨ãããã¨ã + ã¨ããã«ã¼ã«ãå®ãããã¦ãã¾ãããããããã¨ã§ã + ã¢ããªã±ã¼ã·ã§ã³å ¨ä½ãè¨å®ã試é¨ããéã«ãªã£ã¦ã¾ã§ãã³ã³ãã¼ãã³ãå é¨ã®ãã°ãã¨ã©ã¼ã + ä¿®æ£ããç ´ç®ã«ãªããªãã¦ãã¿ã¾ããã¦ããããã¹ãã¨å¼ã°ãããããã£ãã³ã³ãã¼ãã³ãæ¯ã® + ãã¹ã㯠XP ã®åºæ¬ååã®ã²ã¨ã¤ã§ãããã ããã¨ãã£ã¦ + PHPUnit ãå©ç¨ããããã« XP ãå®è¡ããªãã¨ãããªã訳ã§ã¯ããã¾ããã + PHPUnitã¯ãåä½ã¨ãã¦ãã¯ã©ã¹ã颿°ããã¹ãããæå¹ãªãã¼ã«ã§ããã + ééã®ãªããããã°ä½æ¥ãé¿ããã®ã«æç¨ã§ãã </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.workroutine"> <title>å®è¡æé </title> <para> - é常ãã¯ã©ã¹ã使ãã<function>echo</function> ã¾ã㯠- <function>var_dump</function> ãç¨ãã¦ã·ã¹ãã åããã¦ããªããã㤠- ãã®ãã¹ããè¡ããå ¨ã¦ããã¾ãè¡ããã¨ãé¡ãã¾ããPHPUnitã«ããæ©æµ - ãå¾ãããã«ã¯ããã®æµããåèããå¿ è¦ãããã¾ããæåã®æ¹æ³ã¯ã以 - ä¸ã®ããã«è¡ããã¨ã§ãã + ããã¾ã§ã«è¡ããã¦ããè¯ããããã¹ãæé ã¯ãä½ããã®ã¯ã©ã¹ã使ããå¾ã + <function>echo</function> ã <function>var_dump</function> + ãç¨ãã¦éä½ç³»çã«ãã¹ããè¡ããä¸å ·åãçºçããªããã¨ãé¡ããã¨ããæµãã§ãããã + PHPUnit ã使ã£ã¦å©çãå¾ãããã«ã¯ããã®æµããåèããå¿ è¦ãããã¾ãã + æåã®æé ã¯ã以ä¸ã®éãè¡ããã¨ã§ãã <itemizedlist> <listitem> - <para>1. ã¯ã©ã¹/APIãè¨è¨</para> + <para>1. ã¯ã©ã¹/ API ãè¨è¨</para> </listitem> <listitem> <para>2. ãã¹ãç¨ãã¼ã«ã使</para> </listitem> <listitem> - <para>3. ã¯ã©ã¹/APIãå®è£ </para> + <para>3. ã¯ã©ã¹/ API ãå®è£ </para> </listitem> <listitem> <para>4. ãã¹ãç¨ãã¼ã«ãå®è¡</para> </listitem> <listitem> - <para>5. 失æã¾ãã¯ã¨ã©ã¼ãä¿®æ£ããå度#4ã¸é²ã</para> + <para>5. 失æã¾ãã¯ã¨ã©ã¼ãä¿®æ£ããå度 #4 ã¸é²ã</para> </listitem> </itemizedlist> - ãã®æé ã¯ãå¤ãã®æéãå¿ è¦ã¨ããããã«è¦ãã¾ããããã®å°è±¡ã¯èª¤ã - ã§ããPHPUnitãç¨ãã¦ãã¹ãç¨ãã¼ã«ã使ããã«ã¯æ°åããããããã - ãã¹ãç¨ãã¼ã«ãå®è¡ããã®ã«ã¯ãæ°ç§ãããããã¾ããã + ãã®æé ãè¸ãã¨æéãå¤ãå¿ è¦ã¨ãªãããã«è¦ãã¾ããããã®å°è±¡ã¯èª¤ãã§ãã + PHPUnit ã使ã£ã¦ãã¹ãã¹ã¤ã¼ãã使ããã«ã¯æ°åããããããã + ãã¹ãã¹ã¤ã¼ãã®å®è¡ã«ããæ°ç§ãããããã¾ããã </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.design"> <title>ã¯ã©ã¹ã®è¨è¨</title> <para> - ç°¡åãªä¾ã¨ãã¦ãæååå¦çã¯ã©ã¹ããå§ãã¦ã¿ã¾ããããã¾ããæåå - å¦çãè¡ãä¸é£ã®é¢æ°ã颿°ã®å®£è¨ã以ä¸ã®ããã«ä½æãã¾ãã + ç°¡åãªä¾ã¨ãã¦ãæååãå¦çããã¯ã©ã¹ãåãä¸ãã¾ãã + ã¾ããæååå¦çãè¡ãä¸é£ã®é¢æ°ã®å®£è¨ã以ä¸ã®ããã«ä½æãã¾ãã <programlisting role="php"> <![CDATA[ ----- string.php ---- +//---- 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> + <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. + 次ã«ããã®æååå¦çã¯ã©ã¹ã®å颿°ããã¹ããããã¹ãã¹ã¤ã¼ãã使ãã¾ãã + ãã¹ãã¹ã¤ã¼ãã¯ã <classname>PHPUnit_TestCase + </classname> ãç¶æ¿ããé常㮠PHP ã¯ã©ã¹ã§ããã®ã¯ã©ã¹ä¸ã« + åç§°ã 'test' ã§å§ã¾ã "ãã¹ã颿°" ãå®ç¾©ãã¦ããã¾ãã + ãã¹ã颿°ã«ããã¦ã¯ããã¹ã対象ã®é¢æ°ã®å¸°ãå¤ã¨ + ãããã¹ãæ£ããå¤ã¨ã®æ¯è¼ãè¡ãã¾ãã + ãã®æ¯è¼ã¯ã<function>assert*</function> ç³»ã®é¢æ°ã使ã£ã¦è¡ãã + ãã¹ãã«åæ ¼ãããã©ããã®å¤æãè¡ããã¾ãã <programlisting role="php"> <![CDATA[ ----- testcase.php ---- - -<?php +//---- testcase.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 + // ãã¹ã颿°ãå®è¡ãããåã«ã³ã¼ã«ããã + // ãã®é¢æ°ã¯ PHPUnit_TestCase ã«ã¦å®ç¾©ããã¦ããã + // ããã§ãªã¼ãã¼ã©ã¤ããã¦ãã function setUp() { - // create a new instance of String with the - // string 'abc' + // æ°ããã¤ã³ã¹ã¿ã³ã¹ãæåå'abc'ãè¨å®ãã¦ä½æ $this->abc = new String("abc"); } - // called after the test functions are executed - // this function is defined in PHPUnit_TestCase and overwritten - // here + // ãã¹ã颿°ãå®è¡ãããå¾ã«ã³ã¼ã«ããã + // ãã®é¢æ°ã¯ PHPUnit_TestCase ã«ã¦å®ç¾©ããã¦ããã + // ããã§ãªã¼ãã¼ã©ã¤ããã¦ãã function tearDown() { - // delete your instance + // ã¤ã³ã¹ã¿ã³ã¹ã®åé¤ unset($this->abc); } - // test the toString function + // toString 颿°ã®ãã¹ã function testToString() { $result = $this->abc->toString('contains %s'); $expected = 'contains abc'; $this->assertTrue($result == $expected); } - // test the copy function + // copy 颿°ã®ãã¹ã function testCopy() { $abc2 = $this->abc->copy(); $this->assertEquals($abc2, $this->abc); } - // test the add function + // add 颿°ã®ãã¹ã function testAdd() { $abc2 = new String('123'); $this->abc->add($abc2); @@ -163,21 +159,18 @@ $this->assertTrue($result == $expected); } } -?> ]]> </programlisting> </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.firstrun"> - <title>The first test run</title> + <title>ãã¹ãã®å®è¡</title> <para> - Now, we can run a first test. Execute this PHP program. - Make sure that the paths are correct. + ããã§ã¯ããã¹ããå®è¡ãã¦ã¿ã¾ãããã + ãã¹ãæ£ããã確èªãããã® PHP ããã°ã©ã ãå®è¡ãã¦ãã ããã <programlisting role="php"> <![CDATA[ ----- stringtest.php ---- - -<?php +//---- stringtest.php ---- require_once 'testcase.php'; require_once 'PHPUnit.php'; @@ -186,13 +179,11 @@ $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 @@ -200,93 +191,94 @@ 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>. + ãã©ã¦ã¶ããå®è¡ãããå ´åã¯ã + <function>$result->toString</function> ã <function>$result->toHTML + </function> ã¸å¤æ´ãã¦ãã ãããHTML ãã¼ã¸ãåºåããã¾ãã </para> </refsect1> <refsect1 id="packages.php.phpunit.intro.implement"> - <title>Implementation</title> + <title>å®è£ </title> <para> - Ok, let's start with implementation of the our string class. + æååå¦çã¯ã©ã¹ã®å®è£ ãè¡ãã¾ãããã <programlisting role="php"> <![CDATA[ ----- string.php ---- +//---- 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 + ãããæå¾ã®ãã¹ããä¸åæ ¼ã§ããã¿ã¤ããã¹ãããããã§ãã + <filename>string.php</filename> ã® 16 è¡ç®ã以ä¸ã®æ§ã«ä¿®æ£ãã¾ãã <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>ã¾ã¨ã</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. + ãã£ãï¼ã¤ã®åç´ãªé¢æ°ãããªãã¯ã©ã¹ã«å¯¾ãã¦ã¯ã大è¢è£ãªæé ããç¥ãã¾ããã + ããããä¸è¨ã¯çãä¾ã«éããªãã®ã§ãã£ã¦ããªã³ã©ã¤ã³ã·ã§ããã® + ã·ã§ããã³ã°ã«ã¼ãããã¼ã¿ãã¼ã¹æ½è±¡åã¯ã©ã¹ãªã©ã®ã + 大ããã¦è¤é㪠API ãæã¤ã¯ã©ã¹ãèãã¦è¦ã¦ãã ããã + PHPUnit ã¯ãå®è£ ä¸ã«æ½ããã°ãè¦ã¤ããã®ã«éå¸¸ã«æç¨ãªãã¼ã«ãªã®ã§ãã + </para> + <para> + ã¾ãã以åã«ä½¿ã£ãã¯ã©ã¹ã®åå®è£ ããããããªå ´åãèããã¨ã + ãã¹ãã¹ã¤ã¼ãç¡ãã§ã¯ããã®ã¯ã©ã¹ã«ä¾åããã¢ããªã±ã¼ã·ã§ã³ã« + ä¸å ·åãçºçãããå¯è½æ§ãé«ããªãã¾ãã + ã¾ããã¹ãã¹ã¤ã¼ãã使ããæ°ããã¯ã©ã¹ããã¹ãã«ãã¹ã¦åæ ¼ããããã«ä¿ã£ãã¾ã¾ + åå®è£ ãè¡ã£ã¦ããã°ãã¢ããªã±ã¼ã·ã§ã³ã«ä¸å ·åãèµ·ããäºã¯ãªãã§ãããã </para> </refsect1> </refentry> http://cvs.php.net/diff.php/peardoc/ja/package/php/phpunit/run.xml?r1=1.2&r2=1.3&ty=u Index: peardoc/ja/package/php/phpunit/run.xml diff -u peardoc/ja/package/php/phpunit/run.xml:1.2 peardoc/ja/package/php/phpunit/run.xml:1.3 --- peardoc/ja/package/php/phpunit/run.xml:1.2 Wed Oct 22 11:18:32 2003 +++ peardoc/ja/package/php/phpunit/run.xml Wed Oct 20 07:09:00 2004 @@ -1,10 +1,11 @@ <?xml encoding="utf-8"?> -<!-- sync: 1.4 --> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> +<!-- EN-Revision: 1.4 Maintainer: haruki Status: ready --> +<!-- CREDITS: hirokawa --> <refentry id="package.php.phpunit.run"> <refnamediv> <refname>PHPUnit::run()</refname> - <refpurpose>TestSuiteãå®è¡ããTestResultãªãã¸ã§ã¯ããè¿ã</refpurpose> + <refpurpose>ãã¹ãã¹ã¤ã¼ããå®è¡ããTestResult ãªãã¸ã§ã¯ããè¿ã</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> @@ -22,7 +23,7 @@ <refsect1 id="package.php.phpunit.run.desc"> &title.desc; <para> - æå®ãããã¹ãã¹ã¼ããå®è¡ãã¾ãã + æå®ãããã¹ãã¹ã¤ã¼ããå®è¡ãã¾ãã </para> </refsect1> <refsect1 id="package.php.phpunit.run.parameter"> @@ -31,7 +32,7 @@ <itemizedlist> <listitem> <para> - <parameter>object $suite</parameter> - PHPUnit_TestSuiteã®ãªãã¸ã§ã¯ã + <parameter>object $suite</parameter> - PHPUnit_TestSuite ã®ãªãã¸ã§ã¯ã <!-- <link linkend="package.phpunit.phpunit-testsuite"></link> --> </para> </listitem> @@ -41,7 +42,7 @@ <refsect1 id="package.categorie.mypackage.myfunction.return"> &title.returns; <para> - <parameter>&PHPUnit_Result</parameter> - PHPUnit_Resultã¸ã®ãªãã¡ã¬ã³ã¹ã + <parameter>&PHPUnit_Result</parameter> - PHPUnit_Result ã¸ã®ãªãã¡ã¬ã³ã¹ã <!-- <link linkend="package.phpunit.phpunit-result">PHPUnit_Result</link>. --> </para> </refsect1> @@ -51,12 +52,10 @@ <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> http://cvs.php.net/diff.php/peardoc/ja/package/php/phpunit/testcase.xml?r1=1.3&r2=1.4&ty=u Index: peardoc/ja/package/php/phpunit/testcase.xml diff -u peardoc/ja/package/php/phpunit/testcase.xml:1.3 peardoc/ja/package/php/phpunit/testcase.xml:1.4 --- peardoc/ja/package/php/phpunit/testcase.xml:1.3 Wed Oct 22 11:18:32 2003 +++ peardoc/ja/package/php/phpunit/testcase.xml Wed Oct 20 07:09:00 2004 @@ -1,29 +1,30 @@ <?xml encoding="utf-8" ?> -<!-- sync: 1.2 --> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> +<!-- EN-Revision: 1.2 Maintainer: haruki Status: ready --> +<!-- CREDITS: hirokawa --> <refentry id="package.php.phpunit.testcase"> <refnamediv> <refname><classname>TestCase</classname></refname> - <refpurpose>TestCase: è¤æ°ã®ãã¹ããå®è¡ããããã®è¨å(fixture)ãå®ç¾©ãã</refpurpose> + <refpurpose>TestCase: è¤æ°ã®ãã¹ããå®è¡ããããã®è©¦é¨è£ ç½®</refpurpose> </refnamediv> <refsect1 id="package.php.phpunit.testcase.desc"> &title.desc; <para> &class.testcase; - TestCaseãå®ç¾©ããæé ï¼ + TestCase ãå®ç¾©ããæé ï¼ - 1) PHPUnit_TestCaseã®ãµãã¯ã©ã¹ãå®è£ ãã¾ãã - 2) è¨åã®ç¶æ ãä¿åããã¤ã³ã¹ã¿ã³ã¹å¤æ°ãå®ç¾©ãã¾ãã - 3) setUp()ããªã¼ãã¼ã©ã¤ããããã¨ã«ããè¨åã®ç¶æ ãåæåãã¾ãã - 4) tearDown()ã䏿¸ããããã¨ã«ãããã¹ãå¾ã®æ¸ æãè¡ãã¾ãã + 1) PHPUnit_TestCase ã®ãµãã¯ã©ã¹ãä½ãã¾ã + 2) 試é¨è£ ç½®ã®ç¶æ ãä¿åããã¯ã©ã¹å¤æ°ãå®ç¾©ãã¾ã + 3) setUp() ããªã¼ãã¼ã©ã¤ããããã¨ã«ãã試é¨è£ ç½®ã®ç¶æ ãåæåãã¾ã + 4) tearDown() ã䏿¸ããããã¨ã«ãããã¹ãå¾ã®å¾çä»ããè¡ãã¾ã - åãã¹ãã¯ãåèªã®è¨åã«ããã¦å®è¡ãããããããã¹ãã®å®è¡ã«ããå¯ - ä½ç¨ã¯ããã¾ããã + åãã¹ãã¯ãåèªã®è©¦é¨è£ ç½®ã«ããã¦å®è¡ãããããããã¹ãã®å®è¡ã«ãã + å¯ä½ç¨ã¯ããã¾ããã </para> </refsect1> </refentry> - &package.php.phpunit.testcase.example; + <!-- &package.php.phpunit.testcase.example; --> &package.php.phpunit.testcase.counttestcases; <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/co.php/peardoc/ja/package/php/phpunit/testcase/intro.xml?r=1.1&p=1 Index: peardoc/ja/package/php/phpunit/testcase/intro.xml +++ peardoc/ja/package/php/phpunit/testcase/intro.xml <?xml encoding="utf-8" ?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.3 Maintainer: haruki Status: ready --> <!-- CREDITS: hirokawa --> <refentry id="packages.php.phpunit.testcase.intro"> <refnamediv> <refname>PHPUnit::TestCase</refname> <refpurpose> TestCase: è¤æ°ã®ãã¹ããå®è¡ããããã®è©¦é¨è£ ç½®ã®æ½è±¡å </refpurpose> </refnamediv> <refsect1> <title>TestCase ãå®ç¾©ããæé </title> <para> <itemizedlist> <listitem> <para>1) PHPUnit_TestCase ã®ãµãã¯ã©ã¹ãä½ãã¾ã</para> </listitem> <listitem> <para>2) ã¯ã©ã¹å¤æ°ãå®ç¾©ããããã«è©¦é¨è£ ç½®ã®ç¶æ ãä¿åã§ããããã«ãã¾ã</para> </listitem> <listitem> <para>3) setUp() ããªã¼ãã¼ã©ã¤ããããã¨ã«ãã試é¨è£ ç½®ã®ç¶æ ãåæåãã¾ã</para> </listitem> <listitem> <para>4) tearDown() ã䏿¸ããããã¨ã«ãããã¹ãå¾ã®å¾çä»ããè¡ãã¾ã</para> </listitem> </itemizedlist> åãã¹ãã¯ãå¥åã®è©¦é¨è£ ç½®ã«ããã¦å®è¡ãããããããã¹ãã®å®è¡ã«ãã å¯ä½ç¨ã¯ããã¾ããã </para> </refsect1> <refsect1> <title>PHPUnit::TestCase</title> <para> <programlisting role="php"> <![CDATA[ class MathTest extends PHPUnit_TestCase { var $fValue1; var $fValue2; function MathTest($name) { $this->PHPUnit_TestCase($name); } function setUp() { $this->fValue1 = 2; $this->fValue2 = 3; } } ]]> </programlisting> </para> <para> åãã¹ãã«ããã¦ã¯ã試é¨è£ ç½®ãå©ç¨ãã¦ã¡ã½ãããå®è£ ãã¾ãã æ£ããå¤ãè¿ããããã©ããã¯ãassert 颿°ã« boolean ãæ¸¡ããã¨ã§ 確èªãã¾ãã </para> <para> <programlisting role="php"> <![CDATA[ function testPass() { $this->assertTrue($this->fValue1 + $this->fValue2 == 5); } ]]> </programlisting> </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 -->