Last active
August 29, 2015 14:05
-
-
Save pfaocle/c099438099c0bb992f41 to your computer and use it in GitHub Desktop.
Best option for chucking around $I in Cest classes?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CheeseCest | |
{ | |
/** | |
* A test. | |
* | |
* @param AuthenticatedStepsInterface $I | |
* The Guy object being used to test. | |
*/ | |
public function testSomething(AuthenticatedStepsInterface $I) | |
{ | |
$this->doSomethingInternal($I, 'some value'); | |
} | |
/** | |
* A helper/internal method. | |
* | |
* @param AuthenticatedStepsInterface $I | |
* The Guy object being used to test. | |
* @param string $something | |
* Some random parameter we need. | |
*/ | |
protected function doSomethingInternal(AuthenticatedStepsInterface $I, $something) | |
{ | |
$I->see($something); | |
// ... | |
} | |
} | |
// OR: | |
class CheeseCest | |
{ | |
/** | |
* @var AuthenticatedStepsInterface | |
* Store the Guy object being used to test. | |
*/ | |
protected $guy; | |
/** | |
* A test. | |
* | |
* @param AuthenticatedStepsInterface $I | |
* The Guy object being used to test. | |
*/ | |
public function testSomething(AuthenticatedStepsInterface $I) | |
{ | |
$this->guy = $I; | |
$this->doSomethingInternal($I, 'some value'); | |
} | |
/** | |
* A helper/internal method. | |
* | |
* @param string $something | |
* Some random parameter we need. | |
*/ | |
protected function doSomethingInternal($something) | |
{ | |
$I = $this->guy; | |
$I->see($something); | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment