Update travis & tests
This commit is contained in:
parent
aa9e7602b6
commit
219aeb2234
|
@ -10,3 +10,4 @@
|
|||
# Project files
|
||||
/app_token
|
||||
/exemple/**/app_token
|
||||
/clover.xml
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
![unstable](https://poser.pugx.org/alphayax/freebox_api_php/v/unstable)
|
||||
![pakagist](https://img.shields.io/packagist/v/alphayax/freebox_api_php.svg)
|
||||
|
||||
[![Build Status](https://travis-ci.org/alphayax/freebox_api_php.svg?branch=master)](https://travis-ci.org/alphayax/freebox_api_php)
|
||||
[![Coverage](https://api.codacy.com/project/badge/Coverage/f3569cf671f04b8ab6d699be3fd011e5)](https://www.codacy.com/app/alphayax/freebox_api_php?utm_source=github.com&utm_medium=referral&utm_content=alphayax/freebox_api_php&utm_campaign=Badge_Coverage)
|
||||
![codacy](https://api.codacy.com/project/badge/Grade/f3569cf671f04b8ab6d699be3fd011e5)
|
||||
|
||||
![license](https://img.shields.io/packagist/l/alphayax/freebox_api_php.svg)
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
<phpunit bootstrap="vendor/autoload.php">
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">freebox</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<testsuites>
|
||||
<testsuite name="all">
|
||||
<directory>tests</directory>
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
namespace alphayax\tests\models;
|
||||
use alphayax\freebox\api\v3\models\AirMedia\AirMediaReceiver;
|
||||
|
||||
/**
|
||||
* Class AirMediaReceiverTest
|
||||
* @package alphayax\tests\models
|
||||
*/
|
||||
class AirMediaReceiverTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function modelProvider(){
|
||||
$data = <<<JSON
|
||||
[
|
||||
{
|
||||
"capabilities": {
|
||||
"photo": true,
|
||||
"screen": false,
|
||||
"audio": true,
|
||||
"video": true
|
||||
},
|
||||
"name": "Freebox Player",
|
||||
"password_protected": true
|
||||
},
|
||||
{
|
||||
"capabilities": {
|
||||
"photo": false,
|
||||
"screen": false,
|
||||
"audio": true,
|
||||
"video": false
|
||||
},
|
||||
"name": "Freebox Server",
|
||||
"password_protected": false
|
||||
}
|
||||
]
|
||||
JSON;
|
||||
|
||||
$datas = json_decode( $data, true);
|
||||
$provider = [];
|
||||
foreach( $datas as $item){
|
||||
$provider[] = [new AirMediaReceiver( $item), $item];
|
||||
}
|
||||
return $provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider modelProvider
|
||||
* @param AirMediaReceiver $model
|
||||
* @param array $data
|
||||
*/
|
||||
public function testConstruct( $model, $data){
|
||||
$this->assertAttributeEquals( $data['capabilities'] , 'capabilities' , $model);
|
||||
$this->assertAttributeEquals( $data['name'] , 'name' , $model);
|
||||
$this->assertAttributeEquals( $data['password_protected'], 'password_protected' , $model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider modelProvider
|
||||
* @param AirMediaReceiver $model
|
||||
* @param array $data
|
||||
*/
|
||||
public function testGetters( $model, $data) {
|
||||
$this->assertEquals( $model->getCapabilities() , $data['capabilities']);
|
||||
$this->assertEquals( $model->isPasswordProtected() , $data['password_protected']);
|
||||
$this->assertEquals( $model->getName() , $data['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider modelProvider
|
||||
* @param AirMediaReceiver $model
|
||||
* @param array $data
|
||||
*/
|
||||
public function testSetters( $model, $data) {
|
||||
// No setters
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider modelProvider
|
||||
* @param AirMediaReceiver $model
|
||||
* @param array $data
|
||||
*/
|
||||
public function testSerialize( $model, $data){
|
||||
$json = json_encode( $model);
|
||||
$this->assertNotFalse( $json);
|
||||
|
||||
$model_x = json_decode( $json, true);
|
||||
$this->assertEquals( $model_x, $data);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,17 +1,20 @@
|
|||
<?php
|
||||
namespace alphayax\tests\models;
|
||||
|
||||
|
||||
use alphayax\freebox\api\v3\models\AirMedia\AirMediaConfig;
|
||||
|
||||
/**
|
||||
* Class AirMediaConfigTest
|
||||
* @package alphayax\tests\models
|
||||
*/
|
||||
class AirMediaConfigTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function modelProvider(){
|
||||
|
||||
$data = [
|
||||
'enabled' => true,
|
||||
];
|
||||
|
||||
return [
|
||||
[new AirMediaConfig( $data), $data],
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue