<?php
use MiotApi\Contract\Specification\PropertySpecification;
class PropertySpecificationTest extends PHPUnit_Framework_TestCase
{
private $property;
public function testInit()
{
$urn = 'urn:miot-spec-v2:property:air-quality:0000001C';
$this->property = new PropertySpecification($urn);
$this->assertEquals('urn:miot-spec-v2:property:air-quality:0000001C', $this->property->getType());
}
public function testGetValueRange()
{
$urn = 'urn:miot-spec-v2:property:keep-warm-temperature:0000002E';
$this->property = new PropertySpecification($urn);
$this->assertEquals([
0,
100,
1,
], $this->property->getValueRange());
}
public function testGetFormat()
{
$urn = 'urn:miot-spec-v2:property:air-quality:0000001C';
$this->property = new PropertySpecification($urn);
$this->assertEquals('uint8', $this->property->getFormat());
}
public function testGetAccess()
{
$urn = 'urn:miot-spec-v2:property:air-quality:0000001C';
$this->property = new PropertySpecification($urn);
$this->assertEquals([
'read',
'notify',
], $this->property->getAccess());
}
public function testGetValueList()
{
$urn = 'urn:miot-spec-v2:property:air-quality:0000001C';
$this->property = new PropertySpecification($urn);
$this->assertEquals([
[
'value' => 1,
'description' => 'Excellent',
],
[
'value' => 2,
'description' => 'Fine',
],
], $this->property->getValueList());
}
public function testGetUnit()
{
$urn = 'urn:miot-spec-v2:property:keep-warm-temperature:0000002E';
$this->property = new PropertySpecification($urn);
$this->assertEquals('celsius', $this->property->getUnit());
}
}