コード例 #1
0
ファイル: AppTest.php プロジェクト: mvc5/mvc5-tests
 /**
  *
  */
 function test_app_provider_and_scope()
 {
     $app = new App([Arg::SERVICES => ['var3' => function () {
         return 'foobar';
     }, 'var2' => [Config::class, new Args(['var3' => new Plugin('var3')])], 'bat' => function ($var2) {
         return $var2['var3'];
     }, Config::class => Config::class, 'v3' => function () {
         return '6';
     }, 'v2' => [Config::class, new Args(['v3' => new Plugin('v3')])], 'var4' => function ($v2) {
         return $v2['v3'];
     }, 'code' => 1, 'foo' => new Plugins(['home' => 9, 'var2' => new Plugin(Config::class, [new Args(['var3' => new Provide('var4')])]), Config::class => function ($args) {
         return new Config($args);
     }, 'code' => 2, 'bar' => new Plugins(['code' => 5, Config::class => new Provide(Config::class), 'test' => function ($bat, $code, $home, $var2, Config $config) {
         return function ($param, $param2, Config $config) use($bat, $code, $home, $var2) {
             return $bat . $code . $home . $param . $var2['var3'] . $param2;
         };
     }, 'baz' => function () {
         return function ($param2) {
             /** @var \Mvc5\Service\Plugin $this */
             return $this->call('test', ['param' => '3', 'param2' => $param2]);
         };
     }])])]]);
     $this->assertEquals('foobar', $app['bat']);
     $this->assertEquals('foobar', $app('bat'));
     $this->assertEquals('foobar', $app->get('bat'));
     $this->assertEquals('foobar', $app->plugin('bat'));
     $this->assertEquals('6', $app['foo']['var2']['var3']);
     $this->assertEquals('foobar59360', $app->call($app['foo']['bar']['baz'], ['param2' => '0']));
     $this->assertEquals('foobar59360', $app->call('foo->bar->baz', ['param2' => '0']));
 }
コード例 #2
0
ファイル: AliasTest.php プロジェクト: mvc5/tests
 /**
  *
  */
 function test_autowire()
 {
     spl_autoload_register(new Alias(['TestView' => Render::class]));
     $app = new App();
     $service = $app->plugin(AutowireAlias::class);
     $this->assertInstanceOf(Render::class, $service->view());
 }
コード例 #3
0
ファイル: FilterTest.php プロジェクト: mvc5/tests
 /**
  *
  */
 function test_filter_null()
 {
     $app = new App([Arg::SERVICES => ['bar' => function () {
         return 'bar';
     }]]);
     $filters = [function ($foo) {
         return $foo;
     }, new Model\CallableObject(), Model\Filterable::class, function ($foo, $baz) {
         return $foo . $baz;
     }, function () {
         return null;
     }, function ($foo, $baz, $bar) {
         return $foo . $bar;
     }];
     $plugin = new Filter('foo', $filters, ['bar']);
     $this->assertEquals(null, $app->plugin($plugin, ['s']));
 }
コード例 #4
0
ファイル: ConfigTest.php プロジェクト: mvc5/mvc5-tests
 /**
  *
  */
 function test_clone_object_scoped_different_object()
 {
     $plugins = new App();
     $config = new Config($plugins);
     $plugins->scope(new \stdClass());
     $this->assertEquals(clone $config, $config);
 }
コード例 #5
0
ファイル: RelayTest.php プロジェクト: mvc5/tests
 /**
  *
  */
 function test_relay_config()
 {
     $app = new App([Arg::SERVICES => ['foo' => new Model\Bar()]]);
     $name = 'foo.bar.baz';
     $this->assertEquals('foobar', $app->call($name, ['foobar']));
 }