Make tests run on Windows (fixes #137)

Use AppVeyor to run tests
This commit is contained in:
Pierre Rudloff 2017-11-11 13:58:55 +01:00
parent 88ea150d5a
commit 2432a06c1b
9 changed files with 116 additions and 29 deletions

View file

@ -48,6 +48,13 @@ class FrontControllerTest extends TestCase
*/
private $controller;
/**
* Config class instance.
*
* @var Config
*/
private $config;
/**
* Prepare tests.
*/
@ -58,7 +65,15 @@ class FrontControllerTest extends TestCase
$this->response = new Response();
$this->container['view'] = ViewFactory::create($this->container, $this->request);
$this->container['locale'] = new LocaleManager();
$this->controller = new FrontController($this->container, Config::getInstance('config/config_test.yml'));
if (PHP_OS == 'WINNT') {
$configFile = 'config_test_windows.yml';
} else {
$configFile = 'config_test.yml';
}
$this->config = Config::getInstance('config/'.$configFile);
$this->controller = new FrontController($this->container, $this->config);
$this->container['router']->map(['GET'], '/', [$this->controller, 'index'])
->setName('index');
$this->container['router']->map(['GET'], '/video', [$this->controller, 'video'])
@ -150,6 +165,18 @@ class FrontControllerTest extends TestCase
* @return void
*/
public function testConstructor()
{
$controller = new FrontController($this->container, $this->config);
$this->assertInstanceOf(FrontController::class, $controller);
}
/**
* Test the constructor with a default config.
*
* @return void
* @requires OS Linux
*/
public function testConstructorWithDefaultConfig()
{
$controller = new FrontController($this->container);
$this->assertInstanceOf(FrontController::class, $controller);
@ -162,7 +189,8 @@ class FrontControllerTest extends TestCase
*/
public function testConstructorWithStream()
{
$controller = new FrontController($this->container, new Config(['stream' => true]));
$this->config->stream = true;
$controller = new FrontController($this->container, $this->config);
$this->assertInstanceOf(FrontController::class, $controller);
}
@ -302,12 +330,12 @@ class FrontControllerTest extends TestCase
*/
public function testVideoWithStream()
{
$config = new Config(['stream' => true]);
$this->assertRequestIsOk('video', ['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU'], $config);
$this->config->stream = true;
$this->assertRequestIsOk('video', ['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU'], $this->config);
$this->assertRequestIsOk(
'video',
['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'audio' => true],
$config
$this->config
);
}
@ -375,10 +403,11 @@ class FrontControllerTest extends TestCase
*/
public function testRedirectWithStream()
{
$this->config->stream = true;
$this->assertRequestIsOk(
'redirect',
['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU'],
new Config(['stream' => true])
$this->config
);
}
@ -389,10 +418,11 @@ class FrontControllerTest extends TestCase
*/
public function testRedirectWithM3uStream()
{
$this->config->stream = true;
$this->assertRequestIsOk(
'redirect',
['url' => 'https://twitter.com/verge/status/813055465324056576/video/1'],
new Config(['stream' => true])
$this->config
);
}
@ -403,10 +433,11 @@ class FrontControllerTest extends TestCase
*/
public function testRedirectWithRtmpStream()
{
$this->config->stream = true;
$this->assertRequestIsOk(
'redirect',
['url' => 'http://www.canalc2.tv/video/12163', 'format' => 'rtmp'],
new Config(['stream' => true])
$this->config
);
}
@ -417,13 +448,14 @@ class FrontControllerTest extends TestCase
*/
public function testRedirectWithRemux()
{
$this->config->remux = true;
$this->assertRequestIsOk(
'redirect',
[
'url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU',
'format' => 'bestvideo+bestaudio',
],
new Config(['remux' => true])
$this->config
);
}
@ -481,13 +513,15 @@ class FrontControllerTest extends TestCase
* Test the redirect() function with a playlist stream.
*
* @return void
* @requires OS Linux
*/
public function testRedirectWithPlaylist()
{
$this->config->stream = true;
$this->assertRequestIsOk(
'redirect',
['url' => 'https://www.youtube.com/playlist?list=PLgdySZU6KUXL_8Jq5aUkyNV7wCa-4wZsC'],
new Config(['stream' => true])
$this->config
);
}