<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
		<id>https://wiki.nonip.net/index.php?action=history&amp;feed=atom&amp;title=Php%2Fphpunit%2F%E3%83%A2%E3%83%83%E3%82%AF%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%2F%E3%83%86%E3%82%B9%E3%83%88%E5%AF%BE%E8%B1%A1%E3%81%8Cconstruct%E3%82%92%E5%90%AB%E3%81%BE%E3%81%AA%E3%81%84%E5%A0%B4%E5%90%88</id>
		<title>Php/phpunit/モックオブジェクト/テスト対象がconstructを含まない場合 - 変更履歴</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.nonip.net/index.php?action=history&amp;feed=atom&amp;title=Php%2Fphpunit%2F%E3%83%A2%E3%83%83%E3%82%AF%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%2F%E3%83%86%E3%82%B9%E3%83%88%E5%AF%BE%E8%B1%A1%E3%81%8Cconstruct%E3%82%92%E5%90%AB%E3%81%BE%E3%81%AA%E3%81%84%E5%A0%B4%E5%90%88"/>
		<link rel="alternate" type="text/html" href="https://wiki.nonip.net/index.php?title=Php/phpunit/%E3%83%A2%E3%83%83%E3%82%AF%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88/%E3%83%86%E3%82%B9%E3%83%88%E5%AF%BE%E8%B1%A1%E3%81%8Cconstruct%E3%82%92%E5%90%AB%E3%81%BE%E3%81%AA%E3%81%84%E5%A0%B4%E5%90%88&amp;action=history"/>
		<updated>2026-04-24T22:56:37Z</updated>
		<subtitle>このウィキのこのページに関する変更履歴</subtitle>
		<generator>MediaWiki 1.24.2</generator>

	<entry>
		<id>https://wiki.nonip.net/index.php?title=Php/phpunit/%E3%83%A2%E3%83%83%E3%82%AF%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88/%E3%83%86%E3%82%B9%E3%83%88%E5%AF%BE%E8%B1%A1%E3%81%8Cconstruct%E3%82%92%E5%90%AB%E3%81%BE%E3%81%AA%E3%81%84%E5%A0%B4%E5%90%88&amp;diff=526&amp;oldid=prev</id>
		<title>127.0.0.1: ページの作成:「constructを実行せずに、テストしたい場合のサンプル  ==サンプル==  *application/point  class Point  {      private $_point = 0;      public function...」</title>
		<link rel="alternate" type="text/html" href="https://wiki.nonip.net/index.php?title=Php/phpunit/%E3%83%A2%E3%83%83%E3%82%AF%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88/%E3%83%86%E3%82%B9%E3%83%88%E5%AF%BE%E8%B1%A1%E3%81%8Cconstruct%E3%82%92%E5%90%AB%E3%81%BE%E3%81%AA%E3%81%84%E5%A0%B4%E5%90%88&amp;diff=526&amp;oldid=prev"/>
				<updated>2015-05-19T18:13:27Z</updated>
		
		<summary type="html">&lt;p&gt;ページの作成:「constructを実行せずに、テストしたい場合のサンプル  ==サンプル==  *application/point  class Point  {      private $_point = 0;      public function...」&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;constructを実行せずに、テストしたい場合のサンプル&lt;br /&gt;
&lt;br /&gt;
==サンプル==&lt;br /&gt;
&lt;br /&gt;
*application/point&lt;br /&gt;
 class Point&lt;br /&gt;
 {&lt;br /&gt;
     private $_point = 0;&lt;br /&gt;
     public function __construct($point)&lt;br /&gt;
     {&lt;br /&gt;
         $this-&amp;gt;_point = $point;&lt;br /&gt;
     }&lt;br /&gt;
     public function add($point)&lt;br /&gt;
     {&lt;br /&gt;
         $this-&amp;gt;_point += $point;&lt;br /&gt;
         return $this;&lt;br /&gt;
     }&lt;br /&gt;
     public function getPoint()&lt;br /&gt;
     {&lt;br /&gt;
         return $this-&amp;gt;_point;&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
*test/application/PointMockConstructTest.php&lt;br /&gt;
 require_once __DIR__ . '/../../application/Point.php';&lt;br /&gt;
 class PointMockConstructTest extends PHPUnit_Framework_TestCase&lt;br /&gt;
 {&lt;br /&gt;
     public function testGetPoint()&lt;br /&gt;
     {&lt;br /&gt;
         // Point クラスのスタブを作成します (テスト対象クラスにconstructがあっても無視します。&lt;br /&gt;
         $stub = $this-&amp;gt;getMockBuilder('Point')&lt;br /&gt;
                      -&amp;gt;disableOriginalConstructor()&lt;br /&gt;
                      -&amp;gt;getMock();&lt;br /&gt;
         // スタブの設定を行います&lt;br /&gt;
         $stub-&amp;gt;expects($this-&amp;gt;any())&lt;br /&gt;
              -&amp;gt;method('getPoint')&lt;br /&gt;
              -&amp;gt;will($this-&amp;gt;returnValue(10));&lt;br /&gt;
         // $stub-&amp;gt;getPoint() をコールすると 10 を返すようになります&lt;br /&gt;
         $this-&amp;gt;assertThat($stub-&amp;gt;getPoint(), $this-&amp;gt;equalTo(10));&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>127.0.0.1</name></author>	</entry>

	</feed>