Skip to content

Commit 0b26eab

Browse files
committed
replace doctrine annotation by php attribute for PHPUnit
1 parent e660a8c commit 0b26eab

19 files changed

Lines changed: 222 additions & 133 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
### Changed
1212
- add required #\[RunTestsInSeparateProcesses] attribute on Kernel, Functional and FunctionalJavascript tests
13+
- replace doctrine annotation by php attribute for PHPUnit
1314

1415
## [6.0.6] - 2026-01-26
1516
### Added

tests/src/Functional/BambooTwigCacheableTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
namespace Drupal\Tests\bamboo_twig\Functional;
44

5+
use Drupal\bamboo_twig_cacheable\TwigExtension\BubbleMetadata;
6+
use PHPUnit\Framework\Attributes\CoversClass;
7+
use PHPUnit\Framework\Attributes\CoversMethod;
58
use PHPUnit\Framework\Attributes\Group;
69
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
710

811
/**
912
* Tests Cacheable twig filters and functions.
1013
*/
14+
#[CoversClass(BubbleMetadata::class)]
15+
#[CoversMethod(BubbleMetadata::class, 'attachCacheableMetadata')]
1116
#[Group('bamboo_twig')]
1217
#[Group('bamboo_twig_functional')]
1318
#[Group('bamboo_twig_cacheable')]
@@ -25,7 +30,7 @@ class BambooTwigCacheableTest extends BambooTwigTestBase {
2530
];
2631

