コード例 #1
0
 public function testSetters()
 {
     $wp = new WorkerPool();
     try {
         $wp->setWorkerPoolSize(5);
     } catch (\Exception $e) {
         $this->assertTrue(FALSE, 'setWorkerPoolSize shouldn\'t throw an exception.');
     }
     try {
         $wp->setChildProcessTitleFormat('X %basename% %class% Child %i% X');
     } catch (\Exception $e) {
         $this->assertTrue(FALSE, 'setChildProcessTitleFormat shouldn\'t throw an exception.');
     }
     try {
         $wp->setParentProcessTitleFormat('X %basename% %class% Parent X');
     } catch (\Exception $e) {
         $this->assertTrue(FALSE, 'setParentProcessTitleFormat shouldn\'t throw an exception.');
     }
     $this->assertEquals(5, $wp->getWorkerPoolSize(), 'getWorkerPoolSize should return an int');
     $this->assertEquals('X %basename% %class% Child %i% X', $wp->getChildProcessTitleFormat(), 'getChildProcessTitleFormat should return a string');
     $this->assertEquals('X %basename% %class% Parent X', $wp->getParentProcessTitleFormat(), 'getParentProcessTitleFormat should return a string');
     $wp->create(new Fixtures\PingWorker());
     try {
         $wp->setWorkerPoolSize(5);
         $this->assertTrue(FALSE, 'setWorkerPoolSize should throw an exception for a created pool.');
     } catch (\Exception $e) {
     }
     try {
         $wp->setChildProcessTitleFormat('%basename% %class% Child %i%');
         $this->assertTrue(FALSE, 'setChildProcessTitleFormat should throw an exception for a created pool.');
     } catch (\Exception $e) {
     }
     try {
         $wp->setParentProcessTitleFormat('%basename% %class% Parent');
         $this->assertTrue(FALSE, 'setParentProcessTitleFormat should throw an exception for a created pool.');
     } catch (\Exception $e) {
     }
     $wp->destroy();
 }