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

Auto-Inject into Test\Unit #4070

Merged
merged 3 commits into from Mar 25, 2017
Merged

Auto-Inject into Test\Unit #4070

merged 3 commits into from Mar 25, 2017

Conversation

@DavertMik
Copy link
Member

@DavertMik DavertMik commented Mar 21, 2017

This is the new recommended approach to use actor classes inside unit tests:

function _inject(UnitTester $I)
{
    $this->i = $I;
}

function testRobotUserIsInsideDatabase()
{
    $this->i->seeInDatabase('users', ['id' => 1, 'name' => 'robot']);
}

$this->tester injection into Test\Unit classes happen in a very mysterious way. While this injection still happens it should be done explicitly, using _inject method we already have. This will allow to specify and name properties in predictable names. This will also allow to use classes based on Actor, like PageObjects, or StepObjects.

This new recommended way will be added to docs, while old one will be removed. However, property-based old-style injection will be kept till 3.0 and probably even after it.

DavertMik added 3 commits Mar 21, 2017
…\Unit via inject

deprecates using  $this->tester in favor of common _inject()
@DavertMik DavertMik merged commit eb1d3d7 into 2.2 Mar 25, 2017
6 checks passed
6 checks passed
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
semaphoreci The build passed on Semaphore.
Details
wercker/build Wercker pipeline passed
Details
@DavertMik DavertMik deleted the tests-inject branch Mar 25, 2017
chris1312 pushed a commit to chris1312/Codeception that referenced this pull request Jun 16, 2017
* allow to inject actor classes and other objects from DI into the Test\Unit via inject
deprecates using  $this->tester in favor of common _inject()

* fixed creating actor object via di
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.