Skip to content

Commit 504d605

Browse files
authored
Merge pull request #151 from Chi-teck/fix-test
Update tests
2 parents 54435aa + 1f016bf commit 504d605

File tree

109 files changed

+300
-309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+300
-309
lines changed

composer.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
"ext-json": "*",
2828
"psr/event-dispatcher": "^1.0",
2929
"psr/log": "^3.0",
30-
"symfony/console": "^7.0",
31-
"symfony/dependency-injection": "^7.0",
32-
"symfony/filesystem": "^7.0",
33-
"symfony/string": "^7.0",
30+
"symfony/console": "^7.1",
31+
"symfony/dependency-injection": "^7.1",
32+
"symfony/filesystem": "^7.1",
33+
"symfony/string": "^7.1",
3434
"twig/twig": "^3.4"
3535
},
3636
"require-dev": {
@@ -41,12 +41,14 @@
4141
"phpspec/prophecy-phpunit": "^2.2",
4242
"phpunit/phpunit": "^10.5",
4343
"squizlabs/php_codesniffer": "^3.9",
44-
"symfony/var-dumper": "^7.0",
45-
"symfony/yaml": "^7.0",
44+
"symfony/var-dumper": "^7.1",
45+
"symfony/yaml": "^7.1",
4646
"vimeo/psalm": "^5.24.0"
4747
},
4848
"conflict": {
4949
"squizlabs/php_codesniffer": "<3.6",
5050
"nikic/php-parser": "<4.17"
51-
}
51+
},
52+
"minimum-stability": "RC",
53+
"prefer-stable": true
5254
}

scripts/sut-tests.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ if [[ $test_filter = all || $test_filter = form ]]; then
138138

139139
dcg_phpcs --exclude=DrupalPractice.Yaml.RoutingAccess .
140140
dcg_module_install $module_machine_name
141-
dcg_phpunit tests
141+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
142142
dcg_module_uninstall $module_machine_name
143143
fi
144144

@@ -200,7 +200,7 @@ if [[ $test_filter = all || $test_filter = module_component ]]; then
200200

201201
dcg_phpcs .
202202
dcg_module_install $module_machine_name
203-
dcg_phpunit tests
203+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
204204
dcg_module_uninstall $module_machine_name
205205
fi
206206

@@ -242,7 +242,7 @@ if [[ $test_filter = all || $test_filter = plugin ]]; then
242242
dcg_module_install $module_machine_name
243243
echo 'Build CKEditor plugin...'
244244
npm install && npm run build
245-
dcg_phpunit tests
245+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
246246
dcg_module_uninstall $module_machine_name
247247
fi
248248

@@ -274,7 +274,7 @@ if [[ $test_filter = all || $test_filter = service ]]; then
274274

275275
dcg_phpcs $module_dir
276276
dcg_module_install $module_machine_name
277-
dcg_phpunit tests
277+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
278278
# Do not uninstall this module as the uninstall validator prevents it.
279279
fi
280280

@@ -299,7 +299,7 @@ if [[ $test_filter = all || $test_filter = yml ]]; then
299299

300300
dcg_phpcs $module_dir
301301
dcg_module_install $module_machine_name
302-
dcg_phpunit tests
302+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
303303
dcg_module_uninstall $module_machine_name
304304
fi
305305

@@ -321,7 +321,7 @@ if [[ $test_filter = all || $test_filter = test ]]; then
321321

322322
dcg_phpcs --exclude=Generic.CodeAnalysis.UselessOverridingMethod $module_dir
323323
dcg_module_install $module_machine_name
324-
dcg_phpunit tests
324+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
325325
dcg_module_uninstall $module_machine_name
326326
fi
327327

@@ -347,7 +347,7 @@ if [[ $test_filter = all || $test_filter = theme_component ]]; then
347347

348348
dcg_phpcs --exclude=Generic.CodeAnalysis.UselessOverridingMethod $module_dir
349349
dcg_module_install $module_machine_name
350-
dcg_phpunit tests
350+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
351351
dcg_module_uninstall $module_machine_name
352352
fi
353353

@@ -366,7 +366,7 @@ if [[ $test_filter = all || $test_filter = plugin_manager ]]; then
366366

367367
dcg_phpcs .
368368
dcg_module_install $module_machine_name
369-
dcg_phpunit tests
369+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
370370
dcg_module_uninstall $module_machine_name
371371
fi
372372

@@ -383,7 +383,7 @@ if [[ $test_filter = all || $test_filter = configuration_entity ]]; then
383383

384384
dcg_phpcs .
385385
dcg_module_install $module_machine_name
386-
dcg_phpunit tests
386+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
387387
dcg_module_uninstall $module_machine_name
388388
fi
389389

