public function testGetTemplateForFactory() { FactoryRegistry::registerFactories(['Fixture\\Carpenter\\BasicUserFactory']); $template = FactoryRegistry::getTemplateForFactory('BasicUser'); $this->assertInstanceOf('\\Carpenter\\Template', $template); $this->assertAttributeInstanceOf('\\Fixture\\Carpenter\\BasicUserFactory', 'factory', $template); }
/** * Build a new fixture without persisting it * * @param string $factory The name of the factory to build * @param string $modifiers.. One or more modifiers to apply to the fixture * @param array $overrides A key/value set of properties to override * @return mixed The fixture specified by the factory * @throws Carpenter\FactoryNotFoundException */ public static function build() { $arguments = func_get_args(); $modifiers = []; $overrides = []; $factory = array_shift($arguments); if (count($arguments) > 1) { $overrides = array_pop($arguments); $modifiers = $arguments; } elseif (count($arguments) > 0 && is_array($arguments[0])) { $overrides = $arguments; } elseif (count($arguments) > 0 && is_string($arguments[0])) { $modifiers = $arguments; } $template = FactoryRegistry::getTemplateForFactory($factory); $resolved = $template->resolve($modifiers, $overrides); return $template->apply(Configuration::$adapter, $resolved); }