Skip to content

Add an attribute to auto-populate object by their constructor argument #1486

@chadyred

Description

@chadyred

Hello,

To test any classical services, like Application services / Domain Services, the injection of dependencies is 90% the same :

    public function let(
        FooInterface $foo,
        BarInterface $bar,
        AInterface $a,
        BInterface $b,
        XInterface $x,
    ): void
    {
        $this->beConstructedWith($foo, $bar, $a, $b, $x); // or ...func_get_args() but could be a bad pratice...
    }

What ?

The constructor args should be mocked by their interface easily and quicker than before.

How ?

It could be good to :

  • create an Attribute like "AutoMockInjection('__construct')" so we could switch from the __construct
  • read the namespace of each one of the tested object to create the tested instance by injecting mocked interface

Why ?

Clean some "static" let function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions