public function testWriteServiceProviderGuard() { $this->creator->writeServiceProvider($this->package, $this->rootdir->url(), true); $file = $this->rootdir->url() . '/src/' . $this->package->vendor . '/' . $this->package->name . '/' . $this->package->name . 'ServiceProvider.php'; $this->assertFileExists($file); $matches = array(); $this->assertTrue(preg_match('/namespace\\s+([^\\s;]+)/', file_get_contents($file), $matches) === 1); $namespace = $matches[1]; $this->assertEquals($this->package->vendor . '\\' . $this->package->name, $namespace); }
/** * create two packages one old fashioned, the other using the new implementation */ private function createPackages() { $config = $this->config->config()->get('workbench::composer'); $this->oldfashioned = Package::emptyInst()->vendorProvider('Vendor')->nameProvider('OldFashioned')->authorsProvider($config['authors']); $this->newpackage = Package::emptyInst()->vendorProvider('Vendor')->nameProvider('NewPackage')->authorsProvider($config['authors'])->licenseProvider($config['license'])->psr0Provider('psr\\root')->namespaceProvider('custom\\namespace'); $creator = new PackageCreator(new Filesystem()); $creator->create($this->oldfashioned, $this->rootdir->url(), true); $creator->create($this->newpackage, $this->rootdir->url(), true); }