Example #1
0
 public function testSingleton()
 {
     $config = Config::getInstance();
     $this->assertInstanceOf('Sinergi\\Gearman\\Config', $config);
     $config = new Config();
     $config->setUser('test1');
     $config = Config::getInstance();
     $this->assertInstanceOf('Sinergi\\Gearman\\Config', $config);
     $this->assertEquals('test1', $config->getUser());
 }
Example #2
0
 /**
  * @param Config $config
  * @param StreamSelectLoop|LibEventLoop $loop
  * @param Process $process
  * @param LoggerInterface|null $logger
  */
 public function __construct(Config $config = null, Process $process = null, $loop = null, LoggerInterface $logger = null)
 {
     static::$instance = $this;
     if (null === $config) {
         $config = Config::getInstance();
     }
     $this->setConfig($config);
     if (null !== $logger) {
         $this->setLogger($logger);
     }
     if (null !== $process) {
         $this->setProcess($process);
     }
     if ($loop instanceof StreamSelectLoop || $loop instanceof LibEventLoop) {
         $this->setLoop($loop);
     }
 }