Пример #1
0
 /**
  * @param bool $ignoreUnknownTrackTypes Optional parameter used to skip unknown track types by passing true. The
  *                                      default behavior (false) is throw an exception on unknown track types.
  *
  * @throws \Exception                                          If this function is called before getInfoStartAsync()
  * @throws \Mhor\MediaInfo\Exception\UnknownTrackTypeException
  *
  * @return MediaInfoContainer
  */
 public function getInfoWaitAsync($ignoreUnknownTrackTypes = false)
 {
     if ($this->mediaInfoCommandRunnerAsync == null) {
         throw new \Exception('You must run `getInfoStartAsync` before running `getInfoWaitAsync`');
     }
     // blocks here until process is complete
     $output = $this->mediaInfoCommandRunnerAsync->wait();
     $mediaInfoOutputParser = new MediaInfoOutputParser();
     $mediaInfoOutputParser->parse($output);
     return $mediaInfoOutputParser->getMediaInfoContainer($ignoreUnknownTrackTypes);
 }
 public function testRunAsync()
 {
     $processMock = $this->getMockBuilder('Symfony\\Component\\Process\\Process')->disableOriginalConstructor()->getMock();
     $processMock->method('start')->willReturn($processMock);
     $processMock->method('wait')->willReturn(true);
     $processMock->method('getOutput')->willReturn(file_get_contents($this->outputPath));
     $processMock->method('isSuccessful')->willReturn(true);
     $processBuilderMock = $this->getMockBuilder('Symfony\\Component\\Process\\ProcessBuilder')->disableOriginalConstructor()->getMock();
     $processBuilderMock->method('getProcess')->willReturn($processMock);
     $mediaInfoCommandRunner = new MediaInfoCommandRunner($this->filePath, null, array('--OUTPUT=XML', '-f'), $processBuilderMock);
     $mediaInfoCommandRunner->start();
     // do some stuff in between, count to 5
     $i = 0;
     do {
         $i++;
     } while ($i < 5);
     // block and complete operation
     $output = $mediaInfoCommandRunner->wait();
     $this->assertEquals(file_get_contents($this->outputPath), $output);
 }