Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 149ea79

Browse files
committed
add getConfig.
1 parent 85a5a4f commit 149ea79

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tests/Server/PidManagerFactoryTest.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace SwooleTW\Http\Tests\Server;
44

5-
use Mockery as m;
65
use Illuminate\Container\Container;
6+
use Mockery as m;
77
use SwooleTW\Http\Server\PidManager;
88
use SwooleTW\Http\Server\PidManagerFactory;
99
use SwooleTW\Http\Tests\TestCase;
@@ -14,7 +14,7 @@ public function testFactoryReturnsAPidManager()
1414
{
1515
$factory = new PidManagerFactory($container = new Container);
1616

17-
$config = m::mock(ConfigContract::class);
17+
$config = $this->getConfig();
1818

1919
$container->singleton(ConfigContract::class, function () use ($config) {
2020
return $config;
@@ -24,4 +24,21 @@ public function testFactoryReturnsAPidManager()
2424

2525
$this->assertInstanceOf(PidManager::class, $factory($container));
2626
}
27+
28+
protected function getConfig()
29+
{
30+
$config = m::mock(ConfigContract::class);
31+
$callback = function ($key) {
32+
return $this->config[$key] ?? '';
33+
};
34+
35+
$config->shouldReceive('get')
36+
->with(m::type('string'), m::any())
37+
->andReturnUsing($callback);
38+
$config->shouldReceive('get')
39+
->with(m::type('string'))
40+
->andReturnUsing($callback);
41+
42+
return $config;
43+
}
2744
}

0 commit comments

Comments
 (0)