/** * Get the directory name from the package's type * * @param CompletePackage $package * * @return string|bool */ protected static function getDirectoryType($package) { switch ($package->getType()) { case "wordpress-muplugin": return 'mu-plugins'; case "wordpress-plugin": return 'plugins'; case "wordpress-theme": return 'themes'; default: return false; } }
/** * Test the conversion of a complete repository. * * @return void */ public function testConvertRepositoryToArrayOnlyRequired() { $repository = new ArrayRepository([$package1 = new CompletePackage('test/dependency1', '1.0.0.0', '1.0.0.0'), $package2 = new CompletePackage('test/non-dependency2', '2.0.0.0', '2.0.0.0')]); $package1->setType('project'); $package1->setLicense(['LGPL-3']); $package2->setType('project'); $package2->setLicense(['GPL-3']); $converter = new PackageConverter($rootPackage = new RootPackage('root/package', 'dev-master', 'dev-master')); $rootPackage->setRequires(['test/dependency1' => new Link('root/package', 'test/dependency1', new Constraint('<', '2.0'))]); $converted = $converter->convertRepositoryToArray($repository, true); $this->assertEquals(['test\\/dependency1'], $converted->getEntries('/')); $this->assertEquals(['test\\/dependency1/name', 'test\\/dependency1/version', 'test\\/dependency1/constraint', 'test\\/dependency1/type', 'test\\/dependency1/locked', 'test\\/dependency1/license', 'test\\/dependency1/abandoned'], $converted->getEntries('/test\\/dependency1')); $this->assertEquals($package1->getName(), $converted->get('test\\/dependency1/name')); $this->assertEquals($package1->getPrettyVersion(), $converted->get('test\\/dependency1/version')); $this->assertEquals($converted->get('test\\/dependency1/constraint'), '< 2.0'); $this->assertEquals($package1->getType(), $converted->get('test\\/dependency1/type')); $this->assertFalse($converted->get('test\\/dependency1/locked')); $this->assertEquals($package1->getLicense(), $converted->get('test\\/dependency1/license')); $this->assertFalse($converted->get('test\\/dependency1/abandoned')); }