<?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%E4%BE%9D%E5%AD%98%E3%81%99%E3%82%8B%E3%83%AD%E3%82%B8%E3%83%83%E3%82%AF%E3%82%92%E5%90%AB%E3%82%80%E5%A0%B4%E5%90%88</id>
		<title>Php/phpunit/モックオブジェクト/依存するロジックを含む場合 - 変更履歴</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%E4%BE%9D%E5%AD%98%E3%81%99%E3%82%8B%E3%83%AD%E3%82%B8%E3%83%83%E3%82%AF%E3%82%92%E5%90%AB%E3%82%80%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/%E4%BE%9D%E5%AD%98%E3%81%99%E3%82%8B%E3%83%AD%E3%82%B8%E3%83%83%E3%82%AF%E3%82%92%E5%90%AB%E3%82%80%E5%A0%B4%E5%90%88&amp;action=history"/>
		<updated>2026-04-24T22:56:32Z</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/%E4%BE%9D%E5%AD%98%E3%81%99%E3%82%8B%E3%83%AD%E3%82%B8%E3%83%83%E3%82%AF%E3%82%92%E5%90%AB%E3%82%80%E5%A0%B4%E5%90%88&amp;diff=861&amp;oldid=prev</id>
		<title>127.0.0.1: ページの作成:「==依存するクラスの解決法== モックできない場合は、できるように修正する  *UserGetLogic.php(テスト対象修正前  class UserGetLogic  {...」</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/%E4%BE%9D%E5%AD%98%E3%81%99%E3%82%8B%E3%83%AD%E3%82%B8%E3%83%83%E3%82%AF%E3%82%92%E5%90%AB%E3%82%80%E5%A0%B4%E5%90%88&amp;diff=861&amp;oldid=prev"/>
				<updated>2015-05-19T18:18:17Z</updated>
		
		<summary type="html">&lt;p&gt;ページの作成:「==依存するクラスの解決法== モックできない場合は、できるように修正する  *UserGetLogic.php(テスト対象修正前  class UserGetLogic  {...」&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==依存するクラスの解決法==&lt;br /&gt;
モックできない場合は、できるように修正する&lt;br /&gt;
&lt;br /&gt;
*UserGetLogic.php(テスト対象修正前&lt;br /&gt;
 class UserGetLogic&lt;br /&gt;
 {&lt;br /&gt;
   public function getUserId()&lt;br /&gt;
   {&lt;br /&gt;
     $user = new UserClass();&lt;br /&gt;
     return $user-&amp;gt;getId();&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
*UserGetLogic.php(テスト対象修正後&lt;br /&gt;
 class UserGetLogic&lt;br /&gt;
 {&lt;br /&gt;
   private $_user;&lt;br /&gt;
   public function getUser()&lt;br /&gt;
   {&lt;br /&gt;
     return new UserClass();&lt;br /&gt;
   }&lt;br /&gt;
   public function getUserId()&lt;br /&gt;
   {&lt;br /&gt;
     $user = $this-&amp;gt;getUser();&lt;br /&gt;
     return $user-&amp;gt;getId();&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
*UserGetLogicTest.php（テストコード&lt;br /&gt;
 class UserGetLogicTest extends PHPUnit_Framework_TestCase&lt;br /&gt;
 {&lt;br /&gt;
   public function testGetUserId()&lt;br /&gt;
   {&lt;br /&gt;
     // userClassのモック作成&lt;br /&gt;
     $userClassMock = $this-&amp;gt;getMock('UserClass', array('getId'));&lt;br /&gt;
    $userClassMock-&amp;gt;expects($this-&amp;gt;any())-method('getId')-&amp;gt;will($this-&amp;gt;returnValue(10));&lt;br /&gt;
     // logicのモック作成&lt;br /&gt;
     $logic = $this-&amp;gt;getMock('UserGetLogic', array('getUser'));&lt;br /&gt;
     $logic-&amp;gt;expects($this-&amp;gt;any())-&amp;gt;method('getUser')-&amp;gt;will($this-&amp;gt;returnValue($userClassMock));&lt;br /&gt;
     $id = $logic-&amp;gt;getUserId();&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>127.0.0.1</name></author>	</entry>

	</feed>