So I am a bit confused on the right way to test when using a lifecycle hook. In the example below, have an action that gets fired when the $rating is updated. How do I test that it’s doing the right thing?
-
- set(‘foo’, ‘bar’) - this will just set the value but doesn’t trigger any of the hooks
- ->call(‘foo’); - gives me a “DirectlyCallingLifecycleHooksNotAllowedException: Unable to call lifecycle method”
I’m probably missing something very simple but can’t figure out the right approach.
class TestComponent extends Component
{
public $rating;
public function updateRating($value)
{
//do something
}
public function render()
{
return view('test-component');
}
}