Пример #1
0
 private function createFiles($vendor, $name)
 {
     $stubs = $this->container['stubs.path'] . '/extension';
     $vendorParser = NameParser::parseFromCamelCase($vendor);
     $nameParser = NameParser::parseFromCamelCase($name);
     $vendorUcf = ucfirst($vendor);
     $vendorTc = $vendorParser->getAsTitleCase();
     $vendorUCC = $vendorParser->getAsUpperCamelCase();
     $nameUcf = ucfirst($name);
     $nameTc = $nameParser->getAsTitleCase();
     $nameUCC = $nameParser->getAsUpperCamelCase();
     $vendorLc = strtolower($vendor);
     $vendorKc = $vendorParser->getAsKebabCase();
     $nameLc = strtolower($name);
     $nameKc = $nameParser->getAsKebabCase();
     $mapping = [$stubs . '/config/config.yml.dist.stub' => '/config/config.yml.dist', $stubs . '/config/.gitignore.stub' => '/config/.gitignore', $stubs . '/src/ExtensionNameExtension.php.stub' => '/src/' . $nameUCC . 'Extension.php', $stubs . '/templates/.gitignore.stub' => '/templates/.gitignore', $stubs . '/tests/bootstrap.php.stub' => '/tests/bootstrap.php', $stubs . '/tests/ExtensionTest.php.stub' => '/tests/ExtensionTest.php', $stubs . '/web/.gitignore.stub' => '/web/.gitignore', $stubs . '/.gitignore.stub' => '/.gitignore', $stubs . '/.guenther.yml.stub' => '/.guenther.yml', $stubs . '/composer.json.stub' => '/composer.json', $stubs . '/phpunit.xml.dist.stub' => '/phpunit.xml.dist', $stubs . '/README.md.stub' => '/README.md'];
     foreach ($mapping as $stub => $destination) {
         $content = file_get_contents($stub);
         $content = str_replace('{vendorUcf}', $vendorUcf, $content);
         $content = str_replace('{vendorTc}', $vendorTc, $content);
         $content = str_replace('{vendorUCC}', $vendorUCC, $content);
         $content = str_replace('{nameUcf}', $nameUcf, $content);
         $content = str_replace('{nameTc}', $nameTc, $content);
         $content = str_replace('{nameUCC}', $nameUCC, $content);
         $content = str_replace('{vendorLc}', $vendorLc, $content);
         $content = str_replace('{vendorKc}', $vendorKc, $content);
         $content = str_replace('{nameLc}', $nameLc, $content);
         $content = str_replace('{nameKc}', $nameKc, $content);
         $this->container['filesystem']->put($destination, $content);
     }
 }
Пример #2
0
 /** @test */
 public function it_parses_from_kebabcase()
 {
     $parser = NameParser::parseFromKebabCase('foo-bar-baz');
     $this->assertEquals(['foo', 'bar', 'baz'], $parser->getPieces());
     $parser = NameParser::parseFromKebabCase('foo-Bar-BAZ');
     $this->assertEquals(['foo', 'bar', 'baz'], $parser->getPieces());
     $parser = NameParser::parseFromKebabCase('foo');
     $this->assertEquals(['foo'], $parser->getPieces());
 }
Пример #3
0
 protected function isReadmeEqualWithBootstrappedOne($filesystem, $stubsPath)
 {
     $extensionName = explode('/', $this->composerJson['name'])[1];
     $nameParser = NameParser::parseFromKebabCase($extensionName);
     $exampleReadme = file_get_contents($stubsPath . '/extension/README.md.stub');
     $exampleReadme = str_replace('{nameTc}', $nameParser->getAsTitleCase(), $exampleReadme);
     $exampleReadme = str_replace('{nameKc}', $nameParser->getAsKebabCase(), $exampleReadme);
     $readme = $this->getReadme($filesystem);
     return $readme === $exampleReadme;
 }