public function givenIConfigureTheProviderFor_ToInjectAnyArgument($class) { $provider = new DefaultProvider($this->factory); $provider->setParameterFilter(function () { return true; }); $this->factory->setProvider($class, $provider); }
public function provide($class, array $args = array()) { $instance = parent::provide($class, array('spec' => $this->spec)); $this->factory->setSingleton($instance, $class); $this->providedFixtures[] = $instance; return $instance; }
public function provide($className, array $constructorArgs = []) { $callConstructor = $constructorArgs != self::$NO_CONSTRUCTOR; $mockClassName = $this->makeMockClassName($className, $callConstructor); if (!class_exists($mockClassName)) { $generator = new MockGenerator(); $code = $generator->generateMock($className, $mockClassName, $callConstructor); eval($code); } if (!$callConstructor) { return $this->injector->injectConstructor($mockClassName, $constructorArgs, function () { return false; }); } return parent::provide($mockClassName, $constructorArgs); }
private function givenOnlyPropertiesWithTheAnnotation_ShouldBeInjected($annotation) { $this->provider = new DefaultProvider($this->fix->factory); $this->fix->factory->setProvider('StdClass', $this->provider); $this->provider->setPropertyFilter(function (\ReflectionProperty $property) use($annotation) { return strpos($property->getDocComment(), $annotation) !== false; }); }