Skip to content

Commit d4f3204

Browse files
committed
test: refactor tests for remote URLs support
Refs #55
1 parent 022e95a commit d4f3204

3 files changed

Lines changed: 19 additions & 50 deletions

File tree

tests/MovieTest.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ public static function setUpBeforeClass(): void
3232
self::$moviePath = dirname(__FILE__).DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test.mp4';
3333
self::$audioPath = dirname(__FILE__).DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test.wav';
3434
self::$noMediaPath = dirname(__FILE__).DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test1.txt';
35-
self::$movieUrl = array(
36-
'base' => 'https://github.com/char0n/ffmpeg-php/blob/master/tests/data/',
37-
'fileName' => 'test',
38-
'fileExtension' => '.mp4',
39-
'query' => '?raw=true'
40-
);
35+
self::$movieUrl = 'https://github.com/char0n/ffmpeg-php/blob/master/tests/data/test.mp4?raw=true';
4136
}
4237

4338
public static function tearDownAfterClass(): void
@@ -67,20 +62,18 @@ public function testFileDoesNotExistException()
6762
new Movie(uniqid('test', true));
6863
}
6964

70-
public function testFileFromUrlDoesNotExistException()
65+
public function testRemoteUrlMovieFile()
66+
{
67+
$movie = new Movie(self::$movieUrl);
68+
$this->assertInstanceOf(Movie::class, $movie);
69+
}
70+
71+
public function testRemoteUrlMovieFileDoesNotExistException()
7172
{
7273
$this->expectException(\UnexpectedValueException::class);
7374
$this->expectExceptionCode(334561);
7475

75-
$nonExistingUrlFile = sprintf(
76-
'%s%s%s%s',
77-
self::$movieUrl['base'],
78-
uniqid('test', true),
79-
self::$movieUrl['fileExtension'],
80-
self::$movieUrl['query']
81-
);
82-
83-
new Movie($nonExistingUrlFile);
76+
new Movie('https://github.com/char0n/test.mp4');
8477
}
8578

8679
public function testPersistentResourceSimulation()

tests/OutputProviders/FFMpegProviderTest.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ public static function setUpBeforeClass(): void
2020
{
2121
$path = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR;
2222
self::$moviePath = realpath($path.'test.mp4');
23-
self::$movieUrl = array(
24-
'base' => 'https://github.com/char0n/ffmpeg-php/blob/master/tests/data/',
25-
'fileName' => 'test',
26-
'fileExtension' => '.mp4',
27-
'query' => '?raw=true'
28-
);
23+
self::$movieUrl = 'https://github.com/char0n/ffmpeg-php/blob/master/tests/data/test.mp4?raw=true';
2924
}
3025

3126
public static function tearDownAfterClass(): void
@@ -60,29 +55,22 @@ public function testGetOutputFileDoesNotExist()
6055
$provider->getOutput();
6156
}
6257

63-
public function testGetOutputUrl()
58+
public function testGetOutputFromRemoteUrl()
6459
{
6560
$provider = new FFMpegProvider();
66-
$provider->setMovieFile(implode(self::$movieUrl));
61+
$provider->setMovieFile(self::$movieUrl);
6762
$output = $provider->getOutput();
6863

6964
$this->assertEquals(1, preg_match('/FFmpeg version/i', $output));
7065
}
7166

72-
public function testGetOutputUrlFileDoesNotExist()
67+
public function testGetOutputFromRemoteUrlDoesNotExist()
7368
{
7469
$this->expectException(\UnexpectedValueException::class);
7570
$this->expectExceptionCode(334561);
7671

7772
$provider = new FFMpegProvider();
78-
$nonExistingUrlFile = sprintf(
79-
'%s%s%s%s',
80-
self::$movieUrl['base'],
81-
uniqid('test', true),
82-
self::$movieUrl['fileExtension'],
83-
self::$movieUrl['query']
84-
);
85-
$provider->setMovieFile($nonExistingUrlFile);
73+
$provider->setMovieFile('https://github.com/char0n/test.mp4');
8674
$provider->getOutput();
8775
}
8876

tests/OutputProviders/FFProbeProviderTest.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ public static function setUpBeforeClass(): void
2020
{
2121
$path = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR;
2222
self::$moviePath = realpath($path.'test.mp4');
23-
self::$movieUrl = array(
24-
'base' => 'https://github.com/char0n/ffmpeg-php/blob/master/tests/data/',
25-
'fileName' => 'test',
26-
'fileExtension' => '.mp4',
27-
'query' => '?raw=true'
28-
);
23+
self::$movieUrl = 'https://github.com/char0n/ffmpeg-php/blob/master/tests/data/test.mp4?raw=true';
2924
}
3025

3126
public static function tearDownAfterClass(): void
@@ -60,29 +55,22 @@ public function testGetOutputFileDoesNotExist()
6055
$provider->getOutput();
6156
}
6257

63-
public function testGetOutputUrl()
58+
public function testGetOutputFromRemoteUrl()
6459
{
6560
$provider = new FFProbeProvider();
66-
$provider->setMovieFile(implode(self::$movieUrl));
61+
$provider->setMovieFile(self::$movieUrl);
6762
$output = $provider->getOutput();
6863

6964
$this->assertEquals(1, preg_match('/FFprobe version/i', $output));
7065
}
7166

72-
public function testGetOutputUrlFileDoesNotExist()
67+
public function testGetOutputFromRemoteUrlDoesNotExist()
7368
{
7469
$this->expectException(\UnexpectedValueException::class);
7570
$this->expectExceptionCode(334561);
7671

7772
$provider = new FFProbeProvider();
78-
$nonExistingUrlFile = sprintf(
79-
'%s%s%s%s',
80-
self::$movieUrl['base'],
81-
uniqid('test', true),
82-
self::$movieUrl['fileExtension'],
83-
self::$movieUrl['query']
84-
);
85-
$provider->setMovieFile($nonExistingUrlFile);
73+
$provider->setMovieFile('https://github.com/char0n/test.mp4');
8674
$provider->getOutput();
8775
}
8876

0 commit comments

Comments
 (0)