I am writing unit tests and most of them are working. However, I am having trouble with one thing, which I can't quite understand the difference.
In order to tests calls through the application's router/controller setup, I mock the \Phalcon\Http\Request object like so:
public function testCreateSingle() {
$_SERVER["REQUEST_METHOD"] = "POST";
$_SERVER["REQUEST_URI"] = "logs";
$_GET["_url"] = "/logs";
$raw = '{"application": "Test Application","type":"CRITICAL","subject":"test","details":"my details"}';
$mock = $this->getMock("\\Phalcon\\Http\\Request", array("getRawBody"));
$mock->expects($this->once())
->method("getRawBody")
->will($this->returnValue($raw));
$this->di->set('request', $mock, true);
include("../app.php");
$this->expectOutputString('{"success":true,"response":{"result":"success"}}');
}
The problem I am having is, this only works when I do "$this->di->get('request')" in the controller instead of "$this->request".
Any suggestions?