refactor: New Video class
The news class provides a cleaner object-oriented logic BREAKING CHANGE: The VideoDownload class has been removed and the Config constructor is now private
This commit is contained in:
parent
feb8998188
commit
4c9af8ad1d
18 changed files with 665 additions and 719 deletions
|
@ -1,123 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* VideoDownloadStubsTest class.
|
||||
*/
|
||||
|
||||
namespace Alltube\Test;
|
||||
|
||||
use Alltube\Config;
|
||||
use Alltube\VideoDownload;
|
||||
use Mockery;
|
||||
use phpmock\mockery\PHPMockery;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Unit tests for the VideoDownload class.
|
||||
* They are in a separate file so they can safely replace PHP functions with stubs.
|
||||
*/
|
||||
class VideoDownloadStubsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* VideoDownload instance.
|
||||
*
|
||||
* @var VideoDownload
|
||||
*/
|
||||
private $download;
|
||||
|
||||
/**
|
||||
* Config class instance.
|
||||
*
|
||||
* @var Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* Video URL used in many tests.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* Initialize properties used by test.
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
PHPMockery::mock('Alltube', 'popen');
|
||||
PHPMockery::mock('Alltube', 'fopen');
|
||||
|
||||
if (PHP_OS == 'WINNT') {
|
||||
$configFile = 'config_test_windows.yml';
|
||||
} else {
|
||||
$configFile = 'config_test.yml';
|
||||
}
|
||||
$this->config = Config::getInstance('config/'.$configFile);
|
||||
$this->download = new VideoDownload($this->config);
|
||||
$this->url = 'https://www.youtube.com/watch?v=XJC9_JkzugE';
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove stubs.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
Mockery::close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getAudioStream function with a buggy popen.
|
||||
*
|
||||
* @return void
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testGetAudioStreamWithPopenError()
|
||||
{
|
||||
$this->download->getAudioStream($this->url, 'best');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getM3uStream function with a buggy popen.
|
||||
*
|
||||
* @return void
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testGetM3uStreamWithPopenError()
|
||||
{
|
||||
$this->download->getM3uStream($this->download->getJSON($this->url, 'best'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getRtmpStream function with a buggy popen.
|
||||
*
|
||||
* @return void
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testGetRtmpStreamWithPopenError()
|
||||
{
|
||||
$this->download->getRtmpStream($this->download->getJSON($this->url, 'best'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getRemuxStream function with a buggy popen.
|
||||
*
|
||||
* @return void
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testGetRemuxStreamWithPopenError()
|
||||
{
|
||||
$this->download->getRemuxStream([$this->url, $this->url]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getConvertedStream function with a buggy popen.
|
||||
*
|
||||
* @return void
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testGetConvertedStreamWithPopenError()
|
||||
{
|
||||
$this->download->getConvertedStream($this->url, 'best', 32, 'flv');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue