provider = new FFmpegOutputProvider(); $this->provider->setMovieFile(self::$moviePath); } public function tearDown() { $this->provider = null; } public function testGetOutput() { $output = $this->provider->getOutput(); $this->assertEquals(1, preg_match('/FFmpeg version/i', $output)); } public function testGetOutputFileDoesntExist() { try { $provider = new FFmpegOutputProvider(); $provider->setMovieFile(uniqid('test', true)); $provider->getOutput(); } catch (Exception $ex) { if ($ex->getCode() == 334561) { return; } else { $this->fail('Expected exception raise with wrong code'); } } $this->fail('An expected exception with code 334561 has not been raised'); } public function testPersistentResourceSimulation() { PHP_Timer::start(); $provider = new FFmpegOutputProvider('ffmpeg', true); $provider->setMovieFile(self::$moviePath); $provider->getOutput(); $provider = clone $provider; $provider->getOutput(); $provider = clone $provider; $provider->getOutput(); $elapsed = PHP_Timer::stop(); PHP_Timer::start(); $provider = new FFmpegOutputProvider('ffmpeg', false); $provider->setMovieFile(self::$moviePath); $provider->getOutput(); $provider = clone $provider; $provider->getOutput(); $provider = clone $provider; $provider->getOutput(); $elapsed1 = PHP_Timer::stop(); $this->assertGreaterThan($elapsed, $elapsed1, 'Persistent resource simulation should be faster'); } public function testSerializeUnserialize() { $output = $this->provider->getOutput(); $serialized = serialize($this->provider); $this->provider = null; $this->provider = unserialize($serialized); $this->assertEquals($output, $this->provider->getOutput(), 'Output from original and unserialized provider should be equal'); } }