예제 #1
0
 /**
  * Execute the command.
  *
  * @return void
  */
 protected function fire()
 {
     $appDir = $this->argument('dir');
     //exit is non-absolute path to app directory was given
     if (!preg_match(Path::ABSOLUTE_PATTERN, $appDir)) {
         $this->comment("Error", "App directory must be an absolute path", true);
         exit;
     }
     //install a fresh Laravel app
     (new Laravel($appDir, new ProcessBuilder(), $this))->install();
     //get the template
     $template = new TemplateReader($this->argument('template'), new Filesystem(), $this);
     //process structural portions of the config
     $structure = new Structure($appDir, $template->getConfigSection(TemplateReader::STRUCTURE), new Filesystem(), $this);
     $structure->copy();
     $structure->move();
     $structure->delete();
     $structure->touch();
     $structure->mkdirs();
     //process composer portions of the config
     $composer = new Composer($appDir, $template->getConfigSection(TemplateReader::COMPOSER), new Filesystem(), $this);
     $composer->requirePackages();
     $composer->requireDevPackages();
     $composer->autoloadClassmap();
     $composer->autoloadPsr0();
     $composer->autoloadPsr4();
     $composer->writeComposerJson();
 }
예제 #2
0
 public function testRequireDevPackagesWithExistingReqDev()
 {
     $appDir = '/path/to/app';
     $composerPath = $appDir . DIRECTORY_SEPARATOR . 'composer.json';
     $require = $this->getConfig()['require-dev'];
     $jArray = json_decode($this->getComposerJson(), true);
     $jArray['require-dev'] = ["mockery/mockery" => "dev-master@dev"];
     $json = json_encode($jArray, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
     $mFS = m::mock('Illuminate\\Filesystem\\Filesystem');
     $mFS->shouldReceive('get')->once()->with($composerPath)->andReturn($json);
     $mCmd = m::mock('Console\\BuildCommand');
     $mCmd->shouldIgnoreMissing();
     foreach ($require as $package) {
         $pkg = $package['package'];
         $ver = $package['version'];
         $mCmd->shouldReceive('comment')->once()->with("Composer", "Require Dev: {$pkg} {$ver}");
     }
     //test on a config with NO require-dev
     $composer = new Composer($appDir, $this->getConfig(), $mFS, $mCmd);
     $composer->requireDevPackages();
     $expectedPackages = ['mockery/mockery' => 'dev-master@dev', 'fzaninotto/faker' => '1.3.*', 'squizlabs/php_codesniffer' => '*'];
     $this->assertEquals($expectedPackages, $composer->getComposerArray()[Composer::REQUIRE_DEV_DEPENDENCIES]);
 }