Answer the question
In order to leave comments, you need to log in
In phpunit, is it possible to mock a future callable?
I have such a class, and in this class a method from another class is called, is it possible to override its result?
class Book {
public function getAuthorName($id)
{
$author = Author::model()->findByPk($id);
return $author->name;
}
}
class BookTest{
public function test()
{
$book = new Book();
// Вот тут как то хочу переопределить возвращаемое значение Author::model()->findByPk($id);
// Типа при вызове Author::model()->findByPk()->name == 'Саня';
$result = $book->getAuthorName(1);
$this->assertEquals('Саня', result);
}
}
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