public function testSetupAttributeProperties() { $obj = new Dummy('foo'); $obj->setupAttribute('buzz', A::REQUIRED, A::SINGLE); $this->assertTrue($obj->getAttribute('buzz')->isRequired()); $this->assertFalse($obj->getAttribute('buzz')->isMultiple()); }
/** * Create a dummy object using the template descriptor from the RIPE * metadata service. This can be useful if the package’s attribute * validation rules become outdated and you absolutely need a confomant * RIPE object (and can’t wait for the update). * * @param string $type A RIPE object type * @param array $descriptor A template descriptor. * @return Dummy A dummy object according to the descriptor. */ public static function factory($type, array $descriptor) { $key = null; foreach ($descriptor as $attribute) { if (in_array('PRIMARY_KEY', $attribute['keys'])) { $key = $attribute['name']; break; } } $obj = new Dummy($type, $key); foreach ($descriptor as $attribute) { $required = $attribute['requirement'] === 'MANDATORY'; $multiple = $attribute['cardinality'] === 'MULTIPLE'; $obj->setupAttribute($attribute['name'], $required, $multiple); } return $obj; }