Skip to content

Inject on an already created instance #84

@drdamour

Description

@drdamour

In tests I've been doing stuff like this

    /**
     * @return CampaignService
     */
    public function getMockedService()
    {
        return $this->DIContainer->get("CampaignService");
    }

but I feel it'd be a bit cleaner i think to do something like this

    /**
     * @return CampaignService
     */
    public function getMockedService()
    {
        $service = new CampaignService()
        return $this->DIContainer->InjectOn($service);
    }

clearly constructor injection couldn't happen in this case...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions