public function testObjectStateToLegacy()
{
$this->insertDatabaseFixture(__DIR__ . '/../../../../../Repository/Tests/Service/Integration/Legacy/_fixtures/clean_ezdemo_47_dump.php');
$converter = $this->getLimitationConverter();
$policy = new Policy();
$policy->module = 'content';
$policy->function = 'read';
// #1 Test wildcard
$policy->limitations = array(Limitation::STATE => '*');
$converter->toLegacy($policy);
$this->assertEquals(array(ObjectStateLimitationHandler::STATE_GROUP . 'ez_lock' => '*'), $policy->limitations, 'Expected State limitation to be transformed into StateGroup_ limitations');
// #2 Test valid state values
$policy->limitations = array(Limitation::STATE => array(1, 2));
$converter->toLegacy($policy);
$this->assertEquals(array(ObjectStateLimitationHandler::STATE_GROUP . 'ez_lock' => array(1, 2)), $policy->limitations, 'Expected State limitation to be transformed into StateGroup_ limitations');
// #3 Test invalid state values (the invalid values are just ignored as validation is done on higher level)
$policy->limitations = array(Limitation::STATE => array(1, 2, 3, 4));
$converter->toLegacy($policy);
$this->assertEquals(array(ObjectStateLimitationHandler::STATE_GROUP . 'ez_lock' => array(1, 2)), $policy->limitations, 'Expected State limitation to be transformed into StateGroup_ limitations');
}