Reputation: 1
I'm calling the endpoint that routes to methodIWantToTest
like so:
$response = $this->json('GET', 'my/endpoint/');
I'm attaching the code below, any ideas how I can mock the call to the second method? Thanks.
class MyController extends Controller
{
public function methodIWantToTest():
{
//some code to test
$this->methodIWantToMock()
//some more code to test
}
public function methodIWantToMock():
{
//mock this response
}
}
Upvotes: 0
Views: 237
Reputation: 892
I don't know if I understand your question correctly but you're already doing it. I don't know also why you're using ':' after the '()' in function and you need semicolon after you call the method you want to call
class MyController extends Controller
{
public function methodIWantToTest()
{
//some code to test
$this->methodIWantToMock();
//some more code to test
}
public function methodIWantToMock()
{
//mock this response
}
}
you can also pass value if you want just do this
class MyController extends Controller
{
public function methodIWantToTest()
{
//some code to test
$this->methodIWantToMock($value);
//some more code to test
}
public function methodIWantToMock($value)
{
//mock this response
}
}
Upvotes: 1