@@ -402,7 +402,7 @@ if [[ $test_filter = all || $test_filter = content_entity ]]; then
402402

403403
dcg_phpcs .
404404
dcg_module_install $module_machine_name
405-
dcg_phpunit tests
405+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
406406
dcg_module_uninstall $module_machine_name
407407

408408
dcg_label 'Content entity (with fields)'
@@ -418,7 +418,7 @@ if [[ $test_filter = all || $test_filter = content_entity ]]; then
418418

419419
dcg_phpcs .
420420
dcg_module_install $module_machine_name
421-
dcg_phpunit tests
421+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
422422
dcg_module_uninstall $module_machine_name
423423

424424
dcg_label 'Content entity (without bundles, fields and canonical page)'
@@ -434,7 +434,7 @@ if [[ $test_filter = all || $test_filter = content_entity ]]; then
434434

435435
dcg_phpcs .
436436
dcg_module_install $module_machine_name
437-
dcg_phpunit tests
437+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
438438
dcg_module_uninstall $module_machine_name
439439
fi
440440

@@ -450,7 +450,7 @@ if [[ $test_filter = all || $test_filter = bundle_class ]]; then
450450
$dcg entity:bundle-class -a acme -a Acme -a User -a UserBundle -a Yes -a UserBase
451451
dcg_phpcs $module_dir
452452
dcg_module_install $module_machine_name
453-
dcg_phpunit tests
453+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
454454
dcg_module_uninstall $module_machine_name
455455
fi
456456

@@ -464,11 +464,11 @@ if [[ $test_filter = all || $test_filter = module ]]; then
464464
cd $module_dir
465465

466466
$dcg module -d $drupal_dir/modules -a Peach -a peach -a 'Simple module generated by DCG.' \
467-
-a DCG -a 'drupal:views, drupal:node, drupal:action' -a Yes -a Yes -a Yes
467+
-a DCG -a 'drupal:views, drupal:node' -a Yes -a Yes -a Yes
468468

469469
dcg_phpcs $module_dir
470470
dcg_module_install $module_machine_name
471-
dcg_phpunit tests
471+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
472472
dcg_module_uninstall $module_machine_name
473473
fi
474474

@@ -491,7 +491,7 @@ if [[ $test_filter = all || $test_filter = theme ]]; then
491491
dcg_phpcs $theme_dir
492492
dcg_phpcs $module_dir
493493
dcg_module_install $module_machine_name
494-
dcg_phpunit tests
494+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
495495
dcg_module_uninstall $module_machine_name
496496
fi
497497

@@ -509,6 +509,6 @@ if [[ $test_filter = all || $test_filter = drush ]]; then
509509

510510
dcg_phpcs $module_dir
511511
dcg_module_install $module_machine_name
512-
dcg_phpunit tests
512+
dcg_phpunit $drupal_dir/modules/$module_machine_name/tests
513513
dcg_module_uninstall $module_machine_name
514514
fi

