コード例 #1
0
 /**
  * Create a workbench directory for the package.
  *
  * @param  \Illuminate\Workbench\Package $package
  * @param  string $path
  * @return string
  *
  * @throws \InvalidArgumentException
  */
 protected function createDirectory(Package $package, $path)
 {
     $fullPath = $path . '/' . $package->getFullName();
     // If the directory doesn't exist, we will go ahead and create the package
     // directory in the workbench location. We will use this entire package
     // name when creating the directory to avoid any potential conflicts.
     if (!$this->files->isDirectory($fullPath)) {
         $this->files->makeDirectory($fullPath, 0777, true);
         return $fullPath;
     }
     throw new \InvalidArgumentException("Package exists.");
 }
コード例 #2
0
 /**
  * composer.json guard
  */
 public function testWriteComposerGuard()
 {
     $this->creator->writeSupportFiles($this->package, $this->rootdir->url(), true);
     $file = $this->rootdir->url() . '/composer.json';
     $this->assertFileExists($file);
     $composer = json_decode(file_get_contents($file));
     // check package name
     $this->assertEquals($this->package->getFullName(), $composer->name, 'Package name check: ');
     // check authors
     $this->assertCount(1, $composer->authors, 'Authors check: ');
     $this->assertEquals($this->package->author, $composer->authors[0]->name, 'Author name check: ');
     $this->assertEquals($this->package->email, $composer->authors[0]->email, 'Author email check: ');
     // check autoload
     $psr0 = $this->package->vendor . '\\' . $this->package->name;
     $this->objectHasAttribute($psr0, $composer->autoload->{'psr-0'}, 'Autoload - PSR-0 key check: ');
     $this->assertEquals($composer->autoload->{'psr-0'}->{$psr0}, 'src/', 'Autoload - PSR-0 value check: ');
 }