KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to configure a Mock object in PHPunit to return values for different properties (that are accessed using the __get function) Example: class OriginalObject { public function __get($name){ switch($name) case "ParameterA": return "ValueA"; case "ParameterB": return "ValueB"; } } I'm trying to mock this using: $mockObject = $this->getMock("OrigionalObject"); $mockObject ->expects($this->once()) ->method('__get') ->with($this->equalTo('ParameterA')) ->will($this->returnValue("ValueA")); $mockObject ->expects($this->once()) ->method('__get') ->with($this->equalTo('ParameterB')) ->will($this->returnValue("ValueB")); but this fails horribly :-(
Tags (comma-separated)
Save Edits
Cancel