/** * Create the singleton instance only if it doesn't exists already. * * @param LoggerInterface $log Allow any logger extended from PSR\Log * @param Application $sugarApp * @param string $sugarUserId * * @throws \RuntimeException */ public static function createInstance(Application $sugarApp, $sugarUserId) { if (!is_null(self::$instance)) { if (self::$instance->getPath() !== $sugarApp->getPath()) { // We have an instance but with a different path throw new \RuntimeException('Unable to create another SugarCRM\\EntryPoint from another path.'); } self::$instance->getInstance(); self::$instance->setCurrentUser($sugarUserId); } else { // Init in a variable for now in case an exception occurs $instance = new self($sugarApp, $sugarUserId); $instance->initSugar(); // now that sugar in initialized without exceptions we can set the single instance. self::$instance = $instance; } return self::$instance; }
/** * @expectedException \Inet\SugarCrm\Exception\SugarException */ public function testInvalidVersion() { $sugar = new Application(new NullLogger(), __DIR__); $sugar->getVersion(); }