예제 #1
0
 /**
  * @test
  * @dataProvider propertyDefaultTypesProviderTypes
  */
 public function classBuilderGeneratesPropertyDefault($propertyName, $propertyDefaultValue)
 {
     $domainObject = $this->buildDomainObject($this->modelName, true, true);
     $propertyClassName = '\\EBT\\ExtensionBuilder\\Domain\\Model\\DomainObject\\' . ucfirst($propertyName) . 'Property';
     $property = new $propertyClassName($propertyName);
     $domainObject->addProperty($property);
     /** @var \EBT\ExtensionBuilder\Domain\Model\ClassObject\ClassObject $modelClassObject */
     $modelClassObject = $this->classBuilder->generateModelClassFileObject($domainObject, $this->modelClassTemplatePath, false)->getFirstClass();
     $propertyObject = $modelClassObject->getProperty($propertyName);
     self::assertSame($propertyDefaultValue, $propertyObject->getDefault());
 }
예제 #2
0
 /**
  * Generates the code for the domain model class
  * Either from domainObject template or from class partial
  *
  * @param \EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject
  * @param boolean $mergeWithExistingClass
  * @return string
  */
 public function generateDomainObjectCode(\EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject, $mergeWithExistingClass)
 {
     $modelTemplateClassPath = $this->codeTemplateRootPath . 'Classes/Domain/Model/Model.phpt';
     $modelClassFileObject = $this->classBuilder->generateModelClassFileObject($domainObject, $modelTemplateClassPath, $mergeWithExistingClass);
     if ($modelClassFileObject) {
         $this->addLicenseHeader($modelClassFileObject->getFirstClass());
         return $this->printerService->renderFileObject($modelClassFileObject, TRUE);
     } else {
         throw new \Exception('Class file for domain object could not be generated');
     }
 }