getInstance() public static method

Return the object instance (Singleton)
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. The Environment class is now static.
public static getInstance ( ) : Environment
return Environment The object instance
Beispiel #1
0
 /**
  * Test the booting in the frontend.
  *
  * @return void
  */
 public function testBootBackend()
 {
     $dispatcher = $this->mockEventDispatcher(array(MetaModelsEvents::SUBSYSTEM_BOOT, MetaModelsEvents::SUBSYSTEM_BOOT_BACKEND));
     $environment = \Contao\Environment::getInstance();
     $container = new MetaModelsServiceContainer();
     $container->setEventDispatcher($dispatcher);
     $environment::set('script', 'contao/main.php');
     $boot = $this->getMock('MetaModels\\Helper\\SubSystemBoot', array('getMode', 'metaModelsTablesPresent'));
     $boot->expects($this->any())->method('getMode')->will($this->returnValue('BE'));
     $boot->expects($this->any())->method('metaModelsTablesPresent')->will($this->returnValue(true));
     $class = new \ReflectionClass($boot);
     $getMode = $class->getMethod('getMode');
     $getMode->setAccessible(true);
     /** @var SubSystemBoot $boot */
     $this->assertEquals('BE', $getMode->invoke($boot));
     $boot->boot(new \Pimple(array('environment' => $environment, 'metamodels-service-container' => $container)));
 }