/**
  * @test
  */
 public function packageMetaDataContainsPackageType()
 {
     $packagePath = 'vfs://Packages/Application/Acme.MyPackage/';
     mkdir($packagePath, 0777, TRUE);
     file_put_contents($packagePath . 'composer.json', '{"name": "acme/mypackage", "type": "flow-test"}');
     $package = new Package($this->getMock('TYPO3\\Flow\\Package\\PackageManager'), 'Acme.MyPackage', $packagePath, 'Classes');
     $metaData = $package->getPackageMetaData();
     $this->assertEquals('flow-test', $metaData->getPackageType());
 }
 /**
  * Returns the package meta data object of this package.
  *
  * @return \TYPO3\Flow\Package\MetaData
  */
 public function getPackageMetaData()
 {
     if ($this->packageMetaData === NULL) {
         parent::getPackageMetaData();
         $suggestions = $this->getComposerManifest('suggest');
         if ($suggestions !== NULL) {
             foreach ($suggestions as $suggestion => $version) {
                 if ($this->packageRequirementIsComposerPackage($suggestion) === FALSE) {
                     // Skip non-package requirements
                     continue;
                 }
                 $packageKey = $this->packageManager->getPackageKeyFromComposerName($suggestion);
                 $constraint = new \TYPO3\Flow\Package\MetaData\PackageConstraint(\TYPO3\Flow\Package\MetaDataInterface::CONSTRAINT_TYPE_SUGGESTS, $packageKey);
                 $this->packageMetaData->addConstraint($constraint);
             }
         }
     }
     return $this->packageMetaData;
 }
 /**
  * @test
  */
 public function getPackageMetaDataIgnoresUnresolvableConstraints()
 {
     $packagePath = 'vfs://Packages/Application/Acme.MyPackage/';
     mkdir($packagePath, 0777, true);
     file_put_contents($packagePath . 'composer.json', '{"name": "acme/mypackage", "type": "flow-test", "require": { "non/existing/package": "*" }}');
     $mockPackageManager = $this->getMockBuilder(PackageManager::class)->disableOriginalConstructor()->getMock();
     $mockPackageManager->expects($this->once())->method('getPackageKeyFromComposerName')->with('non/existing/package')->will($this->throwException(new InvalidPackageStateException()));
     $package = new Package($mockPackageManager, 'Acme.MyPackage', $packagePath, 'Classes');
     $metaData = $package->getPackageMetaData();
     $packageConstraints = $metaData->getConstraintsByType(MetaDataInterface::CONSTRAINT_TYPE_DEPENDS);
     $this->assertCount(0, $packageConstraints);
 }
 /**
  * @test
  */
 public function packageMetaDataContainsPackageType()
 {
     $packagePath = 'vfs://Packages/Application/Acme.MyPackage/';
     mkdir($packagePath, 0777, true);
     file_put_contents($packagePath . 'composer.json', '{"name": "acme/mypackage", "type": "flow-test"}');
     $package = new Package('Acme.MyPackage', 'acme/mypackage', $packagePath, ['psr-0' => ['acme\\MyPackage' => 'Classes/']]);
     $metaData = $package->getPackageMetaData();
     $this->assertEquals('flow-test', $metaData->getPackageType());
 }