Skip to content

Commit ea0c8db

Browse files
committed
scope plugin always creates a new app
1 parent e0d2426 commit ea0c8db

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

src/Config/ConfigTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ function test_clone_object_scoped()
373373
{
374374
$app = new App;
375375

376-
$config = (new App)(new Scope($app, Config::class));
376+
$config = (new App)(new Scope([], Config::class));
377377

378378
$this->assertEquals(clone $config, $config);
379379
}
@@ -385,7 +385,7 @@ function test_clone_object_scoped_true()
385385
{
386386
$app = new App(null, null, true);
387387

388-
$config = (new App)(new Scope($app, Config::class));
388+
$config = (new App)(new Scope([], Config::class));
389389

390390
$this->assertEquals(clone $config, $config);
391391
}
@@ -397,7 +397,7 @@ function test_clone_object_scoped_different_object()
397397
{
398398
$app = new App(null, null, true);
399399

400-
$config = (new App)(new Scope($app, \stdClass::class));
400+
$config = (new App)(new Scope([], \stdClass::class));
401401

402402
$this->assertEquals(clone $config, $config);
403403
}

src/Plugin/ScopeTest.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
use Mvc5\Config;
99
use Mvc5\App;
10-
use Mvc5\Plugin\Args;
1110
use Mvc5\Plugin\Link;
11+
use Mvc5\Plugin\Plugin;
1212
use Mvc5\Plugin\Scope;
1313
use Mvc5\Test\Test\TestCase;
1414

@@ -20,36 +20,34 @@ class ScopeTest
2020
*/
2121
function test()
2222
{
23-
$scope = new Scope(new App, Config::class);
23+
$scope = new Scope([], Config::class);
2424

25-
$args = [new App, new Link, Config::class];
25+
$args = [new Plugin(App::class, [['services' => []], null, true, true]), new Link, Config::class];
2626

2727
$this->assertTrue(is_callable($scope->config()));
2828
$this->assertEquals($args, $scope->args());
2929
}
3030

3131
/**
32-
*
32+
* @throws \Throwable
3333
*/
3434
function test_scope()
3535
{
36-
$app = new App([
37-
'services' => [
38-
'bar' => function() {
39-
return 'foobar';
40-
},
41-
'foo' => function() {
42-
/** @var Config $this */
43-
return $this->get('bar');
44-
},
45-
'scope' => fn() => $this
46-
]
47-
], null, true);
48-
49-
$config = (new App)(new Scope($app, Config::class));
36+
$plugins = [
37+
'bar' => function() {
38+
return 'foobar';
39+
},
40+
'foo' => function() {
41+
/** @var Config $this */
42+
return $this->get('bar');
43+
},
44+
'scope' => fn() => $this
45+
];
46+
47+
$config = (new App)(new Scope($plugins, Config::class));
5048

5149
$this->assertInstanceOf(Config::class, $config);
52-
$this->assertEquals($config, $app['scope']);
50+
$this->assertInstanceOf(Config::class, $config['scope']);
5351
$this->assertEquals('foobar', $config['foo']);
5452
}
5553
}

0 commit comments

Comments
 (0)