setFacadeApplication() public static method

Set the application instance.
public static setFacadeApplication ( Illuminate\Contracts\Foundation\Application $app ) : void
$app Illuminate\Contracts\Foundation\Application
return void
Beispiel #1
0
 /**
  * Bootstrap the test environemnt:
  * - Create an application instance and register it within itself.
  * - Register the package service provider with the app.
  * - Set the APP facade.
  *
  * @return void
  */
 public function setUp()
 {
     $app = new Application();
     $app->instance('app', $app);
     $app->register('Ideil\\LaravelFileOre\\LaravelFileOreServiceProvider');
     Facade::setFacadeApplication($app);
 }
Beispiel #2
0
 public function bootstrap(Application $app, $config)
 {
     \Illuminate\Support\Facades\Facade::clearResolvedInstances();
     \Illuminate\Support\Facades\Facade::setFacadeApplication($app);
     #注册别名并设置自动加载器
     \Illuminate\Foundation\AliasLoader::getInstance($config['app_aliases'])->register();
 }
Beispiel #3
0
 public function __construct($values = array())
 {
     parent::__construct();
     static::$app = $this;
     foreach ($values as $key => $value) {
         $this[$key] = $value;
     }
     Facade::setFacadeApplication($this);
     // register the configserviceprovider so we can access the config
     $this->register(new ConfigServiceProvider());
     // grab the providers from the config and load them
     $providers = $this['config']->get('app/providers');
     foreach ($providers as $provider) {
         $this->register(new $provider());
     }
     // set the locale (https://github.com/silexphp/Silex/issues/983)
     $locale = $values['locale'];
     if ($this['translator']) {
         $this['translator']->setlocale($locale);
     }
     // register fieldtypes from config
     $fieldTypesConfig = $this['config']->get('fieldtypes');
     if ($fieldTypesConfig) {
         $this['fieldtypes'] = $this['fieldtypes.factory']->fromConfig($fieldTypesConfig);
     }
     // register contenttypes from config
     $contentTypeConfig = $this['config']->get('contenttypes');
     if ($contentTypeConfig) {
         $this['contenttypes'] = $this['contenttypes.factory']->fromConfig($contentTypeConfig);
     }
 }
 /**
  * Bootstrap the test environemnt:
  * - Create an application instance and register it within itself.
  * - Register the package service provider with the app.
  * - Set the APP facade.
  *
  * @return void
  */
 public function setUp()
 {
     $app = new Application();
     $app->instance('app', $app);
     $app->register('Codesleeve\\LaravelStapler\\LaravelStaplerServiceProvider');
     Facade::setFacadeApplication($app);
 }
Beispiel #5
0
 public function register()
 {
     $this->app->container->singleton('ioc', function () {
         return new Container();
     });
     Facade::setFacadeApplication($this->app->ioc);
 }
 public static function create()
 {
     $instance = new self();
     // Swap the Facade app with our container (to use these mocks)
     Facade::setFacadeApplication($instance->app);
     return $instance->app;
 }
