PHPUnitを使用して\SplObserverのモックオブジェクトを作成し、
\SplSubjectを実装するクラスにモックオブジェクトを添付しようとすると、
「\SplObserverが実装されていない」というエラーコードが表示されました。
エラーコードは以下の通りです。
fatal error: Argument 1 passed to ..\AbstractSubject::attach() must implement interface SplObserver, instance of PHPUnit_Framework_MockObject_Builder_InvocationMocker given, called in ../Decorator/ResultCacheTest.php on line 45 and defined in /users/.../AbstractSubject.php on line 50
ソースコードは以下の通りです。
// Edit: Using the fully qualified name doesn't work either $observer = $this->getMock('SplObserver', array('update')) ->expects($this->once()) ->method('update'); /* Attach the mock object to the cache object and listen for the results to be *set on cache */ $this->_cache->attach($observer); doSomethingThatSetsCache();
どう修正すればよいのか、ご教授お願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。