Seems the problem was elsewhere and injecting it like any other class seems to work fine. For those who are wondering:
My Image class constructor:
use Illuminate\Config\Repository as Config;
class Image {
public function __construct(
Config $config
) {
$this->config = $config;
}
}
My ImageSpec.php:
function let(\Illuminate\Config\Repository $config)
{
$this->beConstructedWith($config);
}
function it_is_initializable()
{
$this->shouldHaveType('Acme\Images\Image');
}
mehdidalvand liked this reply
Yes, it works if you leave it at that. However if you add another function to the image class like this:
function isAccepted(){
return in_array($this->type, $this->config->get('accepted_types'));
}
I don't think it will work in this case. Or you will get weird results at best.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community