Beispiel #7
0
 /**
  * Creates the application.
  *
  * @return \Symfony\Component\HttpKernel\HttpKernelInterface
  */
 public function createApplication()
 {
     Facade::setFacadeApplication($app = new Application());
     $app['env'] = 'testing';
     $app['path'] = 'app_path';
     $app['path.config'] = 'config_path';
     return $app;
 }
 /** @test */
 public function it_returns_the_schema_builder()
 {
     $migration = new MigrationStub();
     $mock = Mockery::mock('Illuminate\\Database\\Connection');
     Facade::setFacadeApplication(['db' => $mock]);
     $mock->shouldReceive('getSchemaBuilder')->once()->andReturn('foo');
     $this->assertEquals('foo', $migration->getSchemaBuilder());
 }
 public function setUp()
 {
     $app = M::mock('Application');
     $app = $app->shouldReceive('make')->with('path.public')->andReturn('tmp');
     $app = $app->shouldReceive('make')->with('path')->andReturn('tests');
     $app = $app->mock();
     Facade::setFacadeApplication($app);
 }
 /**
  * setUp method.
  */
 public function setUp()
 {
     // Bootstrap the application container
     $app = new Application();
     $app->instance('app', $app);
     $app->register('Codesleeve\\FixtureL4\\FixtureL4ServiceProvider');
     Facade::setFacadeApplication($app);
 }
 public function testMapping()
 {
     Facade::setFacadeApplication(new ApplicationStub());
     $configuration = ['driver' => 'sqlite', 'database' => 'db', 'username' => 'somedude', 'prefix' => 'mitch_', 'charset' => 'whatevs'];
     $expected = ['driver' => 'pdo_sqlite', 'path' => 'path/database/db.sqlite', 'user' => $configuration['username']];
     $actual = $this->sqlMapper->map($configuration);
     $this->assertEquals($expected, $actual);
 }
 protected function setUp()
 {
     $this->controller = new CommodeControllerTestSubject();
     $this->applicationMock = $this->getMock('Illuminate\\Foundation\\Application', ['make']);
     $this->requestMock = $this->getMock('Illuminate\\Http\\Request', ['ajax']);
     $this->resolver = new Resolver($this->applicationMock);
     Facade::setFacadeApplication($this->applicationMock);
     parent::setUp();
 }
Beispiel #13
0
 public function __construct(array $attributes)
 {
     $this->encrypter = new Encrypter('088409730f085dd15e8e3a7d429dd185', 'AES-256-CBC');
     $app = new Container();
     $app->singleton('app', 'Illuminate\\Container\\Container');
     $app->singleton('config', 'Illuminate\\Config\\Repository');
     $app['config']->set('elocrypt.prefix', '__ELOCRYPT__:');
     Facade::setFacadeApplication($app);
     parent::__construct($attributes);
 }
Beispiel #14
0
 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();
 }
 public function testAllWorks()
 {
     $this->prepareFakeData();
     $app = m::mock('AppMock');
     $app->shouldReceive('instance')->once()->andReturn($app);
     \Illuminate\Support\Facades\Facade::setFacadeApplication($app);
     \Illuminate\Support\Facades\Config::swap($config = m::mock('ConfigMock'));
     $config->shouldReceive('get')->once()->andReturn(5);
     $objs = $this->r->all();
     $this->assertEquals(5, count($objs));
 }
 /**
  * Stop the application
  *
  * @return void
  */
 public function stopApplication()
 {
     if ($this->hasApplicationBeenStarted()) {
         foreach ($this->beforeApplicationDestroyedCallbacks as $callback) {
             call_user_func($callback);
         }
         $this->app->flush();
         $this->app = null;
         Facade::clearResolvedInstances();
         Facade::setFacadeApplication(null);
     }
 }
Beispiel #17
0
 /**
  * Register the facades for the application.
  */
 public function withFacades()
 {
     Facade::setFacadeApplication($this);
     class_alias('Illuminate\\Support\\Facades\\DB', 'DB');
     class_alias('Illuminate\\Support\\Facades\\App', 'App');
     class_alias('Illuminate\\Support\\Facades\\File', 'File');
     class_alias('Illuminate\\Support\\Facades\\Cache', 'Cache');
     class_alias('Illuminate\\Support\\Facades\\Event', 'Event');
     class_alias('Illuminate\\Support\\Facades\\Session', 'Session');
     class_alias('Illuminate\\Support\\Facades\\Request', 'Request');
     class_alias('Illuminate\\Support\\Facades\\Response', 'Response');
 }
