Answer the question
In order to leave comments, you need to log in
How to stub methods from a called phpunit method?
There is a method that requests json from an external API. I simulate a call to this method, and I muffle inside this method, the method that calls the api, but for some reason I run into an error: Protocol "" not supported or disabled in libcurl
In the getTasksData () method, a connection to the api occurs that does not need to be done in tests . Why is the original getTasksData() called and not its replacement?
public function testCreateTasks()
{
$mock = Mockery::mock(MyClass::class)->makePartial();
$mock->shouldReceive('getTasksData')->andReturn(false);
$result = $mock->createTasks();
$this->assertSame(false, $result);
}
public function createTasks()
{
$tasks = self::getTasksData();
// создать задачу
return true;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question