Skip to content

Commit 7717a13

Browse files
committed
Merge pull request #47 from cabello/patch-3
Add support to dynamic helpers
2 parents a3f37a7 + 95487c1 commit 7717a13

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

Test/Helper/AbstractHelper.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ abstract class AbstractHelper
2424
*
2525
* @param \IC\Bundle\Base\TestBundle\Test\Functional\WebTestCase $testCase
2626
*/
27-
public function __construct(WebTestCase $testCase)
27+
public function __construct(WebTestCase $testCase = null)
28+
{
29+
$this->testCase = $testCase;
30+
}
31+
32+
public function setTestCase(WebTestCase $testCase)
2833
{
2934
$this->testCase = $testCase;
3035
}

Test/WebTestCase.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,18 @@ public function getHelper($name)
7575
{
7676
$helperClass = $this->helperList->get($name);
7777

78-
return new $helperClass($this);
78+
if ($helperClass) {
79+
return new $helperClass($this);
80+
}
81+
82+
$container = $this->getClient()->getContainer();
83+
$helperService = $container->get($name);
84+
85+
if ($helperService) {
86+
$helperService->setTestCase($this);
87+
88+
return $helperService;
89+
}
7990
}
8091

8192
/**

0 commit comments

Comments
 (0)