I'm using an ORM and the way I get an object of the record is using FooModel::find(1)
. FooModel
has a method I need to mock for testing. How can I do it? (Can't use the PHPUnit mock
because that would give me a mocked FooModel
that'll not correspond to the record with ID 1
.)
Edit
Example:
class FooModel
{
// ORM model that fetches record from the DB
public function thisNeedsToBeMocked()
{
// some code here that depends on external factors so should be part of unit tests
}
}
The way I get the record with ID 1
is:
$fooObject = FooModel::find(1);
I need to be able of mock the thisNeedsToBeMocked()
of $fooObject
that I have after I run the static
method find()
.