Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prophesize missing properties action #2

Open
step307 opened this issue Oct 9, 2018 · 2 comments
Open

Prophesize missing properties action #2

step307 opened this issue Oct 9, 2018 · 2 comments
Labels
enhancement New feature or request

Comments

@step307
Copy link

step307 commented Oct 9, 2018

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

@cawolf
Copy link
Owner

cawolf commented Oct 16, 2018

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?

@cawolf cawolf added this to the v1.1.0 milestone Oct 16, 2018
@cawolf cawolf added the enhancement New feature or request label Oct 16, 2018
@step307
Copy link
Author

step307 commented Oct 18, 2018

Sounds even better !

@cawolf cawolf modified the milestones: v1.1.0, v1.2.0 Oct 25, 2018
@cawolf cawolf modified the milestones: v1.2.0, v1.3.0 Nov 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants