本文整理汇总了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);
}
示例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();
}
示例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.');
}
}
示例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'));
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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;
示例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;
示例15: setUp
/**
* Set up testing container for each test.
*/
public function setUp()
{
parent::setUp();
$this->container = new Container();
Container::setInstance($this->container);
}