I have this method:
public function getLocale()
{
$languageId = $this->_user->language->id;
$page = Wire::getModule('myModule')->getPage($languageId);
$locale = $page->locale;
if (!!$locale) {
return $locale;
}
// fallback to browser's locale
$browserLocale = new SBD_Language();
$locale = $browserLocale->getLanguageLocale('_');
return $locale;
}
Now I want to write a test for it, but I get this error:
Trying to get property of non-object
which is caused by Wire::getModule('myModule')
.
So I'd like to override the Wire::getModule
response with phpunit. I just don't know how to do that.
So far I have created a mock over the class in which the method getLocale
is placed and that is all working fine but how would I tell that mock class that it should actually call a mock of the Wire
class?