Skip to content

Prophesize missing properties action #2

Open

Description

@step307

Additional helper would be great, which:

  1. Finds all private properties which are initialized in constructor
  2. Adds them to constructor with prophesize accordingly their classes from doc block

Use case:
When a test needs several more mocks which are not a part of subject constructor calls, developer could just add private properties and generate all prophesies by this magic feature

Activity

  1. cawolf commented on Oct 16, 2018

    @cawolf
    Owner

    Good idea in general. My thoughts on this were slightly different.

    I thought about adding another intention you trigger manually from any part in the test (setUp() or testMethod()). You then get to choose the interface or class from the known "Import class" popup. If you confirm an interface or class, the intention will

    • add the chosen interface to the imports (if not present) like: use Fully\Qualified\Namespace\ChosenInterface;
    • create a new prophecy at the cursor like: $this->chosenInterface = $this->prophesize(ChosenInterface::class);
    • add a new member variable to the test like: private $chosenInterface;
    • add a doc-block for this member like: /** @var ChosenInterface|ObjectProphecy */

    Would this fulfill your needs aswell?

  2. added this to the v1.1.0 milestone on Oct 16, 2018
  3. step307 commented on Oct 18, 2018

    @step307
    Author

    Sounds even better !

  4. modified the milestones: v1.1.0, v1.2.0 on Oct 25, 2018
  5. modified the milestones: v1.2.0, v1.3.0 on Nov 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions