Ejemplo n.º 1
0
 /**
  * Test the main conversion values.
  *
  * @return void
  */
 public function testFull()
 {
     $package = new RootPackage('test/package', '0.1.1.1', '0.1.1.1');
     $package->setType('project');
     $package->setLicense(['LGPL-3']);
     $package->setType('project');
     $package->setReleaseDate($time = new \DateTime());
     $package->setDescription('Descriptiontext');
     $package->setKeywords(['keyword1', 'keyword1']);
     $package->setHomepage('https://example.org');
     $package->setAuthors([['name' => 'A. Coder', 'email' => '*****@*****.**'], ['name' => 'A. Nother. Coder', 'email' => '*****@*****.**']]);
     $package->setSupport(['issues' => 'https://example.org/issue-tracker']);
     $package->setAbandoned('another/package');
     $upgrade = new CompletePackage('test/package', '1.1.1.1', '1.1.1.1');
     $upgrade->setReleaseDate($upgradeTime = new \DateTime('+7 day'));
     $converted = PackageConverter::create($package)->convertPackageToArray($package, $upgrade);
     $this->assertEquals(['name', 'version', 'constraint', 'type', 'locked', 'time', 'upgrade_version', 'upgrade_time', 'description', 'license', 'keywords', 'homepage', 'authors', 'support', 'abandoned', 'replacement'], $converted->getEntries('/'));
     $this->assertEquals($package->getName(), $converted->get('name'));
     $this->assertEquals($package->getPrettyVersion(), $converted->get('version'));
     $this->assertNull($converted->get('constraint'));
     $this->assertEquals($package->getType(), $converted->get('type'));
     $this->assertFalse($converted->get('locked'));
     $this->assertEquals($package->getLicense(), $converted->get('license'));
     $this->assertEquals($time->format(\DateTime::ATOM), $converted->get('time'));
     $this->assertEquals('1.1.1.1', $converted->get('upgrade_version'));
     $this->assertEquals($upgradeTime->format(\DateTime::ATOM), $converted->get('upgrade_time'));
     $this->assertEquals($package->getDescription(), $converted->get('description'));
     $this->assertEquals($package->getKeywords(), $converted->get('keywords'));
     $this->assertEquals($package->getHomepage(), $converted->get('homepage'));
     $this->assertEquals($package->getAuthors(), $converted->get('authors'));
     $this->assertEquals($package->getSupport(), $converted->get('support'));
     $this->assertEquals($package->isAbandoned(), $converted->get('abandoned'));
     $this->assertEquals($package->getReplacementPackage(), $converted->get('replacement'));
 }