Skip to content

Commit e0e4c38

Browse files
committed
mock env helper function in tests
1 parent 947a21b commit e0e4c38

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

tests/Coroutine/ConnectorFactoryTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
*/
1515
class ConnectorFactoryTest extends TestCase
1616
{
17+
public function setUp()
18+
{
19+
parent::setUp();
20+
$this->mockEnv('Laravel\Lumen');
21+
}
22+
1723
public function testItHasNeededStubByVersion()
1824
{
1925
$version = FW::version();

tests/Task/QueueFactoryTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
*/
1616
class QueueFactoryTest extends TestCase
1717
{
18+
public function setUp()
19+
{
20+
parent::setUp();
21+
$this->mockEnv('Laravel\Lumen');
22+
}
23+
1824
public function testItHasNeededStubByVersion()
1925
{
2026
$version = FW::version();

tests/TestCase.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,15 @@ protected function mockMethod($name, \Closure $function, $namespace = null)
3434
$mock = $builder->build();
3535
$mock->enable();
3636
}
37+
38+
protected function mockEnv(string $namespace, array $variables = [])
39+
{
40+
$this->mockMethod('env', function ($key, $value = null) use ($variables) {
41+
if (array_key_exists($key, $variables)) {
42+
return $variables[$key];
43+
}
44+
45+
return null;
46+
}, $namespace);
47+
}
3748
}

0 commit comments

Comments
 (0)