Merge branch 'feature/codecov' into develop
This commit is contained in:
commit
a1b5409555
6 changed files with 33 additions and 12 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,3 +11,4 @@ coverage/
|
||||||
bower_components/
|
bower_components/
|
||||||
config.yml
|
config.yml
|
||||||
docs/
|
docs/
|
||||||
|
clover.xml
|
||||||
|
|
|
@ -3,3 +3,5 @@ install:
|
||||||
- composer install --no-dev
|
- composer install --no-dev
|
||||||
before_install:
|
before_install:
|
||||||
- composer selfupdate
|
- composer selfupdate
|
||||||
|
after_success:
|
||||||
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
|
|
|
@ -65,12 +65,14 @@ class Config
|
||||||
*/
|
*/
|
||||||
public $curl_params = array();
|
public $curl_params = array();
|
||||||
|
|
||||||
|
private $configFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config constructor
|
* Config constructor
|
||||||
*/
|
*/
|
||||||
private function __construct()
|
private function __construct($yamlfile)
|
||||||
{
|
{
|
||||||
$yamlfile = __DIR__.'/../config.yml';
|
$this->file = $yamlfile;
|
||||||
if (is_file($yamlfile)) {
|
if (is_file($yamlfile)) {
|
||||||
$yaml = Yaml::parse(file_get_contents($yamlfile));
|
$yaml = Yaml::parse(file_get_contents($yamlfile));
|
||||||
if (isset($yaml) && is_array($yaml)) {
|
if (isset($yaml) && is_array($yaml)) {
|
||||||
|
@ -91,10 +93,11 @@ class Config
|
||||||
*
|
*
|
||||||
* @return Config
|
* @return Config
|
||||||
*/
|
*/
|
||||||
public static function getInstance()
|
public static function getInstance($yamlfile = 'config.yml')
|
||||||
{
|
{
|
||||||
if (is_null(self::$instance)) {
|
$yamlfile = __DIR__.'/../'.$yamlfile;
|
||||||
self::$instance = new Config();
|
if (is_null(self::$instance) || self::$instance->file != $yamlfile) {
|
||||||
|
self::$instance = new Config($yamlfile);
|
||||||
}
|
}
|
||||||
return self::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
|
1
config_test.yml
Normal file
1
config_test.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
convert: false
|
|
@ -11,5 +11,6 @@
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<logging>
|
<logging>
|
||||||
<log type="coverage-html" target="coverage/" />
|
<log type="coverage-html" target="coverage/" />
|
||||||
|
<log type="coverage-clover" target="clover.xml" />
|
||||||
</logging>
|
</logging>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|
|
@ -12,21 +12,34 @@ use Alltube\Config;
|
||||||
class ConfigTest extends \PHPUnit_Framework_TestCase
|
class ConfigTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private $config;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->config = Config::getInstance('config_test.yml');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the getInstance function
|
* Test the getInstance function
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testGetInstance()
|
public function testGetInstance()
|
||||||
|
{
|
||||||
|
$this->assertEquals($this->config->convert, false);
|
||||||
|
$this->assertInternalType('array', $this->config->curl_params);
|
||||||
|
$this->assertInternalType('array', $this->config->params);
|
||||||
|
$this->assertInternalType('string', $this->config->youtubedl);
|
||||||
|
$this->assertInternalType('string', $this->config->python);
|
||||||
|
$this->assertInternalType('string', $this->config->avconv);
|
||||||
|
$this->assertInternalType('string', $this->config->rtmpdump);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetInstanceWithEnv()
|
||||||
{
|
{
|
||||||
putenv('CONVERT=1');
|
putenv('CONVERT=1');
|
||||||
$config = Config::getInstance();
|
Config::destroyInstance();
|
||||||
|
$config = Config::getInstance('config_test.yml');
|
||||||
$this->assertEquals($config->convert, true);
|
$this->assertEquals($config->convert, true);
|
||||||
$this->assertInternalType('array', $config->curl_params);
|
|
||||||
$this->assertInternalType('array', $config->params);
|
|
||||||
$this->assertInternalType('string', $config->youtubedl);
|
|
||||||
$this->assertInternalType('string', $config->python);
|
|
||||||
$this->assertInternalType('string', $config->avconv);
|
|
||||||
$this->assertInternalType('string', $config->rtmpdump);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue