setFactoryObjectName() public method

Sets the class name of a factory which is in charge of instantiating this object
public setFactoryObjectName ( string $objectName ) : void
$objectName string Valid object name of a factory
return void
コード例 #1
0
 /**
  * @test
  */
 public function allBasicOptionsAreSetCorrectly()
 {
     $factoryObjectName = 'ConfigurationBuilderTest' . md5(uniqid(mt_rand(), true));
     eval('class ' . $factoryObjectName . ' { public function manufacture() {} } ');
     $configurationArray = [];
     $configurationArray['scope'] = 'prototype';
     $configurationArray['className'] = __CLASS__;
     $configurationArray['factoryObjectName'] = $factoryObjectName;
     $configurationArray['factoryMethodName'] = 'manufacture';
     $configurationArray['lifecycleInitializationMethodName'] = 'initializationMethod';
     $configurationArray['lifecycleShutdownMethodName'] = 'shutdownMethod';
     $configurationArray['autowiring'] = false;
     $objectConfiguration = new Configuration('TestObject', __CLASS__);
     $objectConfiguration->setScope(Configuration::SCOPE_PROTOTYPE);
     $objectConfiguration->setClassName(__CLASS__);
     $objectConfiguration->setFactoryObjectName($factoryObjectName);
     $objectConfiguration->setFactoryMethodName('manufacture');
     $objectConfiguration->setLifecycleInitializationMethodName('initializationMethod');
     $objectConfiguration->setLifecycleShutdownMethodName('shutdownMethod');
     $objectConfiguration->setAutowiring(Configuration::AUTOWIRING_MODE_OFF);
     $configurationBuilder = $this->getAccessibleMock(ConfigurationBuilder::class, ['dummy']);
     $builtObjectConfiguration = $configurationBuilder->_call('parseConfigurationArray', 'TestObject', $configurationArray, __CLASS__);
     $this->assertEquals($objectConfiguration, $builtObjectConfiguration, 'The manually created and the built object configuration don\'t match.');
 }
コード例 #2
0
 /**
  * @test
  */
 public function setFactoryObjectNameAcceptsValidClassNames()
 {
     $this->objectConfiguration->setFactoryObjectName(__CLASS__);
     $this->assertSame(__CLASS__, $this->objectConfiguration->getFactoryObjectName());
 }