protected function setUp() { parent::setUp(); $this->fixturesPath = __DIR__ . '/Fixtures/'; $testTargetDir = 'testDir'; vfsStream::setup($testTargetDir); $dummyExtensionDir = vfsStream::url($testTargetDir) . '/'; $settings = \EBT\ExtensionBuilder\Utility\SpycYAMLParser::YAMLLoadString(file_get_contents($this->fixturesPath . 'Settings/settings1.yaml')); $this->extension = $this->getMock(\EBT\ExtensionBuilder\Domain\Model\Extension::class, array('getExtensionDir')); $this->extension->setVendorName('EBT'); $this->extension->setExtensionKey('dummy'); $this->extension->expects(self::any())->method('getExtensionDir')->will(self::returnValue($dummyExtensionDir)); if (is_dir($dummyExtensionDir)) { GeneralUtility::mkdir($dummyExtensionDir, true); } $this->extension->setSettings($settings); $this->codeTemplateRootPath = PATH_typo3conf . 'ext/extension_builder/Resources/Private/CodeTemplates/Extbase/'; $this->modelClassTemplatePath = $this->codeTemplateRootPath . 'Classes/Domain/Model/Model.phpt'; }
protected function setUp($settingFile = '') { if (!class_exists('PHPParser_Parser')) { \EBT\ExtensionBuilder\Parser\AutoLoader::register(); } if (!class_exists('PHPParser_Parser')) { die('Parser not found!!'); } $this->fixturesPath = PATH_typo3conf . 'ext/extension_builder/Tests/Fixtures/'; $this->extension = $this->getMock('EBT\\ExtensionBuilder\\Domain\\Model\\Extension', array('getExtensionDir')); $extensionKey = 'dummy'; vfsStream::setup('testDir'); $dummyExtensionDir = vfsStream::url('testDir') . '/'; $this->extension->setVendorName('EBT'); $this->extension->setExtensionKey($extensionKey); $this->extension->expects($this->any())->method('getExtensionDir')->will($this->returnValue($dummyExtensionDir)); if (is_dir($dummyExtensionDir)) { GeneralUtility::mkdir($dummyExtensionDir, TRUE); } $yamlParser = new \EBT\ExtensionBuilder\Utility\SpycYAMLParser(); $settings = $yamlParser->YAMLLoadString(file_get_contents($this->fixturesPath . 'Settings/settings1.yaml')); $this->extension->setSettings($settings); $configurationManager = GeneralUtility::makeInstance('EBT\\ExtensionBuilder\\Configuration\\ConfigurationManager'); $this->roundTripService = $this->getMock($this->buildAccessibleProxy('EBT\\ExtensionBuilder\\Service\\RoundTrip'), array('dummy')); $this->classBuilder = GeneralUtility::makeInstance('EBT\\ExtensionBuilder\\Service\\ClassBuilder'); $this->classBuilder->injectConfigurationManager($configurationManager); $this->roundTripService->injectClassBuilder($this->classBuilder); $this->roundTripService->injectConfigurationManager($configurationManager); $this->templateParser = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Fluid\\Core\\Parser\\TemplateParser'), array('dummy')); $this->fileGenerator = $this->getMock($this->buildAccessibleProxy('EBT\\ExtensionBuilder\\Service\\FileGenerator'), array('dummy')); $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $this->objectManager = clone $objectManager; $this->parserService = new \EBT\ExtensionBuilder\Service\Parser(new \PHPParser_Lexer()); $this->printerService = new \EBT\ExtensionBuilder\Service\Printer(); $this->printerService->injectNodeFactory(new \EBT\ExtensionBuilder\Parser\NodeFactory()); $localizationService = $this->objectManager->get('EBT\\ExtensionBuilder\\Service\\LocalizationService'); $this->fileGenerator->injectObjectManager($this->objectManager); $this->fileGenerator->injectPrinterService($this->printerService); $this->fileGenerator->injectLocalizationService($localizationService); $this->roundTripService->injectParserService($this->parserService); $this->roundTripService->initialize($this->extension); $this->classBuilder->injectRoundtripService($this->roundTripService); $this->classBuilder->injectParserService($this->parserService); $this->classBuilder->injectPrinterService($this->printerService); $this->classBuilder->injectClassFactory(new \EBT\ExtensionBuilder\Parser\ClassFactory()); $this->classBuilder->initialize($this->fileGenerator, $this->extension, TRUE); $this->fileGenerator->injectClassBuilder($this->classBuilder); $this->codeTemplateRootPath = PATH_typo3conf . 'ext/extension_builder/Resources/Private/CodeTemplates/Extbase/'; $this->modelClassTemplatePath = $this->codeTemplateRootPath . 'Classes/Domain/Model/Model.phpt'; $this->fileGenerator->setSettings(array('codeTemplateRootPath' => $this->codeTemplateRootPath, 'extConf' => array('enableRoundtrip' => '1'))); $this->fileGenerator->_set('codeTemplateRootPath', PATH_typo3conf . 'ext/extension_builder/Resources/Private/CodeTemplates/Extbase/'); $this->fileGenerator->_set('enableRoundtrip', true); $this->fileGenerator->_set('extension', $this->extension); }
public function setUp() { parent::setUp(); $this->objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); if (!class_exists('PhpParser\\Parser')) { throw new UnknownClassException('PhpParser not found!!'); } $this->fixturesPath = __DIR__ . '/Fixtures/'; $testTargetDir = 'testDir'; vfsStream::setup($testTargetDir); $dummyExtensionDir = vfsStream::url($testTargetDir) . '/'; $yamlParser = new \EBT\ExtensionBuilder\Utility\SpycYAMLParser(); $settings = $yamlParser->YAMLLoadString(file_get_contents($this->fixturesPath . 'Settings/settings1.yaml')); $this->extension = $this->getMock(\EBT\ExtensionBuilder\Domain\Model\Extension::class, array('getExtensionDir')); $this->extension->setVendorName('EBT'); $this->extension->setExtensionKey('dummy'); $this->extension->expects($this->any())->method('getExtensionDir')->will($this->returnValue($dummyExtensionDir)); if (is_dir($dummyExtensionDir)) { GeneralUtility::mkdir($dummyExtensionDir, TRUE); } $this->extension->setSettings($settings); // get instances to inject in Mocks $configurationManager = $this->objectManager->get(\EBT\ExtensionBuilder\Configuration\ConfigurationManager::class); $this->parserService = new \EBT\ExtensionBuilder\Service\Parser(new \PhpParser\Lexer()); $this->printerService = $this->objectManager->get(\EBT\ExtensionBuilder\Service\Printer::class); $localizationService = $this->objectManager->get(\EBT\ExtensionBuilder\Service\LocalizationService::class); $this->classBuilder = $this->objectManager->get(\EBT\ExtensionBuilder\Service\ClassBuilder::class); $this->classBuilder->initialize($this->extension); $this->roundTripService = $this->getAccessibleMock(\EBT\ExtensionBuilder\Service\RoundTrip::class, array('dummy')); $this->inject($this->roundTripService, 'configurationManager', $configurationManager); $this->inject($this->roundTripService, 'parserService', $this->parserService); $this->roundTripService->initialize($this->extension); $this->fileGenerator = $this->getAccessibleMock(\EBT\ExtensionBuilder\Service\FileGenerator::class, array('dummy')); $this->inject($this->fileGenerator, 'objectManager', $this->objectManager); $this->inject($this->fileGenerator, 'printerService', $this->printerService); $this->inject($this->fileGenerator, 'localizationService', $localizationService); $this->inject($this->fileGenerator, 'classBuilder', $this->classBuilder); $this->inject($this->fileGenerator, 'roundTripService', $this->roundTripService); $this->codeTemplateRootPath = PATH_typo3conf . 'ext/extension_builder/Resources/Private/CodeTemplates/Extbase/'; $this->modelClassTemplatePath = $this->codeTemplateRootPath . 'Classes/Domain/Model/Model.phpt'; $this->fileGenerator->setSettings(array('codeTemplateRootPath' => $this->codeTemplateRootPath, 'extConf' => array('enableRoundtrip' => '1'))); $this->fileGenerator->_set('codeTemplateRootPath', __DIR__ . '/../Resources/Private/CodeTemplates/Extbase/'); $this->fileGenerator->_set('enableRoundtrip', true); $this->fileGenerator->_set('extension', $this->extension); }
/** * @param \EBT\ExtensionBuilder\Domain\Model\Extension $extension * @param array $propertyConfiguration * @return void */ protected function setExtensionProperties(&$extension, $propertyConfiguration) { // name $extension->setName(trim($propertyConfiguration['name'])); // description $extension->setDescription($propertyConfiguration['description']); // extensionKey $extension->setExtensionKey(trim($propertyConfiguration['extensionKey'])); // vendorName $extension->setVendorName(trim($propertyConfiguration['vendorName'])); if (!empty($propertyConfiguration['emConf']['sourceLanguage'])) { $extension->setSourceLanguage($propertyConfiguration['emConf']['sourceLanguage']); } if ($propertyConfiguration['emConf']['disableVersioning']) { $extension->setSupportVersioning(false); } if ($propertyConfiguration['emConf']['disableLocalization']) { $extension->setSupportLocalization(false); } if (!empty($propertyConfiguration['emConf']['skipGenerateDocumentationTemplate'])) { $extension->setGenerateDocumentationTemplate(false); } // various extension properties $extension->setVersion($propertyConfiguration['emConf']['version']); if (!empty($propertyConfiguration['emConf']['dependsOn'])) { $dependencies = array(); $lines = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $propertyConfiguration['emConf']['dependsOn']); foreach ($lines as $line) { if (strpos($line, '=>')) { list($extensionKey, $version) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('=>', $line); $dependencies[$extensionKey] = $version; } } $extension->setDependencies($dependencies); } if (!empty($propertyConfiguration['emConf']['targetVersion'])) { $extension->setTargetVersion(floatval($propertyConfiguration['emConf']['targetVersion'])); } if (!empty($propertyConfiguration['emConf']['custom_category'])) { $category = $propertyConfiguration['emConf']['custom_category']; } else { $category = $propertyConfiguration['emConf']['category']; } $extension->setCategory($category); // state $state = 0; switch ($propertyConfiguration['emConf']['state']) { case 'alpha': $state = \EBT\ExtensionBuilder\Domain\Model\Extension::STATE_ALPHA; break; case 'beta': $state = \EBT\ExtensionBuilder\Domain\Model\Extension::STATE_BETA; break; case 'stable': $state = \EBT\ExtensionBuilder\Domain\Model\Extension::STATE_STABLE; break; case 'experimental': $state = \EBT\ExtensionBuilder\Domain\Model\Extension::STATE_EXPERIMENTAL; break; case 'test': $state = \EBT\ExtensionBuilder\Domain\Model\Extension::STATE_TEST; break; } $extension->setState($state); if (!empty($propertyConfiguration['originalExtensionKey'])) { // handle renaming of extensions // original extensionKey $extension->setOriginalExtensionKey($propertyConfiguration['originalExtensionKey']); \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Extension setOriginalExtensionKey:' . $extension->getOriginalExtensionKey(), 'extbase', 0, $propertyConfiguration); } if (!empty($propertyConfiguration['originalExtensionKey']) && $extension->getOriginalExtensionKey() != $extension->getExtensionKey()) { $settings = $this->configurationManager->getExtensionSettings($extension->getOriginalExtensionKey()); // if an extension was renamed, a new extension dir is created and we // have to copy the old settings file to the new extension dir copy($this->configurationManager->getSettingsFile($extension->getOriginalExtensionKey()), $this->configurationManager->getSettingsFile($extension->getExtensionKey())); } else { $settings = $this->configurationManager->getExtensionSettings($extension->getExtensionKey()); } if (!empty($settings)) { $extension->setSettings($settings); \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Extension settings:' . $extension->getExtensionKey(), 'extbase', 0, $extension->getSettings()); } }