src/Twig/TwigSortTokenParser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ final class TwigSortTokenParser extends AbstractTokenParser {
1919
* {@inheritdoc}
2020
*/
2121
public function parse(Token $token): Node {
22+
\trigger_deprecation('chi-teck/drupal-code-generator', '3.6.0', 'The sort twig tag is deprecated and will be removed in 5.x, use the sort_namespaces twig filter.');
2223
$this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
2324
$body = $this->parser->subparse(
2425
static fn (Token $token): bool => $token->test('endsort'),

templates/Test/_browser/browser.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ declare(strict_types=1);
55
namespace Drupal\Tests\{{ machine_name }}\Functional;
66
77
use Drupal\Tests\BrowserTestBase;
8+
use PHPUnit\Framework\Attributes\Group;
89
910
/**
1011
* Test description.
11-
*
12-
* @group {{ machine_name }}
1312
*/
13+
#[Group('{{ machine_name }}')]
1414
final class {{ class }} extends BrowserTestBase {
1515
1616
/**

templates/Test/_kernel/kernel.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ declare(strict_types=1);
55
namespace Drupal\Tests\{{ machine_name }}\Kernel;
66
77
use Drupal\KernelTests\KernelTestBase;
8+
use PHPUnit\Framework\Attributes\Group;
89
910
/**
1011
* Test description.
11-
*
12-
* @group {{ machine_name }}
1312
*/
13+
#[Group('{{ machine_name }}')]
1414
final class {{ class }} extends KernelTestBase {
1515
1616
/**

templates/Test/_unit/unit.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ declare(strict_types=1);
55
namespace Drupal\Tests\{{ machine_name }}\Unit;
66
77
use Drupal\Tests\UnitTestCase;
8+
use PHPUnit\Framework\Attributes\Group;
89
910
/**
1011
* Test description.
11-
*
12-
* @group {{ machine_name }}
1312
*/
13+
#[Group('{{ machine_name }}')]
1414
final class {{ class }} extends UnitTestCase {
1515
1616
/**

templates/Test/_webdriver/webdriver.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ declare(strict_types=1);
55
namespace Drupal\Tests\{{ machine_name }}\FunctionalJavascript;
66
77
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
8+
use PHPUnit\Framework\Attributes\Group;
89
910
/**
1011
* Tests the JavaScript functionality of the {{ name }} module.
11-
*
12-
* @group {{ machine_name }}
1312
*/
13+
#[Group('{{ machine_name }}')]
1414
final class {{ class }} extends WebDriverTestBase {
1515
1616
/**

tests/functional/Generator/PhpStormMetaTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ private function assertPlugins(): void {
189189
self::assertStringContainsString('plugin.manager.block__plugin_ids', $generated_content);
190190
self::assertStringContainsString('plugin.manager.ckeditor5.plugin__plugin_ids', $generated_content);
191191
self::assertStringContainsString('plugin.manager.condition__plugin_ids', $generated_content);
192+
self::assertStringContainsString('plugin.manager.config_action__plugin_ids', $generated_content);
192193
self::assertStringContainsString('plugin.manager.display_variant__plugin_ids', $generated_content);
193194
self::assertStringContainsString('plugin.manager.editor__plugin_ids', $generated_content);
194195
self::assertStringContainsString('plugin.manager.element_info__plugin_ids', $generated_content);
@@ -198,6 +199,7 @@ private function assertPlugins(): void {
198199
self::assertStringContainsString('plugin.manager.field.widget__plugin_ids', $generated_content);
199200
self::assertStringContainsString('plugin.manager.filter__plugin_ids', $generated_content);
200201
self::assertStringContainsString('plugin.manager.help_section__plugin_ids', $generated_content);
202+
self::assertStringContainsString('plugin.manager.help_topic__plugin_ids', $generated_content);
201203
self::assertStringContainsString('plugin.manager.image.effect__plugin_ids', $generated_content);
202204
self::assertStringContainsString('plugin.manager.link_relation_type__plugin_ids', $generated_content);
203205
self::assertStringContainsString('plugin.manager.mail__plugin_ids', $generated_content);
@@ -227,7 +229,7 @@ private function assertPlugins(): void {
227229
self::assertStringContainsString('typed_data_manager__plugin_ids', $generated_content);
228230
self::assertStringContainsString('validation.constraint__plugin_ids', $generated_content);
229231

230-
self::assertSame(49, \substr_count($generated_content, 'registerArgumentsSet'));
232+
self::assertSame(51, \substr_count($generated_content, 'registerArgumentsSet'));
231233
}
232234

233235
/**
@@ -336,7 +338,6 @@ private function assertSettings(): void {
336338
'file_scan_ignore_directories',
337339
'entity_update_batch_size',
338340
'entity_update_backup',
339-
'state_cache',
340341
'migrate_node_migrate_type_classic',
341342
'config_sync_directory',
342343
PHP;

tests/functional/Generator/TemplateTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use DrupalCodeGenerator\Command\Template;
88
use DrupalCodeGenerator\Test\Functional\GeneratorTestBase;
9+
use PHPUnit\Framework\Attributes\DataProvider;
910

1011
/**
1112
* Tests template generator.
@@ -57,9 +58,8 @@ public function testGenerator(): void {
5758

5859
/**
5960
* Test callback.
60-
*
61-
* @dataProvider templateNameValidatorProvider()
6261
*/
62+
#[DataProvider('templateNameValidatorProvider')]
6363
public function testTemplateNameValidator(mixed $value, bool $exception): void {
6464
if ($exception) {
6565
self::expectExceptionObject(new \UnexpectedValueException('The value is not correct template name'));
@@ -72,7 +72,7 @@ public function testTemplateNameValidator(mixed $value, bool $exception): void {
7272
/**
7373
* Data provider callback for testTemplateNameValidator().
7474
*/
75-
public function templateNameValidatorProvider(): array {
75+
public static function templateNameValidatorProvider(): array {
7676
return [
7777
['aaa', FALSE],
7878
['aaa.bbb', FALSE],

tests/functional/Generator/Test/_browser/tests/src/Functional/ExampleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
namespace Drupal\Tests\foo\Functional;
66

77
use Drupal\Tests\BrowserTestBase;
8+
use PHPUnit\Framework\Attributes\Group;
89

910
/**
1011
* Test description.
11-
*
12-
* @group foo
1312
*/
13+
#[Group('foo')]
1414
final class ExampleTest extends BrowserTestBase {
1515

1616
/**

0 commit comments

Comments
 (0)