Refactor, use a Collection
wip
This commit is contained in:
parent
9418ba4ee7
commit
b773e0f76f
|
@ -6,7 +6,8 @@
|
|||
"symfony/console": "^5.0",
|
||||
"symfony/dependency-injection": "^5.0",
|
||||
"symfony/filesystem": "^5.0",
|
||||
"symfony/finder": "^5.0"
|
||||
"symfony/finder": "^5.0",
|
||||
"tightenco/collect": "^6.14"
|
||||
},
|
||||
"require-dev": {
|
||||
"php": "5.6 || ^7.0",
|
||||
|
|
202
composer.lock
generated
202
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "eec04f9d7e938466a1a1782750a35b63",
|
||||
"content-hash": "a32dc8d2b5bef1cbe30356b9599564c5",
|
||||
"packages": [
|
||||
{
|
||||
"name": "psr/container",
|
||||
|
@ -535,6 +535,131 @@
|
|||
"standards"
|
||||
],
|
||||
"time": "2019-11-18T17:27:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/var-dumper",
|
||||
"version": "v5.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/var-dumper.git",
|
||||
"reference": "923591cfb78a935f0c98968fedfad05bfda9d01f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/923591cfb78a935f0c98968fedfad05bfda9d01f",
|
||||
"reference": "923591cfb78a935f0c98968fedfad05bfda9d01f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5",
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
},
|
||||
"conflict": {
|
||||
"phpunit/phpunit": "<5.4.3",
|
||||
"symfony/console": "<4.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-iconv": "*",
|
||||
"symfony/console": "^4.4|^5.0",
|
||||
"symfony/process": "^4.4|^5.0",
|
||||
"twig/twig": "^2.4|^3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
|
||||
"ext-intl": "To show region name in time zone dump",
|
||||
"symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script"
|
||||
},
|
||||
"bin": [
|
||||
"Resources/bin/var-dump-server"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"Resources/functions/dump.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\VarDumper\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony mechanism for exploring and dumping PHP variables",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"dump"
|
||||
],
|
||||
"time": "2020-01-25T15:56:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "tightenco/collect",
|
||||
"version": "v6.14.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tightenco/collect.git",
|
||||
"reference": "17046ff310e1c6a70c8c1cd3743b3631b7e76aee"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/tightenco/collect/zipball/17046ff310e1c6a70c8c1cd3743b3631b7e76aee",
|
||||
"reference": "17046ff310e1c6a70c8c1cd3743b3631b7e76aee",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"symfony/var-dumper": "^3.4 || ^4.0 || ^5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.0",
|
||||
"nesbot/carbon": "^2.23.0",
|
||||
"phpunit/phpunit": "^7.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/Collect/Support/helpers.php",
|
||||
"src/Collect/Support/alias.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Tightenco\\Collect\\": "src/Collect"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Collect - Illuminate Collections as a separate package.",
|
||||
"keywords": [
|
||||
"collection",
|
||||
"laravel"
|
||||
],
|
||||
"time": "2020-01-28T19:25:21+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
|
@ -1974,81 +2099,6 @@
|
|||
"homepage": "https://github.com/sebastianbergmann/version",
|
||||
"time": "2020-01-21T06:36:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/var-dumper",
|
||||
"version": "v5.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/var-dumper.git",
|
||||
"reference": "923591cfb78a935f0c98968fedfad05bfda9d01f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/923591cfb78a935f0c98968fedfad05bfda9d01f",
|
||||
"reference": "923591cfb78a935f0c98968fedfad05bfda9d01f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5",
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
},
|
||||
"conflict": {
|
||||
"phpunit/phpunit": "<5.4.3",
|
||||
"symfony/console": "<4.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-iconv": "*",
|
||||
"symfony/console": "^4.4|^5.0",
|
||||
"symfony/process": "^4.4|^5.0",
|
||||
"twig/twig": "^2.4|^3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
|
||||
"ext-intl": "To show region name in time zone dump",
|
||||
"symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script"
|
||||
},
|
||||
"bin": [
|
||||
"Resources/bin/var-dump-server"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"Resources/functions/dump.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\VarDumper\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony mechanism for exploring and dumping PHP variables",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"dump"
|
||||
],
|
||||
"time": "2020-01-25T15:56:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "theseer/tokenizer",
|
||||
"version": "1.1.3",
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\{{ name }}\Tests\Functional;
|
||||
|
||||
class {{ test_name }} extends \DrupalWebTestCase {}
|
|
@ -11,6 +11,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\Finder\SplFileInfo;
|
||||
use Tightenco\Collect\Support\Collection;
|
||||
|
||||
class GenerateDrupal7Command extends Command
|
||||
{
|
||||
|
@ -85,7 +86,7 @@ class GenerateDrupal7Command extends Command
|
|||
|
||||
private function createFiles()
|
||||
{
|
||||
$createdFiles = [];
|
||||
$createdFiles = new Collection();
|
||||
|
||||
/** @var SplFileInfo $file */
|
||||
foreach ($this->finder->in('fixtures/drupal7_module')->name('/.[info,module]/') as $file) {
|
||||
|
@ -96,10 +97,10 @@ class GenerateDrupal7Command extends Command
|
|||
$contents
|
||||
);
|
||||
|
||||
$createdFiles[] = "{$this->moduleName}.{$file->getExtension()}";
|
||||
$createdFiles->push("{$this->moduleName}.{$file->getExtension()}");
|
||||
}
|
||||
|
||||
$this->io->definitionList($createdFiles);
|
||||
$this->io->listing($createdFiles->sort()->toArray());
|
||||
}
|
||||
|
||||
private function updateFileContents($contents)
|
||||
|
|
17
src/Service/TestNameConverter.php
Normal file
17
src/Service/TestNameConverter.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Opdavies\DrupalModuleGenerator\Service;
|
||||
|
||||
class TestNameConverter
|
||||
{
|
||||
public function __invoke(string $moduleName)
|
||||
{
|
||||
$parts = explode('_', $moduleName);
|
||||
|
||||
$parts = array_map(function ($part) {
|
||||
return ucfirst($part);
|
||||
}, $parts);
|
||||
|
||||
return implode('', $parts).'Test';
|
||||
}
|
||||
}
|
20
tests/Service/TestNameConverterTest.php
Normal file
20
tests/Service/TestNameConverterTest.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Opdavies\Tests\DrupalModuleGenerator\Service;
|
||||
|
||||
use Opdavies\DrupalModuleGenerator\Service\TestNameConverter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class TestNameConverterTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function it_converts_a_module_name_into_a_test_name()
|
||||
{
|
||||
$testNameConverter = new TestNameConverter();
|
||||
|
||||
$moduleName = 'my_module';
|
||||
$testName = 'MyModuleTest';
|
||||
|
||||
$this->assertSame($testName, $testNameConverter->__invoke($moduleName));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue