Update travis & tests
This commit is contained in:
parent
5d57a5fd82
commit
46095c9024
26
.travis.yml
26
.travis.yml
|
@ -4,17 +4,15 @@ php:
|
||||||
- '5.6'
|
- '5.6'
|
||||||
- '7.0'
|
- '7.0'
|
||||||
|
|
||||||
#install:
|
install:
|
||||||
# - curl -s http://getcomposer.org/installer | php
|
- curl -s http://getcomposer.org/installer | php
|
||||||
# - php composer.phar install --dev --no-interaction
|
- php composer.phar install --dev --no-interaction
|
||||||
# - composer dump-autoload
|
- composer dump-autoload
|
||||||
#
|
|
||||||
#script:
|
script:
|
||||||
# - mkdir -p build/cov
|
- mkdir -p build/cov
|
||||||
# - mkdir -p build/logs
|
- mkdir -p build/logs
|
||||||
# - php vendor/bin/phpunit -c phpunit.dist.xml
|
- php vendor/bin/phpunit -c phpunit.dist.xml
|
||||||
#
|
|
||||||
#after_success:
|
after_success:
|
||||||
# - travis_retry php vendor/bin/coveralls -v
|
- travis_retry php vendor/bin/codacycoverage clover build/logs/clover.xml
|
||||||
# - travis_retry php vendor/bin/codacycoverage clover build/logs/clover.xml
|
|
||||||
#
|
|
||||||
|
|
|
@ -12,9 +12,14 @@
|
||||||
],
|
],
|
||||||
"require" : {
|
"require" : {
|
||||||
"php": ">=5.5.0",
|
"php": ">=5.5.0",
|
||||||
"alphayax/php_utils" : "^1.0.0",
|
"alphayax/php_utils" : "^1.0.2",
|
||||||
"monolog/monolog": "^1.9.1"
|
"monolog/monolog": "^1.9.1"
|
||||||
},
|
},
|
||||||
|
"require-dev" : {
|
||||||
|
"phpunit/phpunit": "^5.4.0",
|
||||||
|
"zf1/zend-reflection": "1.12.*",
|
||||||
|
"codacy/coverage": "<2.0.0"
|
||||||
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"alphayax\\": "./"
|
"alphayax\\": "./"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
require_once '../../vendor/autoload.php';
|
require_once '../../vendor/autoload.php';
|
||||||
|
|
||||||
/// Define our application
|
/// Define our application
|
||||||
$App = new \alphayax\freebox\utils\Application( 'com.alphayax.freebox.example_airmedia', 'Freebox PHP API Example (AirMedia)', '1.0.0');
|
$App = new \alphayax\freebox\utils\Application( 'com.alphayax.freebox.airmedia', 'PHP API Example (AirMedia)', '1.0.0');
|
||||||
$App->authorize();
|
$App->authorize();
|
||||||
$App->openSession();
|
$App->openSession();
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ $AirMediaService = new \alphayax\freebox\api\v3\services\AirMedia\AirMedia( $App
|
||||||
|
|
||||||
// AirMedia Config
|
// AirMedia Config
|
||||||
$Configuration = $AirMediaService->getConfiguration();
|
$Configuration = $AirMediaService->getConfiguration();
|
||||||
var_dump( $Configuration);
|
print_r( $Configuration);
|
||||||
|
/*
|
||||||
// AirMedia Receivers
|
// AirMedia Receivers
|
||||||
$Receivers = $AirMediaService->getAirMediaReceivers();
|
$Receivers = $AirMediaService->getAirMediaReceivers();
|
||||||
var_dump( $Receivers);
|
var_dump( $Receivers);
|
||||||
|
@ -27,3 +27,4 @@ $Request->setMedia( 'http://anon.nasa-global.edgesuite.net/HD_downloads/GRAIL_la
|
||||||
|
|
||||||
$Status = $AirMediaService->sendRequestToAirMediaReceiver( 'Freebox Player', $Request);
|
$Status = $AirMediaService->sendRequestToAirMediaReceiver( 'Freebox Player', $Request);
|
||||||
var_dump( $Status);
|
var_dump( $Status);
|
||||||
|
*/
|
|
@ -0,0 +1,10 @@
|
||||||
|
<phpunit bootstrap="vendor/autoload.php">
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="all">
|
||||||
|
<directory>tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<logging>
|
||||||
|
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||||
|
</logging>
|
||||||
|
</phpunit>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<phpunit bootstrap="vendor/autoload.php">
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="all">
|
||||||
|
<directory>tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<logging>
|
||||||
|
<log type="coverage-clover" target="clover.xml"/>
|
||||||
|
</logging>
|
||||||
|
</phpunit>
|
|
@ -0,0 +1,95 @@
|
||||||
|
<?php
|
||||||
|
namespace alphayax\tests;
|
||||||
|
use alphayax\freebox\api\v3\Model;
|
||||||
|
use alphayax\utils\file_system\Directory;
|
||||||
|
|
||||||
|
|
||||||
|
class Test extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
|
public function testModel(){
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
/// Load Models
|
||||||
|
$ModelsDir = new Directory( '../freebox/api/v3/models/');
|
||||||
|
$ModelFiles = $ModelsDir->getFilesByExtension( 'php', true);
|
||||||
|
foreach ($ModelFiles as $modelFile){
|
||||||
|
require_once $modelFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get Model subClasses
|
||||||
|
$LoadedClasses = get_declared_classes();
|
||||||
|
$ModelClasses = [];
|
||||||
|
foreach( $LoadedClasses as $loadedClass){
|
||||||
|
if( is_subclass_of( $loadedClass, Model::class)){
|
||||||
|
$ModelClasses[] = $loadedClass;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test classes
|
||||||
|
foreach( $ModelClasses as $modelClass){
|
||||||
|
$ModelReflect = new \ReflectionClass( $modelClass);
|
||||||
|
|
||||||
|
$ClassArgs = [];
|
||||||
|
$properties = $ModelReflect->getProperties();
|
||||||
|
foreach ( $properties as $property){
|
||||||
|
$ClassArgs[$property->getName()] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$Model = new $modelClass($ClassArgs);
|
||||||
|
|
||||||
|
$methods = $ModelReflect->getMethods();
|
||||||
|
foreach ( $methods as $method){
|
||||||
|
|
||||||
|
$method = new \Zend_Reflection_Method( $Model, $method->getName());
|
||||||
|
$docBlock = $method->getDocblock();
|
||||||
|
echo "--" . PHP_EOL;
|
||||||
|
echo "$modelClass " . $method->getName() . PHP_EOL;
|
||||||
|
|
||||||
|
if( ! $method->isPublic()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$args = [];
|
||||||
|
if($docBlock->hasTag('param')) {
|
||||||
|
/** @var \Zend_Reflection_Docblock_Tag_Param[] $tagParams */
|
||||||
|
$tagParams = $docBlock->getTags('param'); // $tagReturn is an instance of Zend_Reflection_Docblock_Tag_Return
|
||||||
|
foreach ( $tagParams as $tagParam){
|
||||||
|
echo "Param Type : " . $tagParam->getType() . PHP_EOL;
|
||||||
|
|
||||||
|
switch( $tagParam->getType()){
|
||||||
|
case 'string' : $args[] = $tagParam->getName(); break;
|
||||||
|
case 'bool':
|
||||||
|
case 'boolean': $args[] = true; break;
|
||||||
|
case 'array' : $args[] = []; break;
|
||||||
|
default : print_r( $tagParam); return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$a = $method->invokeArgs( $Model, $args);
|
||||||
|
|
||||||
|
if( $docBlock->hasTag('return')) {
|
||||||
|
/** @var \Zend_Reflection_Docblock_Tag_Return $tagReturn */
|
||||||
|
$tagReturn = $docBlock->getTag('return');
|
||||||
|
echo "Returns a: " . $tagReturn->getType() . PHP_EOL;
|
||||||
|
|
||||||
|
$this->assertInternalType( $tagReturn->getType(), $a);
|
||||||
|
/*
|
||||||
|
switch( $tagReturn->getType()){
|
||||||
|
case 'string' : $this->assertInternalType( string); break;
|
||||||
|
case 'bool':
|
||||||
|
case 'boolean': $args[] = true; break;
|
||||||
|
case 'array' : $args[] = []; break;
|
||||||
|
default : print_r( $tagParam); return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
namespace alphayax\tests\models;
|
||||||
|
|
||||||
|
|
||||||
|
use alphayax\freebox\api\v3\models\AirMedia\AirMediaConfig;
|
||||||
|
|
||||||
|
class AirMediaConfigTest extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
|
|
||||||
|
public function testConstruct(){
|
||||||
|
$data = [
|
||||||
|
'enabled' => true,
|
||||||
|
];
|
||||||
|
$AM_Config = new AirMediaConfig( $data);
|
||||||
|
|
||||||
|
$this->assertAttributeEquals( $data['enabled'], 'enabled', $AM_Config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetters() {
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'enabled' => true,
|
||||||
|
];
|
||||||
|
$AM_Config = new AirMediaConfig( $data);
|
||||||
|
|
||||||
|
$this->assertEquals( $AM_Config->isEnabled(), $data['enabled']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetters() {
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'enabled' => true,
|
||||||
|
];
|
||||||
|
$AM_Config = new AirMediaConfig( $data);
|
||||||
|
|
||||||
|
$AM_Config->setEnabled( false);
|
||||||
|
$this->assertAttributeEquals( false, 'enabled', $AM_Config);
|
||||||
|
|
||||||
|
$AM_Config->setPassword( 'azerty');
|
||||||
|
$this->assertAttributeEquals( 'azerty', 'password', $AM_Config);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue