Example #1
0
 /**
  * {@inheritDoc}
  */
 public function set(Fixture $fixture, $object, $property, $value)
 {
     foreach ($value as $index => $param) {
         $value[$index] = $this->typeHintChecker->check($object, $property, $param, $index);
     }
     call_user_func_array(array($object, $property), $value);
 }
Example #2
0
 /**
  * {@inheritDoc}
  */
 public function set(Fixture $fixture, $object, $property, $value)
 {
     $method = $this->findAdderMethod($object, $property);
     foreach ($value as $val) {
         $val = $this->typeHintChecker->check($object, $method, $val);
         $object->{$method}($val);
     }
 }
Example #3
0
 /**
  * {@inheritDoc}
  */
 public function set(Fixture $fixture, $object, $property, $value)
 {
     $setter = $this->setterFor($property);
     $value = $this->typeHintChecker->check($object, $setter, $value);
     if (!is_callable(array($object, $setter))) {
         $refl = new \ReflectionMethod($object, $setter);
         $refl->setAccessible(true);
         $refl->invoke($object, $value);
     } else {
         $object->{$setter}($value);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function instantiate(Fixture $fixture)
 {
     $class = $fixture->getClass();
     $constructorMethod = $fixture->getConstructorMethod();
     $constructorArgs = $fixture->getConstructorArgs();
     $reflClass = new \ReflectionClass($class);
     $constructorArgs = $this->processor->process($constructorArgs, array(), $fixture->getValueForCurrent());
     foreach ($constructorArgs as $index => $value) {
         $constructorArgs[$index] = $this->typeHintChecker->check($class, $constructorMethod, $value, $index);
     }
     if ($constructorMethod === '__construct') {
         $instance = $reflClass->newInstanceArgs($constructorArgs);
     } else {
         $instance = forward_static_call_array(array($class, $constructorMethod), $constructorArgs);
         if (!$instance instanceof $class) {
             throw new \UnexpectedValueException("The static constructor '{$constructorMethod}' for object '{$fixture}' returned an object that is not an instance of '{$class}'");
         }
     }
     return $instance;
 }
Example #5
0
 /**
  * public interface to set the ORM interface
  *
  * @param ORMInterface $manager
  */
 public function setORM(ORMInterface $manager)
 {
     $this->manager = $manager;
     $this->typeHintChecker->setORM($manager);
 }
Example #6
0
 /**
  * public interface to set the Persister interface
  *
  * @param PersisterInterface $manager
  */
 public function setPersister(PersisterInterface $manager)
 {
     $this->manager = $manager;
     $this->typeHintChecker->setPersister($manager);
 }