Support the ongoing development of →
IOC Testing
Last updated 1 year ago.

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)

function it_is_initializable()
Last updated 1 year ago.

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!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.