Skip to content

Commit 1a6c520

Browse files
committed
Adopt PHP attributes in test classes
1 parent 414056c commit 1a6c520

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

tests/Feature/SetLocaleTest.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace CodeZero\Localizer\Tests\Feature;
44

5+
use PHPUnit\Framework\Attributes\Test;
56
use CodeZero\BrowserLocale\BrowserLocale;
67
use CodeZero\Localizer\Middleware\SetLocale;
78
use CodeZero\Localizer\Tests\TestCase;
@@ -33,7 +34,7 @@ protected function setUp(): void
3334
$this->cookieName = Config::get('localizer.cookie_name');
3435
}
3536

36-
/** @test */
37+
#[Test]
3738
public function it_looks_for_a_locale_in_a_custom_route_action()
3839
{
3940
$this->setSupportedLocales(['en', 'nl']);
@@ -54,7 +55,7 @@ public function it_looks_for_a_locale_in_a_custom_route_action()
5455
$this->assertEquals('nl', $response->original);
5556
}
5657

57-
/** @test */
58+
#[Test]
5859
public function it_looks_for_a_locale_in_the_url()
5960
{
6061
$this->setSupportedLocales(['en', 'nl']);
@@ -71,7 +72,7 @@ public function it_looks_for_a_locale_in_the_url()
7172
$this->assertEquals('nl', $response->original);
7273
}
7374

74-
/** @test */
75+
#[Test]
7576
public function you_can_configure_which_segment_to_use_as_locale()
7677
{
7778
$this->setSupportedLocales(['en', 'nl']);
@@ -90,7 +91,7 @@ public function you_can_configure_which_segment_to_use_as_locale()
9091
$this->assertEquals('nl', $response->original);
9192
}
9293

