当前位置: 首页>>代码示例>>PHP>>正文


PHP Container::setInstance方法代码示例

本文整理汇总了PHP中Illuminate\Container\Container::setInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::setInstance方法的具体用法?PHP Container::setInstance怎么用?PHP Container::setInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Container\Container的用法示例。


在下文中一共展示了Container::setInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createApplicationContainer

 protected function createApplicationContainer()
 {
     $this->app = new \TestContainer();
     $this->app->singleton('config', function () {
         return new \Illuminate\Config\Repository();
     });
     $this->registerConfigure();
     $eventServiceProvider = new \Illuminate\Encryption\EncryptionServiceProvider($this->app);
     $eventServiceProvider->register();
     $eventServiceProvider = new \Illuminate\Events\EventServiceProvider($this->app);
     $eventServiceProvider->register();
     $queueProvider = new \Illuminate\Queue\QueueServiceProvider($this->app);
     $queueProvider->register();
     $sessionProvider = new \Illuminate\Session\SessionServiceProvider($this->app);
     $sessionProvider->register();
     $this->registerDatabase();
     $this->registerCache();
     $couchbaseProvider = new \Ytake\LaravelCouchbase\CouchbaseServiceProvider($this->app);
     $couchbaseProvider->register();
     $couchbaseProvider->boot();
     $this->app->bind(\Illuminate\Container\Container::class, function () {
         return $this->app;
     });
     (new \Illuminate\Events\EventServiceProvider($this->app))->register();
     \Illuminate\Container\Container::setInstance($this->app);
 }
开发者ID:ytake,项目名称:laravel-couchbase,代码行数:26,代码来源:CouchbaseTestCase.php

示例2: setUp

 protected function setUp()
 {
     $appMethods = ['version', 'basePath', 'environment', 'isDownForMaintenance', 'registerConfiguredProviders', 'register', 'registerDeferredProvider', 'boot', 'booting', 'booted', 'getCachedCompilePath', 'getCachedServicesPath'];
     $containerMethods = ['bound', 'alias', 'tag', 'tagged', 'bind', 'bindIf', 'singleton', 'extend', 'instance', 'when', 'make', 'call', 'resolved', 'resolving', 'afterResolving'];
     $this->applicationMock = $this->getMock(Application::class, array_merge($appMethods, $containerMethods, $this->applicationMocksMethods()));
     Container::setInstance($this->applicationMock);
     parent::setUp();
 }
开发者ID:laravel-commode,项目名称:utils,代码行数:8,代码来源:PHPUnitContainer.php

示例3: setUp

 public function setUp()
 {
     $_SERVER['SUDO_USER'] = user();
     Container::setInstance(new Container());
     if (!resolve(Linux::class)->getDistributionInstance() instanceof Ubuntu) {
         $this->markTestSkipped('Tests are skipped, Ubuntu needed.');
     }
 }
开发者ID:jmarcher,项目名称:valet-linux,代码行数:8,代码来源:UbuntuTest.php

示例4: testSetupWidgetHelperFunction

 /**
  * testSetupWidgetHelperFunction
  *
  * @return void
  */
 public function testSetupWidgetHelperFunction()
 {
     $handler = $this->handler;
     $containerMock = m::mock('Illuminate\\Contracts\\Container\\Container');
     $handler->shouldReceive('setUp')->andReturn('test widget setup form');
     $containerMock->shouldReceive('make')->andReturn($handler);
     Container::setInstance($containerMock);
     $this->assertSame('test widget setup form', setupWidget('test@testWidgetId'));
 }
开发者ID:mint-soft-com,项目名称:xpressengine,代码行数:14,代码来源:WidgetHelperTest.php

示例5: instantiateServiceContainer

 /**
  * Instantiate service container if it's not instantiated yet.
  */
 protected static function instantiateServiceContainer()
 {
     $container = Container::getInstance();
     if (!$container) {
         $container = new Container();
         Container::setInstance($container);
     }
     static::$container = $container;
 }
开发者ID:triangle-lab,项目名称:bitrix-blade,代码行数:12,代码来源:BladeProvider.php

