mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
98 lines
2.4 KiB
PHP
98 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace Alchemy\Tests\Phrasea\Border\Attribute;
|
|
|
|
use Alchemy\Phrasea\Border\Attribute\Status;
|
|
use Alchemy\Phrasea\Border\Attribute\AttributeInterface;
|
|
|
|
/**
|
|
* @group functional
|
|
* @group legacy
|
|
*/
|
|
class StatusTest extends \PhraseanetTestCase
|
|
{
|
|
/**
|
|
* @var Status
|
|
*/
|
|
protected $object;
|
|
|
|
/**
|
|
* @covers Alchemy\Phrasea\Border\Attribute\Attribute
|
|
* @covers Alchemy\Phrasea\Border\Attribute\Status::__construct
|
|
* @dataProvider getValidStatuses
|
|
*/
|
|
public function testConstructor($status, $binaryString)
|
|
{
|
|
$attr = new Status(self::$DI['app'], $status);
|
|
$this->assertEquals($binaryString, $attr->getValue());
|
|
}
|
|
|
|
public function getValidStatuses()
|
|
{
|
|
return [
|
|
[123, '1111011'],
|
|
['123', '1111011'],
|
|
['0b1111011', '1111011'],
|
|
['1111011', '1111011'],
|
|
['0x7b', '1111011'],
|
|
['7b', '1111011'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @covers Alchemy\Phrasea\Border\Attribute\Status::__construct
|
|
* @dataProvider getInvalidStatuses
|
|
* @expectedException \InvalidArgumentException
|
|
*/
|
|
public function testInvalidConstruction($status)
|
|
{
|
|
new Status(self::$DI['app'], $status);
|
|
}
|
|
|
|
public function getInvalidStatuses()
|
|
{
|
|
return [
|
|
['0b00z2'],
|
|
['0x00g2'],
|
|
['g2'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @covers Alchemy\Phrasea\Border\Attribute\Status::getName
|
|
*/
|
|
public function testGetName()
|
|
{
|
|
$status = new Status(self::$DI['app'], 123);
|
|
$this->assertEquals(AttributeInterface::NAME_STATUS, $status->getName());
|
|
}
|
|
|
|
/**
|
|
* @covers Alchemy\Phrasea\Border\Attribute\Status::getValue
|
|
*/
|
|
public function testGetValue()
|
|
{
|
|
$status = new Status(self::$DI['app'], 123);
|
|
$this->assertEquals('1111011', $status->getValue());
|
|
}
|
|
|
|
/**
|
|
* @covers Alchemy\Phrasea\Border\Attribute\Status::asString
|
|
*/
|
|
public function testAsString()
|
|
{
|
|
$status = new Status(self::$DI['app'], 123);
|
|
$this->assertEquals('1111011', $status->asString());
|
|
}
|
|
|
|
/**
|
|
* @covers Alchemy\Phrasea\Border\Attribute\Status::loadFromString
|
|
*/
|
|
public function testLoadFromString()
|
|
{
|
|
$status = new Status(self::$DI['app'], 12345);
|
|
|
|
$this->assertEquals($status, Status::loadFromString(self::$DI['app'], $status->asString()));
|
|
}
|
|
}
|