1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- /**
- * This file is part of the PHPExiftool package.
- *
- * (c) Alchemy <support@alchemy.fr>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace PHPExiftool\Test;
- use PHPExiftool\PreviewExtractor;
- abstract class AbstractPreviewExtractorTest extends \PHPUnit_Framework_TestCase
- {
- /**
- * @covers PHPExiftool\PreviewExtractor::extract
- */
- public function testExtract()
- {
- $extractor = new PreviewExtractor($this->getExiftool());
- $tmpDir = sys_get_temp_dir() . '/tests' . mt_rand(10000, 99999);
- mkdir($tmpDir);
- $files = $extractor->extract(__DIR__ . '/../../../files/ExifTool.jpg', $tmpDir);
- $this->assertInstanceOf('\\DirectoryIterator', $files);
- $n = 0;
- $unlinks = array();
- foreach ($files as $file) {
- if ($file->isDot() || $file->isDir()) {
- continue;
- }
- $unlinks[] = $file->getPathname();
- $n ++;
- }
- foreach ($unlinks as $u) {
- unlink($u);
- }
- $this->assertEquals(1, $n);
- }
- /**
- * @expectedException \PHPExiftool\Exception\LogicException
- */
- public function testExtractWrongFile()
- {
- $extractor = new PreviewExtractor($this->getExiftool());
- $tmpDir = sys_get_temp_dir() . '/tests' . mt_rand(10000, 99999);
- $extractor->extract(__DIR__ . '/ExifTool.jpg', $tmpDir);
- }
- /**
- * @expectedException \PHPExiftool\Exception\LogicException
- */
- public function testExtractWrongDir()
- {
- $extractor = new PreviewExtractor($this->getExiftool());
- $tmpDir = sys_get_temp_dir() . '/tests' . mt_rand(10000, 99999);
- $extractor->extract(__DIR__ . '/../../../files/ExifTool.jpg', $tmpDir);
- }
- abstract protected function getExiftool();
- }
|