/** * Returns the composer manifest constraints ("require", "suggest" or "conflict") from the given package meta data * * @param string $constraintType one of the MetaDataInterface::CONSTRAINT_TYPE_* constants * @param MetaData $packageMetaData * @return array in the format array('<ComposerPackageName>' => '*', ...) * @deprecated This will be removed with Flow 4.0 together with the MetaData model */ protected function getComposerManifestConstraints($constraintType, MetaData $packageMetaData) { $composerManifestConstraints = []; $constraints = $packageMetaData->getConstraintsByType($constraintType); foreach ($constraints as $constraint) { if (!$constraint instanceof MetaData\PackageConstraint) { continue; } $composerName = isset($this->packageStatesConfiguration['packages'][$constraint->getValue()]['composerName']) ? $this->packageStatesConfiguration['packages'][$constraint->getValue()]['composerName'] : ComposerUtility::getComposerPackageNameFromPackageKey($constraint->getValue()); $composerManifestConstraints[$composerName] = '*'; } return $composerManifestConstraints; }
/** * @test */ public function packageStatesConfigurationContainsRelativePaths() { $packageKeys = array('RobertLemke.Flow.NothingElse' . md5(uniqid(mt_rand(), true)), 'TYPO3.Flow' . md5(uniqid(mt_rand(), true)), 'TYPO3.YetAnotherTestPackage' . md5(uniqid(mt_rand(), true))); foreach ($packageKeys as $packageKey) { $packagePath = 'vfs://Test/Packages/Application/' . $packageKey . '/'; mkdir($packagePath, 0770, true); mkdir($packagePath . 'Classes'); ComposerUtility::writeComposerManifest($packagePath, $packageKey, ['type' => 'flow-test', 'autoload' => []]); } $packageManager = $this->getAccessibleMock(PackageManager::class, array('updateShortcuts', 'emitPackageStatesUpdated'), array(), '', false); $packageManager->_set('packagesBasePath', 'vfs://Test/Packages/'); $packageManager->_set('packageStatesPathAndFilename', 'vfs://Test/Configuration/PackageStates.php'); $packageFactory = new \TYPO3\Flow\Package\PackageFactory($packageManager); $this->inject($packageManager, 'packageFactory', $packageFactory); $packageManager->_set('packages', array()); $actualPackageStatesConfiguration = $packageManager->rescanPackages(); $expectedPackageStatesConfiguration = array(); foreach ($packageKeys as $packageKey) { $composerName = ComposerUtility::getComposerPackageNameFromPackageKey($packageKey); $expectedPackageStatesConfiguration[$composerName] = array('state' => 'active', 'packagePath' => 'Application/' . $packageKey . '/', 'composerName' => $composerName, 'packageClassInformation' => array(), 'packageKey' => $packageKey, 'autoloadConfiguration' => []); } $this->assertEquals($expectedPackageStatesConfiguration, $actualPackageStatesConfiguration['packages']); }