Beispiel #18
0
 public function setUp()
 {
     with(new UserSeeder())->run();
     $app = new ApplicationStub();
     \Illuminate\Support\Facades\Facade::setFacadeApplication($app);
     if (!function_exists('trans')) {
         function trans($key)
         {
             return $key;
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $app = new Container();
     $app->singleton('app', 'Illuminate\\Config\\Repository');
     $app->singleton('config', 'Illuminate\\Config\\Repository');
     Facade::setFacadeApplication($app);
     $app['app']->set('aliases.Config', Illuminate\Support\Facades\Config::class);
     $api_key = empty(getenv('YANDEX_API_KEY')) ? include_once 'yandex.api.key.php' : getenv('YANDEX_API_KEY');
     $app['config']->set('services.yandex-translate.key', $api_key);
     $this->translate = new Translate();
 }
Beispiel #20
0
 public function testGetDescrizioneWorks()
 {
     $prefisso = "it";
     L::set($prefisso);
     $desc_expected = "italiano";
     $app = m::mock('AppMock');
     $app->shouldReceive('instance')->once()->andReturn($app);
     \Illuminate\Support\Facades\Facade::setFacadeApplication($app);
     \Illuminate\Support\Facades\Config::swap($config = m::mock('ConfigMock'));
     Config::shouldReceive(['get' => '', 'get' => $desc_expected]);
     $desc = L::get_descrizione();
     $this->assertEquals($desc, $desc_expected);
 }
Beispiel #21
0
 public function setUp()
 {
     parent::setUp();
     // Setup app
     $this->app = m::mock('AppMock');
     $this->app->shouldReceive('instance')->andReturn($this->app);
     // Mock facades
     \Illuminate\Support\Facades\Facade::setFacadeApplication($this->app);
     // Instentiate class to test
     $this->eloquent = m::mock('Eloquent');
     $this->modelVocabulary = $this->mock('Trexology\\Taxonomy\\Models\\Vocabulary');
     $this->modelTerm = $this->mock('Trexology\\Taxonomy\\Models\\Term');
     $this->taxonomy = new Taxonomy($this->modelVocabulary, $this->modelTerm);
 }
Beispiel #22
0
 public static function boot($path)
 {
     $path = rtrim($path, '/') . '/';
     $env = self::getEnv();
     self::$app = new Container();
     self::$app['app'] = self::$app;
     self::$app['env'] = $env;
     self::$app['path'] = $path;
     //config
     self::bootConfig();
     self::bootClasses();
     self::bootView();
     self::bootProviders();
     Facade::setFacadeApplication(self::$app);
 }
Beispiel #23
0
 public function createApplication()
 {
     static $app;
     if (is_null($app) === false) {
         return $app;
     }
     $app = m::mock(Container::class . ', Illuminate\\Contracts\\Foundation\\Application')->makePartial()->shouldReceive('basePath')->andReturn(realpath(__DIR__ . '/../') . '/')->shouldReceive('version')->andReturn('5.x.testing')->shouldReceive('environment')->andReturn('testing')->mock();
     $app->setInstance($app);
     $app['events'] = m::mock(Dispatcher::class)->shouldReceive('fire')->shouldReceive('until')->mock();
     foreach ($this->aliases as $className => $alias) {
         class_alias($className, $alias);
     }
     Facade::setFacadeApplication($app);
     return $this->app = $app;
 }
Beispiel #24
0
 public static function bootstrap($errorCallbacks)
 {
     // Only bootstrap once.
     if (static::$bootstrapped) {
         return;
     }
     // Load helper functions.
     require_once __DIR__ . '/../../../illuminate/support/Illuminate/Support/helpers.php';
     // Directories.
     $basePath = str_finish(realpath(__DIR__ . '/..'), '/');
     $controllersDirectory = $basePath . 'Controllers';
     $modelsDirectory = $basePath . 'Models';
     // Register the autoloader and add directories.
     ClassLoader::register();
     ClassLoader::addDirectories(array($controllersDirectory, $modelsDirectory));
     // Instantiate the container.
     $app = new Container();
     static::$container = $app;
     // Tell facade about the application instance.
     Facade::setFacadeApplication($app);
     // Register application instance with container
     $app['app'] = $app;
     // Set environment.
     $app['env'] = 'production';
     // Enable HTTP Method Override.
     Request::enableHttpMethodParameterOverride();
     // Create the request.
     $app['request'] = Request::createFromGlobals();
     // Register services.
     with(new EventServiceProvider($app))->register();
     with(new RoutingServiceProvider($app))->register();
     // Register aliases.
     foreach (static::$aliases as $alias => $class) {
         class_alias($class, $alias);
     }
     // Load the routes file if it exists.
     if (file_exists($basePath . 'routes.php')) {
         require_once $basePath . 'routes.php';
     }
     // Dispatch on shutdown.
     register_shutdown_function('Seytar\\Routing\\Router::dispatch', $errorCallbacks);
     // Mark bootstrapped.
     static::$bootstrapped = true;
 }
Beispiel #25
0
 /**
  * __construct.
  *
  * @method __construct
  */
 public function __construct()
 {
     $this->app = new Container();
     $this->request = Request::capture();
     $this->dispatcher = new Dispatcher();
     $this->config = new Fluent();
     $this->files = new Filesystem();
     $this->app['request'] = $this->request;
     $this->app['events'] = $this->dispatcher;
     $this->app['config'] = $this->config;
     $this->app['files'] = $this->files;
     Facade::setFacadeApplication($this->app);
     foreach ($this->aliases as $alias => $class) {
         if (class_exists($alias) === true) {
             continue;
         }
         class_alias($class, $alias);
     }
 }
 /**
  * Refresh the application instance.
  *
  * @return void
  */
 protected function refreshApplication()
 {
     $this->app = $this->createApplication();
     Facade::setFacadeApplication($this->app);
     $this->app['env'] = 'testing';
     $this->app['path.storage'] = __DIR__;
     $loader = $this->getMockBuilder('Illuminate\\Config\\LoaderInterface')->setMethods(array('load', 'exists', 'getNamespaces', 'cascadePackage'))->getMockForAbstractClass();
     $loader->method('load')->will($this->returnValue(array()));
     $loader->method('exists')->will($this->returnValue(true));
     $loader->method('getNamespaces')->will($this->returnValue(array()));
     $loader->method('cascadePackage')->will($this->returnValue(array()));
     $this->app['config'] = new Repository($loader, $this->app['env']);
     $this->app['cache'] = new CacheManager($this->app);
     $this->app['config']['cache.driver'] = 'array';
     $this->app['session'] = new SessionManager($this->app);
     $this->app['config']['session.driver'] = 'array';
     $this->app['session.store'] = $this->app['session']->driver();
     $this->app->boot();
 }
Beispiel #27
0
 protected function setUp()
 {
     parent::setUp();
     $app = Mockery::mock('\\Illuminate\\Foundation\\Application');
     $app->shouldReceive('make')->with('path');
     Facade::setFacadeApplication($app);
     Mockery::mock('\\Illuminate\\Html\\HtmlBuilder');
     Mockery::mock('\\Illuminate\\Html\\FormBuilder');
     $this->htmlBuilder = Mockery::mock('\\SleepingOwl\\Html\\HtmlBuilder');
     $formBuilder = Mockery::mock('\\SleepingOwl\\Html\\FormBuilder');
     $finder = Mockery::mock('\\Symfony\\Component\\Finder\\Finder');
     $config = Mockery::mock('\\Illuminate\\Config\\Repository');
     $this->illuminateRouter = Mockery::mock('\\Illuminate\\Routing\\Router');
     $this->urlGenerator = Mockery::mock('\\Illuminate\\Routing\\UrlGenerator');
     $filesystem = Mockery::mock('\\Illuminate\\Filesystem\\Filesystem');
     $this->htmlBuilder->shouldReceive('tag')->andReturnUsing(function ($tag, $attributes = null, $content = null) {
         return '<' . $tag . '>' . $content . '</' . $tag . '>';
     });
     $config->shouldReceive('get')->with('imagecache::route')->andReturn('img/cache');
     $config->shouldReceive('get')->with('admin::title')->andReturn('admin title');
     $config->shouldReceive('get')->with('admin::index')->andReturn(null);
     $config->shouldReceive('get')->with('admin::prefix')->andReturn('test_admin');
     $config->shouldReceive('get')->with('admin::bootstrapDirectory')->andReturn('admin');
     $finder->shouldReceive('create')->andReturnSelf();
     $finder->shouldReceive('files')->andReturnSelf();
     $finder->shouldReceive('name')->andReturnSelf();
     $finder->shouldReceive('in')->andReturnSelf();
     $finder->shouldReceive('sort');
     $finder->shouldReceive('getIterator')->andReturnUsing(function () {
         return new ArrayIterator(['file.php']);
     });
     $filesystem->shouldReceive('requireOnce');
     $filesystem->shouldReceive('isDirectory')->andReturn(true);
     $this->urlGenerator->shouldReceive('route')->with('sleeping-owl-admin.home')->andReturn('route-home');
     $this->urlGenerator->shouldReceive('route')->with('sleeping-owl-admin.wildcard', Mockery::any())->andReturn('route-wildcard');
     $this->urlGenerator->shouldReceive('route')->with('sleeping-owl-admin.table.table', ['menu_item_test_models'])->andReturn('route-to-model');
     $app->shouldReceive('make')->with('\\SleepingOwl\\Admin\\Admin')->andReturnUsing(function () use($formBuilder, $finder, $config, $filesystem) {
         return new Admin($this->htmlBuilder, $formBuilder, $finder, $config, $this->illuminateRouter, $this->urlGenerator, $filesystem);
     });
     $this->admin = Admin::instance();
 }
Beispiel #28
0
 /**
  * Creates the application.
  *
  * Needs to be implemented by subclasses.
  *
  * @return \Symfony\Component\HttpKernel\HttpKernelInterface
  */
 public function createApplication()
 {
     $app = new Application();
     $app->detectEnvironment(array('local' => array('your-machine-name')));
     $app->bindInstallPaths($this->getApplicationPaths());
     $app['env'] = 'testing';
     $app->instance('app', $app);
     Facade::clearResolvedInstances();
     Facade::setFacadeApplication($app);
     $app->registerCoreContainerAliases();
     with($envVariables = new EnvironmentVariables($app->getEnvironmentVariablesLoader()))->load($app['env']);
     $app->instance('config', $config = new Repository($app->getConfigLoader(), $app['env']));
     $app->startExceptionHandling();
     date_default_timezone_set($this->getApplicationTimezone());
     $aliases = array_merge($this->getApplicationAliases(), $this->getPackageAliases());
     AliasLoader::getInstance($aliases)->register();
     Request::enableHttpMethodParameterOverride();
     $providers = array_merge($this->getApplicationProviders(), $this->getPackageProviders());
     $app->getProviderRepository()->load($app, $providers);
     $this->registerBootedCallback($app);
     return $app;
 }
Beispiel #29
0
*/
if (isset($unitTesting)) {
    $app['env'] = $env = $testEnvironment;
}
/*
|--------------------------------------------------------------------------
| Load The Illuminate Facades
|--------------------------------------------------------------------------
|
| The facades provide a terser static interface over the various parts
| of the application, allowing their methods to be accessed through
| a mixtures of magic methods and facade derivatives. It's slick.
|
*/
Facade::clearResolvedInstances();
Facade::setFacadeApplication($app);
/*
|--------------------------------------------------------------------------
| Register Facade Aliases To Full Classes
|--------------------------------------------------------------------------
|
| By default, we use short keys in the container for each of the core
| pieces of the framework. Here we will register the aliases for a
| list of all of the fully qualified class names making DI easy.
|
*/
$app->registerCoreContainerAliases();
/*
|--------------------------------------------------------------------------
| Register The Environment Variables
|--------------------------------------------------------------------------
Beispiel #30
0
 /**
  * Bootstrap the given application.
  *
  * @param  \Illuminate\Contracts\Foundation\Application $app
  * @return void
  */
 public function bootstrap(Application $app)
 {
     Facade::clearResolvedInstances();
     Facade::setFacadeApplication($app);
     AliasLoader::getInstance($app->make('config')->get('app.aliases'))->register();
 }