public function testCreateWithParameters()
 {
     $descriptor = new InstallerDescriptor('symlink', self::SYMLINK_CLASS, null, array($param1 = new InstallerParameter('param1'), $param2 = new InstallerParameter('param2')));
     $this->assertSame('symlink', $descriptor->getName());
     $this->assertSame(self::SYMLINK_CLASS, $descriptor->getClassName());
     $this->assertNull($descriptor->getDescription());
     $this->assertSame(array('param1' => $param1, 'param2' => $param2), $descriptor->getParameters());
 }
 /**
  * Returns whether the given parameter values are valid.
  *
  * @param array               $parameterValues The parameter values to
  *                                             validate.
  * @param InstallerDescriptor $descriptor      The installer descriptor to
  *                                             validate the values for.
  *
  * @return ConstraintViolation[] The found violations. If no violations were
  *                               found, an empty array is returned.
  */
 public function validate(array $parameterValues, InstallerDescriptor $descriptor)
 {
     $violations = array();
     foreach ($parameterValues as $name => $value) {
         if (!$descriptor->hasParameter($name)) {
             $violations[] = new ConstraintViolation(ConstraintViolation::NO_SUCH_PARAMETER, $value, $descriptor->getName(), $name);
         }
     }
     foreach ($descriptor->getParameters() as $parameter) {
         if (!isset($parameterValues[$parameter->getName()])) {
             if ($parameter->isRequired()) {
                 $violations[] = new ConstraintViolation(ConstraintViolation::MISSING_PARAMETER, $parameterValues, $descriptor->getName(), $parameter->getName());
             }
         }
     }
     return $violations;
 }
 /**
  * Extracting an object containing the data from an installer descriptor.
  *
  * @param InstallerDescriptor $installer The installer descriptor.
  *
  * @return stdClass
  */
 private function installerToData(InstallerDescriptor $installer)
 {
     $data = (object) array('class' => $installer->getClassName());
     if ($installer->getDescription()) {
         $data->description = $installer->getDescription();
     }
     if ($installer->getParameters()) {
         $data->parameters = $this->parametersToData($installer->getParameters());
     }
     return $data;
 }