2732
/**
28-
* @covers Drupal\bamboo_twig_cacheable\TwigExtension\BubbleMetadata::attachCacheableMetadata
33+
* Tests attachCacheableMetadata() propagates cache contexts to the response.
2934
*/
3035
public function testCacheableContexts() {
3136
$this->drupalGet('/bamboo-twig-cacheable');
@@ -35,7 +40,7 @@ public function testCacheableContexts() {
3540
}
3641

3742
/**
38-
* @covers Drupal\bamboo_twig_cacheable\TwigExtension\BubbleMetadata::attachCacheableMetadata
43+
* Tests attachCacheableMetadata() propagates cache tags to the response.
3944
*/
4045
public function testCacheableTags() {
4146
$this->drupalGet('/bamboo-twig-cacheable');
@@ -45,7 +50,7 @@ public function testCacheableTags() {
4550
}
4651

4752
/**
48-
* @covers Drupal\bamboo_twig_cacheable\TwigExtension\BubbleMetadata::attachCacheableMetadata
53+
* Tests attachCacheableMetadata() propagates max-age to the response.
4954
*/
5055
public function testCacheableMaxAge() {
5156
$this->drupalGet('/bamboo-twig-cacheable');

tests/src/Functional/BambooTwigConfigTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22

33
namespace Drupal\Tests\bamboo_twig\Functional;
44

5+
use Drupal\bamboo_twig_config\TwigExtension\Config;
6+
use PHPUnit\Framework\Attributes\CoversClass;
7+
use PHPUnit\Framework\Attributes\CoversMethod;
8+
use PHPUnit\Framework\Attributes\Group;
59
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
610

711
/**
812
* Tests Config twig filters and functions.
9-
*
10-
* @group bamboo_twig
11-
* @group bamboo_twig_functional
12-
* @group bamboo_twig_config
1313
*/
14+
#[CoversClass(Config::class)]
15+
#[CoversMethod(Config::class, 'getSettings')]
16+
#[CoversMethod(Config::class, 'getConfig')]
17+
#[CoversMethod(Config::class, 'getState')]
18+
#[Group('bamboo_twig')]
19+
#[Group('bamboo_twig_functional')]
20+
#[Group('bamboo_twig_config')]
1421
#[RunTestsInSeparateProcesses]
1522
class BambooTwigConfigTest extends BambooTwigTestBase {
1623

@@ -42,7 +49,7 @@ public function setUp(): void {
4249
}
4350

4451
/**
45-
* @covers Drupal\bamboo_twig_config\TwigExtension\Config::getSettings
52+
* Tests getSettings() exposes PHP settings values in templates.
4653
*/
4754
public function testGetSettings() {
4855
$this->drupalGet('/bamboo-twig-config');
@@ -52,7 +59,7 @@ public function testGetSettings() {
5259
}
5360

5461
/**
55-
* @covers Drupal\bamboo_twig_config\TwigExtension\Config::getConfig
62+
* Tests getConfig() exposes Drupal configuration values in templates.
5663
*/
5764
public function testGetConfig() {
5865
$this->drupalGet('/bamboo-twig-config');
@@ -62,7 +69,7 @@ public function testGetConfig() {
6269
}
6370

6471
/**
65-
* @covers Drupal\bamboo_twig_config\TwigExtension\Config::getState
72+
* Tests getState() exposes Drupal state values in templates.
6673
*/
6774
public function testGetState() {
6875
$now = time();

tests/src/Functional/BambooTwigExtensionsI18nTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
use Drupal\Component\Gettext\PoItem;
66
use Drupal\language\Entity\ConfigurableLanguage;
7+
use PHPUnit\Framework\Attributes\Group;
78
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
89

910
/**
1011
* Tests Extensions i18n of twig filters and functions.
11-
*
12-
* @group bamboo_twig
13-
* @group bamboo_twig_functional
14-
* @group bamboo_twig_extensions
15-
* @group bamboo_twig_extensions_i18n
1612
*/
13+
#[Group('bamboo_twig')]
14+
#[Group('bamboo_twig_functional')]
15+
#[Group('bamboo_twig_extensions')]
16+
#[Group('bamboo_twig_extensions_i18n')]
1717
#[RunTestsInSeparateProcesses]
1818
class BambooTwigExtensionsI18nTest extends BambooTwigTestBase {
1919

tests/src/Functional/BambooTwigExtensionsTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace Drupal\Tests\bamboo_twig\Functional;
44

5+
use PHPUnit\Framework\Attributes\Group;
56
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
67

78
/**
89
* Tests Extensions twig filters and functions.
9-
*
10-
* @group bamboo_twig
11-
* @group bamboo_twig_functional
12-
* @group bamboo_twig_extensions
1310
*/
11+
#[Group('bamboo_twig')]
12+
#[Group('bamboo_twig_functional')]
13+
#[Group('bamboo_twig_extensions')]
1414
#[RunTestsInSeparateProcesses]
1515
class BambooTwigExtensionsTest extends BambooTwigTestBase {
1616

tests/src/Functional/BambooTwigFileTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@
22

33
namespace Drupal\Tests\bamboo_twig\Functional;
44

5+
use Drupal\bamboo_twig_file\TwigExtension\File;
6+
use PHPUnit\Framework\Attributes\CoversClass;
7+
use PHPUnit\Framework\Attributes\CoversMethod;
8+
use PHPUnit\Framework\Attributes\Group;
59
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
610

711
/**
812
* Tests File twig filters and functions.
9-
*
10-
* @group bamboo_twig
11-
* @group bamboo_twig_functional
12-
* @group bamboo_twig_file
1313
*/
14+
#[CoversClass(File::class)]
15+
#[CoversMethod(File::class, 'extensionGuesser')]
16+
#[CoversMethod(File::class, 'UrlAbsolute')]
17+
#[Group('bamboo_twig')]
18+
#[Group('bamboo_twig_functional')]
19+
#[Group('bamboo_twig_file')]
1420
#[RunTestsInSeparateProcesses]
1521
class BambooTwigFileTest extends BambooTwigTestBase {
1622

@@ -25,7 +31,7 @@ class BambooTwigFileTest extends BambooTwigTestBase {
2531
];
2632

2733
/**
28-
* @covers Drupal\bamboo_twig_file\TwigExtension\File::extensionGuesser
34+
* Tests extensionGuesser() returns the correct extension for various files.
2935
*/
3036
public function testExtensionGuesser() {
3137
$this->drupalGet('/bamboo-twig-file');
@@ -44,7 +50,7 @@ public function testExtensionGuesser() {
4450
}
4551

4652
/**
47-
* @covers Drupal\bamboo_twig_file\TwigExtension\File::UrlAbsolute
53+
* Tests UrlAbsolute() returns relative and absolute file URLs.
4854
*/
4955
public function testUrlAbsolute() {
5056
$this->drupalGet('/bamboo-twig-file');

tests/src/Functional/BambooTwigI18nTest.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@
22

33
namespace Drupal\Tests\bamboo_twig\Functional;
44

5+
use Drupal\bamboo_twig_i18n\TwigExtension\I18n;
6+
use Drupal\bamboo_twig_loader\TwigExtension\Loader;
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\Attributes\CoversMethod;
9+
use PHPUnit\Framework\Attributes\Group;
510
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
611

712
/**
813
* Tests I18n twig filters and functions.
9-
*
10-
* @group bamboo_twig
11-
* @group bamboo_twig_functional
12-
* @group bamboo_twig_i18n
1314
*/
15+
#[CoversClass(I18n::class)]
16+
#[CoversClass(Loader::class)]
17+
#[CoversMethod(I18n::class, 'getCurrentLanguage')]
18+
#[CoversMethod(I18n::class, 'formatDate')]
19+
#[CoversMethod(I18n::class, 'getTranslation')]
20+
#[CoversMethod(Loader::class, 'loadEntity')]
21+
#[Group('bamboo_twig')]
22+
#[Group('bamboo_twig_functional')]
23+
#[Group('bamboo_twig_i18n')]
1424
#[RunTestsInSeparateProcesses]
1525
class BambooTwigI18nTest extends BambooTwigTestBase {
1626

@@ -87,7 +97,7 @@ protected function setUpTranslations() {
8797
}
8898

8999
/**
90-
* @covers Drupal\bamboo_twig_i18n\TwigExtension\I18n::getCurrentLanguage
100+
* Tests getCurrentLanguage() returns the active language code.
91101
*/
92102
public function testCurrentLang() {
93103
$this->drupalGet('/bamboo-twig-i18n');
@@ -100,7 +110,7 @@ public function testCurrentLang() {
100110
}
101111

102112
/**
103-
* @covers Drupal\bamboo_twig_i18n\TwigExtension\I18n::formatDate
113+
* Tests formatDate() formats dates with locale-aware translations.
104114
*/
105115
public function testFormatDate() {
106116
$this->drupalGet('/bamboo-twig-i18n');
@@ -145,7 +155,7 @@ public function testFormatDate() {
145155
}
146156

147157
/**
148-
* @covers Drupal\bamboo_twig_i18n\TwigExtension\I18n::getTranslation
158+
* Tests getTranslation() returns the entity in the requested language.
149159
*/
150160
public function testGetTranslation() {
151161
$this->drupalGet('/bamboo-twig-i18n');
@@ -187,8 +197,7 @@ public function testGetTranslation() {
187197
}
188198

189199
/**
190-
* @covers Drupal\bamboo_twig_i18n\TwigExtension\I18n::getTranslation
191-
* @covers Drupal\bamboo_twig_loader\TwigExtension\Loader::loadEntity
200+
* Tests getTranslation() with loadEntity() on entity reference fields.
192201
*/
193202
public function testGetTranslationReferencedField() {
194203
$this->drupalGet('/bamboo-twig-i18n');

tests/src/Functional/BambooTwigLoaderTest.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,27 @@
22

33
namespace Drupal\Tests\bamboo_twig\Functional;
44

5+
use Drupal\bamboo_twig_loader\TwigExtension\Loader;
56
use Drupal\Core\StreamWrapper\PublicStream;
67
use Drupal\file\FileInterface;
78
use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait;
9+
use PHPUnit\Framework\Attributes\CoversClass;
10+
use PHPUnit\Framework\Attributes\CoversMethod;
11+
use PHPUnit\Framework\Attributes\Group;
812
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
913

1014
/**
1115
* Tests Loaders twig filters and functions.
12-
*
13-
* @group bamboo_twig
14-
* @group bamboo_twig_functional
15-
* @group bamboo_twig_loader
1616
*/
17+
#[CoversClass(Loader::class)]
18+
#[CoversMethod(Loader::class, 'loadCurrentUser')]
19+
#[CoversMethod(Loader::class, 'loadEntity')]
20+
#[CoversMethod(Loader::class, 'loadEntityRevision')]
21+
#[CoversMethod(Loader::class, 'loadField')]
22+
#[CoversMethod(Loader::class, 'loadImage')]
23+
#[Group('bamboo_twig')]
24+
#[Group('bamboo_twig_functional')]
25+
#[Group('bamboo_twig_loader')]
1726
#[RunTestsInSeparateProcesses]
1827
class BambooTwigLoaderTest extends BambooTwigTestBase {
1928
use TaxonomyTestTrait;
@@ -98,7 +107,7 @@ public function setUp(): void {
98107
}
99108

100109
/**
101-
* @covers Drupal\bamboo_twig_loader\TwigExtension\Loader::loadCurrentUser
110+
* Tests loadCurrentUser() loads the current user in templates.
102111
*/
103112
public function testCurrentUser() {
104113
$this->drupalGet('/bamboo-twig-loader');
@@ -114,7 +123,7 @@ public function testCurrentUser() {
114123
}
115124

116125
/**
117-
* @covers Drupal\bamboo_twig_loader\TwigExtension\Loader::loadEntity
126+
* Tests loadEntity() loads nodes, taxonomy terms, files, and users.
118127
*/
119128
public function testEntity() {
120129
$this->drupalGet('/bamboo-twig-loader');
@@ -222,7 +231,7 @@ public function testEntity() {
222231
}
223232

224233
/**
225-
* @covers Drupal\bamboo_twig_loader\TwigExtension\Loader::loadEntityRevision
234+
* Tests loadEntityRevision() loads specific revisions of entities.
226235
*/
227236
public function testEntityRevision() {
228237
$this->drupalGet('/bamboo-twig-loader-revision');
@@ -252,8 +261,7 @@ public function testEntityRevision() {
252261
}
253262

254263
/**
255-
* @covers Drupal\bamboo_twig_loader\TwigExtension\Loader::loadEntity
256-
* @covers Drupal\bamboo_twig_loader\TwigExtension\Loader::loadEntityRevision
264+
* Tests loadEntity() and loadEntityRevision() load entities from route.
257265
*/
258266
public function testEntityFromRoutes() {
259267
// Accessing unpublished revision page required to be authenticated.
@@ -287,7 +295,7 @@ public function testEntityFromRoutes() {
287295
}
288296

289297
/**
290-
* @covers Drupal\bamboo_twig_loader\TwigExtension\Loader::loadField
298+
* Tests loadField() loads individual field values from entities.
291299
*/
292300
public function testField() {
293301
$this->drupalGet('/bamboo-twig-loader');
@@ -391,7 +399,7 @@ public function testField() {
391399
}
392400

393401
/**
394-
* @covers Drupal\bamboo_twig_loader\TwigExtension\Loader::loadImage
402+
* Tests loadImage() loads an image by URI and by module path.
395403
*/
396404
public function testImage() {
397405
$this->drupalGet('/bamboo-twig-loader');

tests/src/Functional/BambooTwigPathTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22

33
namespace Drupal\Tests\bamboo_twig\Functional;
44

5+
use Drupal\bamboo_twig_path\TwigExtension\Path;
6+
use PHPUnit\Framework\Attributes\CoversClass;
7+
use PHPUnit\Framework\Attributes\CoversMethod;
8+
use PHPUnit\Framework\Attributes\Group;
59
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
610

711
/**
812
* Tests Path twig filters and functions.
9-
*
10-
* @group bamboo_twig
11-
* @group bamboo_twig_functional
12-
* @group bamboo_twig_path
1313
*/
14+
#[CoversClass(Path::class)]
15+
#[CoversMethod(Path::class, 'getSystemPath')]
16+
#[Group('bamboo_twig')]
17+
#[Group('bamboo_twig_functional')]
18+
#[Group('bamboo_twig_path')]
1419
#[RunTestsInSeparateProcesses]
1520
class BambooTwigPathTest extends BambooTwigTestBase {
1621

@@ -24,7 +29,7 @@ class BambooTwigPathTest extends BambooTwigTestBase {
2429
];
2530

2631
/**
27-
* @covers Drupal\bamboo_twig_path\TwigExtension\Path::getSystemPath
32+
* Tests getSystemPath() resolves theme, profile, and module paths.
2833
*/
2934
public function testPathSystem() {
3035
$this->drupalGet('/bamboo-twig-path');

0 commit comments

Comments
 (0)