/** * @test */ public function getNamespaceReturnsThePhpNamespaceCorrespondingToThePackageKey() { $packagePath = 'vfs://Packages/Application/Acme.MyPackage/'; mkdir($packagePath, 0777, TRUE); file_put_contents($packagePath . 'composer.json', '{"name": "acme/mypackage", "type": "flow-test"}'); $package = new FlowPackage($this->getMock('TYPO3\\CMS\\Core\\Package\\PackageManager'), 'Acme.MyPackage', $packagePath); $this->assertEquals('Acme\\MyPackage', $package->getNamespace()); }
/** * @test */ public function getNamespaceReturnsThePhpNamespaceCorrespondingToThePackageKeyIfNoPsrMappingIsDefined() { $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->mockPackageManager, 'Acme.MyPackage', $packagePath); $this->assertEquals('Acme\\MyPackage', $package->getNamespace()); }
/** * @test */ public function getNamespaceReturnsTheFirstPsr4NamespaceIfMultiplePsr4MappingsAreDefined() { $packagePath = 'vfs://Packages/Application/Acme.MyPackage2341/'; mkdir($packagePath, 0777, true); $rawComposerManifest = '{"name": "acme/mypackage2341", "type": "flow-test", "autoload": { "psr-4": { "Namespace2": "path2", "Namespace3": "path3" } }}'; $composerManifest = json_decode($rawComposerManifest, true); file_put_contents($packagePath . 'composer.json', $rawComposerManifest); $package = new Package('Acme.MyPackage2341', 'acme/mypackage2341', $packagePath, $composerManifest['autoload']); $this->assertEquals('Namespace2', $package->getNamespace()); }