/**
  * Write a simple model class for a non aggregate root domain obbject
  * @test
  */
 function relatedMethodsReflectRenamingAProperty()
 {
     $modelName = 'model7';
     $this->generateInitialModelClassFile($modelName);
     // create an "old" domainObject
     $domainObject = $this->buildDomainObject($modelName);
     $this->assertTrue(is_object($domainObject), 'No domain object');
     $property = new Tx_ExtensionBuilder_Domain_Model_DomainObject_StringProperty('prop1');
     $uniqueIdentifier1 = md5(microtime() . 'prop1');
     $property->setUniqueIdentifier($uniqueIdentifier1);
     $domainObject->addProperty($property);
     $uniqueIdentifier2 = md5(microtime() . 'model');
     $domainObject->setUniqueIdentifier($uniqueIdentifier2);
     $this->roundTripService->_set('oldDomainObjects', array($domainObject->getUniqueIdentifier() => $domainObject));
     // create an "old" class object.
     $modelClassObject = $this->classBuilder->generateModelClassObject($domainObject);
     $this->assertTrue(is_object($modelClassObject), 'No class object');
     // Check that the getter/methods exist
     $this->assertTrue($modelClassObject->methodExists('getProp1'));
     $this->assertTrue($modelClassObject->methodExists('setProp1'));
     // set the class object manually, this is usually parsed from an existing class file
     $this->roundTripService->_set('classObject', $modelClassObject);
     // build a new domain object with the same unique identifiers
     $newDomainObject = $this->buildDomainObject('Dummy');
     $property = new Tx_ExtensionBuilder_Domain_Model_DomainObject_BooleanProperty('newProp1Name');
     $property->setUniqueIdentifier($uniqueIdentifier1);
     $property->setRequired(TRUE);
     $newDomainObject->addProperty($property);
     $newDomainObject->setUniqueIdentifier($uniqueIdentifier2);
     // now the slass object should be updated
     $this->roundTripService->_call('updateModelClassProperties', $domainObject, $newDomainObject);
     $classObject = $this->roundTripService->_get('classObject');
     $this->assertTrue($classObject->methodExists('getNewProp1Name'));
     $this->assertTrue($classObject->methodExists('setNewProp1Name'));
 }
 /**
  *
  *
  */
 public function classBuilderGeneratesIsMethodForBooleanProperty()
 {
     $domainObject = $this->buildDomainObject($this->modelName, true, true);
     $property = new Tx_ExtensionBuilder_Domain_Model_DomainObject_BooleanProperty('blue');
     $property->setRequired(TRUE);
     $domainObject->addProperty($property);
     $modelClassObject = $this->classBuilder->generateModelClassObject($domainObject);
     $this->assertTrue($modelClassObject->methodExists('isBlue'), 'No method: isBlue');
 }
 /**
  * Generate the appropriate code for a simple model class
  * for a non aggregate root domain object with one boolean property
  *
  * @test
  */
 function generateCodeForModelClassWithBooleanProperty()
 {
     $modelName = 'ModelCgt1';
     $propertyName = 'blue';
     $domainObject = $this->buildDomainObject($modelName);
     $property = new Tx_ExtensionBuilder_Domain_Model_DomainObject_BooleanProperty();
     $property->setName($propertyName);
     $property->setRequired(TRUE);
     $domainObject->addProperty($property);
     $classFileContent = $this->codeGenerator->generateDomainObjectCode($domainObject, TRUE);
     $this->assertRegExp("/.*class Tx_Dummy_Domain_Model_ModelCgt1.*/", $classFileContent, 'Class declaration was not generated');
     $this->assertRegExp('/.*protected \\$blue.*/', $classFileContent, 'boolean property was not generated');
     $this->assertRegExp('/.*\\* \\@var boolean.*/', $classFileContent, 'var tag for boolean property was not generated');
     $this->assertRegExp('/.*\\* \\@validate NotEmpty.*/', $classFileContent, 'validate tag for required property was not generated');
     $this->assertRegExp('/.*public function getBlue\\(\\).*/', $classFileContent, 'Getter for boolean property was not generated');
     $this->assertRegExp('/.*public function setBlue\\(\\$blue\\).*/', $classFileContent, 'Setter for boolean property was not generated');
     $this->assertRegExp('/.*public function isBlue\\(\\).*/', $classFileContent, 'is method for boolean property was not generated');
 }
 /**
  * This test is too generic, since it creates the required classes
  * with a whole codeGenerator->build call
  *
  * 
  * @test
  */
 function writeAggregateRootClassesFromDomainObject()
 {
     $domainObject = $this->buildDomainObject('ModelCgt7', true, true);
     $property = new Tx_ExtensionBuilder_Domain_Model_DomainObject_BooleanProperty('blue');
     $property->setRequired(TRUE);
     $domainObject->addProperty($property);
     $this->extension->addDomainObject($domainObject);
     $this->codeGenerator->build($this->extension);
     $this->assertFileExists($this->extension->getExtensionDir() . 'Classes/Domain/Model/' . $domainObject->getName() . '.php');
     $this->assertFileExists($this->extension->getExtensionDir() . 'Classes/Domain/Repository/' . $domainObject->getName() . 'Repository.php');
     $this->assertFileExists($this->extension->getExtensionDir() . 'Classes/Controller/' . $domainObject->getName() . 'Controller.php');
 }