コード例 #1
0
 private function renameNonRootPackage(Package $package, $newName)
 {
     $previousInstallInfo = $package->getInstallInfo();
     $installInfo = new InstallInfo($newName, $previousInstallInfo->getInstallPath());
     $installInfo->setInstallerName($previousInstallInfo->getInstallerName());
     foreach ($previousInstallInfo->getDisabledBindingUuids() as $uuid) {
         $installInfo->addDisabledBindingUuid($uuid);
     }
     $this->rootPackageFile->removeInstallInfo($package->getName());
     $this->rootPackageFile->addInstallInfo($installInfo);
     try {
         $this->packageFileStorage->saveRootPackageFile($this->rootPackageFile);
     } catch (Exception $e) {
         $this->rootPackageFile->removeInstallInfo($newName);
         $this->rootPackageFile->addInstallInfo($previousInstallInfo);
         throw $e;
     }
     $this->packages->remove($package->getName());
     $this->packages->add(new Package($package->getPackageFile(), $package->getInstallPath(), $installInfo, $package->getLoadErrors()));
 }
コード例 #2
0
 public function testHasInstallInfos()
 {
     $this->assertFalse($this->packageFile->hasInstallInfos());
     $this->packageFile->addInstallInfo(new InstallInfo('vendor/package', '/path/to/package'));
     $this->assertTrue($this->packageFile->hasInstallInfos());
 }
コード例 #3
0
 public function testWriteRootPackageFileSortsPackageBindings()
 {
     $installInfo = new InstallInfo('vendor/package1', '/path/to/package1');
     $installInfo->addEnabledBindingUuid(Uuid::fromString('c54e5668-2b36-43f4-a32c-2d175092b77d'));
     $installInfo->addEnabledBindingUuid(Uuid::fromString('a54e5668-2b36-43f4-a32c-2d175092b77d'));
     $installInfo->addEnabledBindingUuid(Uuid::fromString('b54e5668-2b36-43f4-a32c-2d175092b77d'));
     $installInfo->addDisabledBindingUuid(Uuid::fromString('6d02ee67-d845-4789-a9c1-8301351c6f5a'));
     $installInfo->addDisabledBindingUuid(Uuid::fromString('4d02ee67-d845-4789-a9c1-8301351c6f5a'));
     $installInfo->addDisabledBindingUuid(Uuid::fromString('5d02ee67-d845-4789-a9c1-8301351c6f5a'));
     $packageFile = new RootPackageFile();
     $packageFile->addInstallInfo($installInfo);
     $this->writer->writePackageFile($packageFile, $this->tempFile);
     $this->assertFileExists($this->tempFile);
     $this->assertJsonFileEquals(__DIR__ . '/Fixtures/json/sorted-package-bindings.json', $this->tempFile);
 }
コード例 #4
0
    public function testSerializeRootPackageFileSortsPackageBindings()
    {
        $installInfo = new InstallInfo('vendor/package1', '/path/to/package1');
        $installInfo->addDisabledBindingUuid(Uuid::fromString('6d02ee67-d845-4789-a9c1-8301351c6f5a'));
        $installInfo->addDisabledBindingUuid(Uuid::fromString('4d02ee67-d845-4789-a9c1-8301351c6f5a'));
        $installInfo->addDisabledBindingUuid(Uuid::fromString('5d02ee67-d845-4789-a9c1-8301351c6f5a'));
        $packageFile = new RootPackageFile();
        $packageFile->addInstallInfo($installInfo);
        $json = <<<JSON
{
    "version": "1.0",
    "packages": {
        "vendor/package1": {
            "install-path": "/path/to/package1",
            "disabled-bindings": [
                "4d02ee67-d845-4789-a9c1-8301351c6f5a",
                "5d02ee67-d845-4789-a9c1-8301351c6f5a",
                "6d02ee67-d845-4789-a9c1-8301351c6f5a"
            ]
        }
    }
}

JSON;
        $this->assertJsonEquals($json, $this->serializer->serializeRootPackageFile($packageFile));
    }
コード例 #5
0
 private function populateRootConfig(RootPackageFile $packageFile, \stdClass $jsonData)
 {
     if (isset($jsonData->{'override-order'})) {
         $packageFile->setOverrideOrder((array) $jsonData->{'override-order'});
     }
     if (isset($jsonData->plugins)) {
         $packageFile->setPluginClasses($jsonData->plugins);
     }
     if (isset($jsonData->config)) {
         $config = $packageFile->getConfig();
         foreach ($this->objectsToArrays($jsonData->config) as $key => $value) {
             $config->set($key, $value);
         }
     }
     if (isset($jsonData->packages)) {
         foreach ($jsonData->packages as $packageName => $packageData) {
             $installInfo = new InstallInfo($packageName, $packageData->{'install-path'});
             if (isset($packageData->installer)) {
                 $installInfo->setInstallerName($packageData->installer);
             }
             if (isset($packageData->{'enabled-bindings'})) {
                 foreach ($packageData->{'enabled-bindings'} as $uuid) {
                     $installInfo->addEnabledBindingUuid(Uuid::fromString($uuid));
                 }
             }
             if (isset($packageData->{'disabled-bindings'})) {
                 foreach ($packageData->{'disabled-bindings'} as $uuid) {
                     $installInfo->addDisabledBindingUuid(Uuid::fromString($uuid));
                 }
             }
             $packageFile->addInstallInfo($installInfo);
         }
     }
 }