當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。