Discussion of testing theory and practice, including methodologies (such as TDD, BDD, DDD, Agile, XP) and software - anything to do with testing goes here. (Formerly "The Testing Side of Development")
require_once('../simpletest/unit_tester.php');
require_once('../simpletest/mock_objects.php');
require_once('../simpletest/reporter.php');
require_once('../lib/Jenk/Controller/Router.php');
class Jenk_Controller_Router_Route
{
public function getController ()
{
}
public function getAction ()
{
}
public function isMatch ()
{
}
}
class Jenk_Controller_Dispatcher
{
public function execute()
{
}
}
Mock::generate('Jenk_Controller_Router_Route', 'MockRoute');
Mock::generate('Jenk_Controller_Dispatcher', 'MockDispatch');
class RouterTest extends UnitTestCase
{
private $_router;
private $_dispatcher;
private $_mockRoute;
public function __construct ()
{
parent::__construct();
$this->_router = new Jenk_Controller_Router();
$this->_mockRoute = new MockRoute(); // if I comment out this line, the error ceases - but my test fails of course.
}
Last edited by Jenk on Wed Feb 21, 2007 6:15 am, edited 1 time in total.
Try adding a constructor to the class being mocked? I rarely if ever have a class without a constructor so not a clue as to whether this impacts anything really . But only thing I noted as odd from my perspective.
No change I'm afraid, both with MockRoute($this) and a constructor in the class.
Puzzling. I searched google for 'simpletest "call to a member function tell"' and got one result in French, but I recognised that they were blaming it on PHP's regression (or lack of.)
I'm not sure I know what that means, but would that be a cause?
It's a weird line error - tell() is called on the current test case as fetched from the current Context. It should be working unless the test has not been setup correctly (something bad enough that simpletest can't find it, or isn't aware of it.).
What SimpleTest version are you using? I can check it later against my own copy and the current Beta. If it's a very old SimpleTest version, and you're using PHP 5.2+ it could easily be a simpletest problem. It had a few early PHP5.2 bugs, and I haven't tested myself on 5.2.1.
about to try again now that I am at home, it was with the latest simpletest version at work but I can't remember which PHP version I've got installed on work machine.
Mock::generate(/* snip.. */);
class Test extends UnitTestCase
{
private $_mockRoute;
public function __construct ()
{
//this fails..
$this->_mockRoute = new MockRoute($this);
}
public function TestSomething ()
{
//this doesn't..
$this->_mockRoute = new MockRoute($this);
}
}