I have a component which I use the mount
method to assign a default value to a property from a configuration file if the property is not supplied as a parameter.
<livewire:my-component />
class MyComponent extends Component
{
public $property = false;
public function mount($property = null)
{
$trhis->property = $property ?? config('property');
}
}
What I want to do is test that if $property
is provided as an argument, then its value is assigned to $this->property
otherwise, the value from the config
is used.
Is there a way to test the value of $property
that is provided to the mount
method?
For example:
// value of $property in mount for this would be null
<livewire:my-component />
// value of $property in mount for this would be true
<livewire:my-component :property="true" />
What I would like to be able to do is assert that for the first example the value of $property
is null
and then that the value of $this->property
is the same as config
.
Then in another test be able to assert that the value of $property
is not null
and that its value is assigned to $this->property
.