Skip to content

Commit

Permalink
Merge pull request #47 from cabello/patch-3
Browse files Browse the repository at this point in the history
Add support to dynamic helpers
  • Loading branch information
robocoder committed Jan 8, 2014
2 parents a3f37a7 + 95487c1 commit 7717a13
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Test/Helper/AbstractHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ abstract class AbstractHelper
*
* @param \IC\Bundle\Base\TestBundle\Test\Functional\WebTestCase $testCase
*/
public function __construct(WebTestCase $testCase)
public function __construct(WebTestCase $testCase = null)
{
$this->testCase = $testCase;
}

public function setTestCase(WebTestCase $testCase)
{
$this->testCase = $testCase;
}
Expand Down
13 changes: 12 additions & 1 deletion Test/WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,18 @@ public function getHelper($name)
{
$helperClass = $this->helperList->get($name);

return new $helperClass($this);
if ($helperClass) {
return new $helperClass($this);
}

$container = $this->getClient()->getContainer();
$helperService = $container->get($name);

if ($helperService) {
$helperService->setTestCase($this);

return $helperService;
}
}

/**
Expand Down

0 comments on commit 7717a13

Please sign in to comment.