示例6: setUp

 protected function setUp()
 {
     $appMethods = ['version', 'basePath', 'environment', 'isDownForMaintenance', 'registerConfiguredProviders', 'register', 'registerDeferredProvider', 'boot', 'booting', 'booted', 'getCachedCompilePath', 'getCachedServicesPath'];
     $containerMethods = ['bound', 'alias', 'tag', 'tagged', 'bind', 'bindIf', 'singleton', 'extend', 'instance', 'when', 'make', 'call', 'resolved', 'resolving', 'afterResolving'];
     $this->appMock = $this->getMock(Application::class, array_merge($appMethods, $containerMethods, ['getLocale']));
     Container::setInstance($this->appMock);
     $this->testInstance = $this->getMockForAbstractClass(MetaAttributes::class, ['_']);
     $this->tranlator = $this->getMock(Translator::class, [], [], '', false);
     parent::setUp();
 }
开发者ID:laravel-commode,项目名称:utils,代码行数:10,代码来源:MetaAttributesTest.php

示例7: testMenuTypeClass

 public function testMenuTypeClass()
 {
     $moduleHandlerMock = m::mock('Xpressengine\\Module\\ModuleHandler');
     $containerMock = m::mock('Illuminate\\Contracts\\Container\\Container');
     $moduleHandlerMock->shouldReceive('getModuleClassName')->andReturn('testModuleClass');
     $containerMock->shouldReceive('make')->andReturn($moduleHandlerMock);
     Container::setInstance($containerMock);
     $menuTypeClassName = moduleClass('xpressengine@test1');
     $this->assertEquals('testModuleClass', $menuTypeClassName);
 }
开发者ID:mint-soft-com,项目名称:xpressengine,代码行数:10,代码来源:ModuleHelperTest.php

示例8: setUp

 protected function setUp()
 {
     $contractMethods = ['bound', 'alias', 'tag', 'tagged', 'bind', 'bindIf', 'singleton', 'extend', 'instance', 'when', 'make', 'call', 'resolved', 'resolving', 'afterResolving'];
     $appMethods = ['version', 'basePath', 'environment', 'isDownForMaintenance', 'registerConfiguredProviders', 'register', 'registerDeferredProvider', 'boot', 'booting', 'booted', 'getCachedCompilePath', 'getCachedServicesPath'];
     $this->appMock = $this->getMock('Illuminate\\Contracts\\Foundation\\Application', array_merge($contractMethods, $appMethods));
     $this->bladeCompilerMock = $this->getMock(BladeCompiler::class, [], [], '', false);
     $this->bladedManagerMock = $this->getMock(BladedManager::class, [], [], '', false);
     $this->testInstance = new BladedServiceProvider($this->appMock);
     Container::setInstance($this->appMock);
     parent::setUp();
 }
开发者ID:laravel-commode,项目名称:bladed,代码行数:11,代码来源:BladedServiceProviderTest.php

示例9: setUp

 public function setUp()
 {
     parent::setUp();
     /** @var \Illuminate\Foundation\Application|\PHPUnit_Framework_MockObject_Builder_InvocationMocker $app */
     $app = $this->getMockBuilder('\\Illuminate\\Foundation\\Application')->disableOriginalConstructor()->getMock();
     $app->method('make')->willReturn('\\GionniValeriana\\laravelAdminlte\\Adminlte');
     Illuminate\Container\Container::setInstance(new Container());
     Facade::setFacadeApplication($app);
     $this->MockedBaseMenuItem = $this->getMockBuilder('\\SleepingOwl\\Admin\\Menu\\MenuItem')->disableOriginalConstructor()->getMock();
     $this->MockedMenuItem = $this->getMockBuilder('\\GionniValeriana\\laravelAdminlte\\MenuItem')->disableOriginalConstructor()->getMock();
 }
开发者ID:marwein,项目名称:laravel-adminlte,代码行数:11,代码来源:AdminTest.php