93-
/** @test */
94+
#[Test]
9495
public function it_looks_for_custom_slugs()
9596
{
9697
$this->setSupportedLocales([
@@ -110,7 +111,7 @@ public function it_looks_for_custom_slugs()
110111
$this->assertEquals('nl', $response->original);
111112
}
112113

113-
/** @test */
114+
#[Test]
114115
public function you_can_use_multiple_slugs_for_a_locale()
115116
{
116117
$this->setSupportedLocales([
@@ -140,7 +141,7 @@ public function you_can_use_multiple_slugs_for_a_locale()
140141
$this->assertEquals('nl', $response->original);
141142
}
142143

143-
/** @test */
144+
#[Test]
144145
public function it_looks_for_custom_domains()
145146
{
146147
$this->setSupportedLocales([
@@ -162,7 +163,7 @@ public function it_looks_for_custom_domains()
162163
$this->assertEquals('nl', $response->original);
163164
}
164165

165-
/** @test */
166+
#[Test]
166167
public function you_can_use_multiple_domains_for_a_locale()
167168
{
168169
$this->setSupportedLocales([
@@ -196,7 +197,7 @@ public function you_can_use_multiple_domains_for_a_locale()
196197
$this->assertEquals('nl', $response->original);
197198
}
198199

199-
/** @test */
200+
#[Test]
200201
public function it_checks_for_a_configured_omitted_locale()
201202
{
202203
$this->setSupportedLocales(['en', 'nl']);
@@ -215,7 +216,7 @@ public function it_checks_for_a_configured_omitted_locale()
215216
$this->assertEquals('nl', $response->original);
216217
}
217218

218-
/** @test */
219+
#[Test]
219220
public function it_looks_for_a_locale_on_the_authenticated_user()
220221
{
221222
$this->setSupportedLocales(['en', 'nl']);
@@ -236,7 +237,7 @@ public function it_looks_for_a_locale_on_the_authenticated_user()
236237
$this->assertEquals('nl', $response->original);
237238
}
238239

239-
/** @test */
240+
#[Test]
240241
public function it_will_bypass_missing_attribute_exception_if_the_locale_attribute_is_missing_on_the_user_model()
241242
{
242243
if (version_compare(App::version(), '9.35.0') === -1) {
@@ -261,7 +262,7 @@ public function it_will_bypass_missing_attribute_exception_if_the_locale_attribu
261262
$this->assertEquals('en', $response->original);
262263
}
263264

264-
/** @test */
265+
#[Test]
265266
public function it_looks_for_a_locale_in_the_session()
266267
{
267268
$this->setSupportedLocales(['en', 'nl']);
@@ -280,7 +281,7 @@ public function it_looks_for_a_locale_in_the_session()
280281
$this->assertEquals('nl', $response->original);
281282
}
282283

283-
/** @test */
284+
#[Test]
284285
public function it_looks_for_a_locale_in_a_cookie()
285286
{
286287
$this->setSupportedLocales(['en', 'nl']);
@@ -300,7 +301,7 @@ public function it_looks_for_a_locale_in_a_cookie()
300301
$this->assertEquals('nl', $response->original);
301302
}
302303

303-
/** @test */
304+
#[Test]
304305
public function it_looks_for_a_locale_in_the_browser()
305306
{
306307
$this->setSupportedLocales(['en', 'nl']);
@@ -319,7 +320,7 @@ public function it_looks_for_a_locale_in_the_browser()
319320
$this->assertEquals('nl', $response->original);
320321
}
321322

322-
/** @test */
323+
#[Test]
323324
public function it_returns_the_best_match_when_a_browser_locale_is_used()
324325
{
325326
$this->setSupportedLocales(['en', 'nl', 'fr']);
@@ -338,7 +339,7 @@ public function it_returns_the_best_match_when_a_browser_locale_is_used()
338339
$this->assertEquals('nl', $response->original);
339340
}
340341

341-
/** @test */
342+
#[Test]
342343
public function it_looks_for_the_current_app_locale()
343344
{
344345
$this->setSupportedLocales(['en', 'nl']);
@@ -355,7 +356,7 @@ public function it_looks_for_the_current_app_locale()
355356
$this->assertEquals('nl', $response->original);
356357
}
357358

358-
/** @test */
359+
#[Test]
359360
public function trusted_detectors_ignore_supported_locales_and_may_set_any_locale()
360361
{
361362
$this->setSupportedLocales(['en']);

tests/Unit/LocalizerTest.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace CodeZero\Localizer\Tests\Unit;
44

5+
use PHPUnit\Framework\Attributes\Test;
56
use CodeZero\Localizer\Detectors\Detector;
67
use CodeZero\Localizer\Localizer;
78
use CodeZero\Localizer\Stores\Store;
@@ -11,7 +12,7 @@
1112

1213
class LocalizerTest extends TestCase
1314
{
14-
/** @test */
15+
#[Test]
1516
public function it_loops_through_the_detectors_and_returns_the_first_supported_locale()
1617
{
1718
$supportedLocales = ['en', 'nl'];
@@ -26,7 +27,7 @@ public function it_loops_through_the_detectors_and_returns_the_first_supported_l
2627
$this->assertEquals('nl', $localizer->detect());
2728
}
2829

29-
/** @test */
30+
#[Test]
3031
public function it_returns_the_first_match_if_an_array_of_locales_is_detected()
3132
{
3233
$supportedLocales = ['en', 'nl'];
@@ -39,7 +40,7 @@ public function it_returns_the_first_match_if_an_array_of_locales_is_detected()
3940
$this->assertEquals('nl', $localizer->detect());
4041
}
4142

42-
/** @test */
43+
#[Test]
4344
public function trusted_detectors_ignore_supported_locales_and_may_set_any_locale()
4445
{
4546
$supportedLocales = ['en'];
@@ -55,7 +56,7 @@ public function trusted_detectors_ignore_supported_locales_and_may_set_any_local
5556
$this->assertEquals('nl', $localizer->detect());
5657
}
5758

58-
/** @test */
59+
#[Test]
5960
public function it_skips_null_and_false_and_empty_values()
6061
{
6162
App::instance(Detector::class, Mockery::mock(Detector::class)->allows()->detect()->andReturns('')->getMock());
@@ -75,7 +76,7 @@ public function it_skips_null_and_false_and_empty_values()
7576
$this->assertEquals('nl', $localizer->detect());
7677
}
7778

78-
/** @test */
79+
#[Test]
7980
public function it_skips_null_and_false_and_empty_values_from_trusted_detectors()
8081
{
8182
App::instance(Detector::class, Mockery::mock(Detector::class)->allows()->detect()->andReturns('')->getMock());
@@ -98,7 +99,7 @@ public function it_skips_null_and_false_and_empty_values_from_trusted_detectors(
9899
$this->assertEquals('nl', $localizer->detect());
99100
}
100101

101-
/** @test */
102+
#[Test]
102103
public function it_returns_false_if_no_supported_locale_could_be_detected()
103104
{
104105
$supportedLocales = ['en'];
@@ -113,7 +114,7 @@ public function it_returns_false_if_no_supported_locale_could_be_detected()
113114
$this->assertFalse($localizer->detect());
114115
}
115116

116-
/** @test */
117+
#[Test]
117118
public function it_loops_through_the_stores_and_calls_the_store_method_with_the_given_locale()
118119
{
119120
$stores = [
@@ -127,7 +128,7 @@ public function it_loops_through_the_stores_and_calls_the_store_method_with_the_
127128
$localizer->store('nl');
128129
}
129130

130-
/** @test */
131+
#[Test]
131132
public function it_accepts_class_names_instead_of_instances_in_the_constructor()
132133
{
133134
App::instance(Store::class, Mockery::mock(Store::class)->expects()->store('nl')->once()->getMock());
@@ -142,7 +143,7 @@ public function it_accepts_class_names_instead_of_instances_in_the_constructor()
142143
$localizer->store('nl');
143144
}
144145

145-
/** @test */
146+
#[Test]
146147
public function you_can_set_the_supported_locales_at_runtime()
147148
{
148149
$supportedLocales = ['en'];

0 commit comments

Comments
 (0)