Skip to content

Instantly share code, notes, and snippets.

@pfaocle
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfaocle/c099438099c0bb992f41 to your computer and use it in GitHub Desktop.
Save pfaocle/c099438099c0bb992f41 to your computer and use it in GitHub Desktop.
Best option for chucking around $I in Cest classes?
<?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