示例10: setUp

 protected function setUp()
 {
     $this->bladeCompiler = new BladeCompiler(new Filesystem(), __DIR__);
     $this->viewMock = $this->getMock(Factory::class, ['exists', 'file', 'make', 'share', 'composer', 'creator', 'addNamespace', 'getShared'], [], '', false);
     $this->appMock = $this->getMock(Application::class, []);
     $this->bladedManager = $this->getMock(BladedManager::class, [], [], '', false);
     $this->testInstance = new BladedCompiler($this->bladeCompiler, $this->appMock);
     $this->stringCompiler = new StringCompiler(new Filesystem(), __DIR__);
     Container::setInstance($this->appMock);
     parent::setUp();
 }
开发者ID:laravel-commode,项目名称:bladed,代码行数:11,代码来源:BladedCompilerTest.php

示例11: testAliases

 public function testAliases()
 {
     $container = new Container();
     $container->bind('request', function () {
         return 'input';
     });
     $container->bind('translator', function () {
         return 'lang';
     });
     $container->bind('blade.compiler', function () {
         return 'blade';
     });
     Container::setInstance($container);
     $this->assertEquals('input', $this->input);
     $this->assertEquals('lang', $this->lang);
     $this->assertEquals('blade', $this->blade_compiler);
     $this->assertSame($container, $this->app);
 }
开发者ID:cknow,项目名称:laravel-support,代码行数:18,代码来源:LaravelTraitTest.php

示例12: createApplicationContainer

 protected function createApplicationContainer()
 {
     $this->app = new \Illuminate\Container\Container();
     $this->app->singleton('config', function () {
         return new \Illuminate\Config\Repository();
     });
     $this->app->instance('log', $log = new \Illuminate\Log\Writer(new \Monolog\Logger('testing')));
     $this->app->instance('Psr\\Log\\LoggerInterface', $log = new \Illuminate\Log\Writer(new \Monolog\Logger('testing')));
     $this->registerConfigure();
     $this->registerDatabase();
     $this->registerCache();
     $annotationConfiguration = new \Ytake\LaravelAspect\AnnotationConfiguration($this->app['config']->get('ytake-laravel-aop.annotation'));
     $annotationConfiguration->ignoredAnnotations();
     $this->app->singleton('aspect.manager', function ($app) {
         return new \Ytake\LaravelAspect\AspectManager($app);
     });
     $this->app->bind(\Illuminate\Container\Container::class, function () {
         return $this->app;
     });
     \Illuminate\Container\Container::setInstance($this->app);
 }
开发者ID:ytake,项目名称:laravel-aspect,代码行数:21,代码来源:AspectTestCase.php

示例13: app

require_once __DIR__ . '/../../vendor/autoload.php';
if (!function_exists('app')) {
    /**
     * Get the available container instance.
     *
     * @param  string  $make
     * @param  array   $parameters
     * @return Illuminate\Container\Container
     */
    function app($make = null, $parameters = [])
    {
        if (is_null($make)) {
            return Container::getInstance();
        }
        return Container::getInstance()->make($make, $parameters);
    }
}
$app = new Container();
$app->setInstance($app);
$events = new EventServiceProvider($app);
$events->register();
$app->bind(Dispatcher::class, function ($app) {
    return $app['events'];
});
$app->bind(StructureInterface::class, function ($app) {
    return $app->make(GraphStructure::class);
});
$app->bind(EventInterface::class, function ($app) {
    return $app->make(LaravelEvents::class);
});
return $app;
开发者ID:daveawb,项目名称:understated,代码行数:31,代码来源:bootstrap.php

示例14:

<?php

use Illuminate\Container\Container;
use Psr\Log\LoggerInterface;
require __DIR__ . '/../vendor/autoload.php';
$app = new \Bludata\Tests\TestApp();
$factory = (require __DIR__ . '/mocks.php');
$app->setMockFactory($factory);
$app->bind(LoggerInterface::class, \Bludata\Tests\Lumen\Traits\LogTraitStub::class);
Container::setInstance($app);
return $app;
开发者ID:raivieira,项目名称:base-api-php,代码行数:11,代码来源:bootstrap.php

示例15: setUp

 /**
  * Set up testing container for each test.
  */
 public function setUp()
 {
     parent::setUp();
     $this->container = new Container();
     Container::setInstance($this->container);
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:9,代码来源:CommandTest.php


注:本文中的Illuminate\Container\Container::setInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。