Skip to content

Commit f0eddb2

Browse files
PHPUnit 10 Shift (#606)
1 parent ac89359 commit f0eddb2

38 files changed

+635
-1085
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ jobs:
8282
run: composer require laravel/framework --no-update
8383

8484
- name: Run tests
85-
run: vendor/bin/phpunit --verbose
85+
run: vendor/bin/phpunit

.github/workflows/demo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
with:
106106
timeout_minutes: 5
107107
max_attempts: 5
108-
command: cd /home/runner/work/blueprint/laravel${{ matrix.laravel-version }}-example; pwd; vendor/bin/phpunit --verbose
108+
command: cd /home/runner/work/blueprint/laravel${{ matrix.laravel-version }}-example; pwd; vendor/bin/phpunit
109109

110110
- name: Run artisan test
111111
uses: nick-invision/retry@v1

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/vendor/
22
/build/
33
.env
4-
.phpunit.result.cache
4+
/.phpunit.cache
55
composer.lock

.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
"name": "laravel-shift/blueprint",
33
"type": "library",
44
"description": "An expressive, human readable code generation tool.",
5-
"keywords": ["framework", "laravel", "code generation"],
5+
"keywords": [
6+
"framework",
7+
"laravel",
8+
"code generation"
9+
],
610
"license": "MIT",
711
"require": {
812
"doctrine/dbal": "^3.3",
@@ -16,7 +20,7 @@
1620
"laravel/pint": "^1.2",
1721
"mockery/mockery": "^1.4.4",
1822
"orchestra/testbench": "^8.0",
19-
"phpunit/phpunit": "^9.5.10"
23+
"phpunit/phpunit": "^10.0"
2024
},
2125
"suggest": {
2226
"jasonmccreary/laravel-test-assertions": "Required to use additional assertions in generated tests (^1.0)."

phpunit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false">
3-
<coverage processUncoveredFiles="true">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3+
<coverage>
44
<include>
55
<directory suffix=".php">./src</directory>
66
</include>

tests/Feature/BlueprintTest.php

Lines changed: 47 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
use Blueprint\Contracts\Generator;
77
use Blueprint\Contracts\Lexer;
88
use Blueprint\Tree;
9+
use PHPUnit\Framework\Attributes\DataProvider;
10+
use PHPUnit\Framework\Attributes\Test;
911
use Symfony\Component\Yaml\Exception\ParseException;
1012
use Tests\TestCase;
1113

1214
/**
1315
* @see Blueprint
1416
*/
15-
class BlueprintTest extends TestCase
17+
final class BlueprintTest extends TestCase
1618
{
1719
/**
1820
* @var Blueprint
@@ -26,10 +28,8 @@ protected function setUp(): void
2628
$this->subject = new Blueprint();
2729
}
2830

29-
/**
30-
* @test
31-
*/
32-
public function it_parses_models()
31+
#[Test]
32+
public function it_parses_models(): void
3333
{
3434
$blueprint = $this->fixture('drafts/models-only.yaml');
3535

@@ -68,10 +68,8 @@ public function it_parses_seeders()
6868
], $this->subject->parse($blueprint));
6969
}
7070

71-
/**
72-
* @test
73-
*/
74-
public function it_parses_controllers()
71+
#[Test]
72+
public function it_parses_controllers(): void
7573
{
7674
$blueprint = $this->fixture('drafts/controllers-only.yaml');
7775

@@ -95,10 +93,8 @@ public function it_parses_controllers()
9593
], $this->subject->parse($blueprint));
9694
}
9795

98-
/**
99-
* @test
100-
*/
101-
public function it_parses_shorthands()
96+
#[Test]
97+
public function it_parses_shorthands(): void
10298
{
10399
$blueprint = $this->fixture('drafts/shorthands.yaml');
104100

@@ -121,10 +117,8 @@ public function it_parses_shorthands()
121117
], $this->subject->parse($blueprint));
122118
}
123119

124-
/**
125-
* @test
126-
*/
127-
public function it_parses_uuid_shorthand()
120+
#[Test]
121+
public function it_parses_uuid_shorthand(): void
128122
{
129123
$blueprint = $this->fixture('drafts/uuid-shorthand.yaml');
130124

@@ -139,10 +133,8 @@ public function it_parses_uuid_shorthand()
139133
], $this->subject->parse($blueprint));
140134
}
141135

142-
/**
143-
* @test
144-
*/
145-
public function it_parses_shorthands_with_timezones()
136+
#[Test]
137+
public function it_parses_shorthands_with_timezones(): void
146138
{
147139
$blueprint = $this->fixture('drafts/with-timezones.yaml');
148140

@@ -156,10 +148,8 @@ public function it_parses_shorthands_with_timezones()
156148
], $this->subject->parse($blueprint));
157149
}
158150

159-
/**
160-
* @test
161-
*/
162-
public function it_parses_longhands()
151+
#[Test]
152+
public function it_parses_longhands(): void
163153
{
164154
$blueprint = $this->fixture('drafts/longhands.yaml');
165155

@@ -183,10 +173,8 @@ public function it_parses_longhands()
183173
], $this->subject->parse($blueprint));
184174
}
185175

186-
/**
187-
* @test
188-
*/
189-
public function it_parses_resource_shorthands()
176+
#[Test]
177+
public function it_parses_resource_shorthands(): void
190178
{
191179
$blueprint = $this->fixture('drafts/with-timezones.yaml');
192180

@@ -200,10 +188,8 @@ public function it_parses_resource_shorthands()
200188
], $this->subject->parse($blueprint));
201189
}
202190

203-
/**
204-
* @test
205-
*/
206-
public function it_parses_the_readme_example()
191+
#[Test]
192+
public function it_parses_the_readme_example(): void
207193
{
208194
$blueprint = $this->fixture('drafts/readme-example.yaml');
209195

@@ -236,10 +222,8 @@ public function it_parses_the_readme_example()
236222
], $this->subject->parse($blueprint));
237223
}
238224

239-
/**
240-
* @test
241-
*/
242-
public function it_parses_the_readme_example_with_different_platform_eols()
225+
#[Test]
226+
public function it_parses_the_readme_example_with_different_platform_eols(): void
243227
{
244228
$definition = $this->fixture('drafts/readme-example.yaml');
245229

@@ -282,10 +266,8 @@ public function it_parses_the_readme_example_with_different_platform_eols()
282266
$this->assertEquals($expected, $this->subject->parse($definition_windows_eol));
283267
}
284268

285-
/**
286-
* @test
287-
*/
288-
public function it_parses_yaml_with_dashed_syntax()
269+
#[Test]
270+
public function it_parses_yaml_with_dashed_syntax(): void
289271
{
290272
$definition = $this->fixture('drafts/readme-example-dashes.yaml');
291273

@@ -314,10 +296,8 @@ public function it_parses_yaml_with_dashed_syntax()
314296
$this->assertEquals($expected, $this->subject->parse($definition));
315297
}
316298

317-
/**
318-
* @test
319-
*/
320-
public function it_allows_parsing_without_stripping_dashes()
299+
#[Test]
300+
public function it_allows_parsing_without_stripping_dashes(): void
321301
{
322302
$sequence = [
323303
'numbers' => range(3, 11),
@@ -326,10 +306,8 @@ public function it_allows_parsing_without_stripping_dashes()
326306
$this->assertEquals($sequence, $this->subject->parse($this->subject->dump($sequence), false));
327307
}
328308

329-
/**
330-
* @test
331-
*/
332-
public function it_throws_a_custom_error_when_parsing_fails()
309+
#[Test]
310+
public function it_throws_a_custom_error_when_parsing_fails(): void
333311
{
334312
$this->expectException(ParseException::class);
335313

@@ -338,10 +316,8 @@ public function it_throws_a_custom_error_when_parsing_fails()
338316
$this->subject->parse($blueprint);
339317
}
340318

341-
/**
342-
* @test
343-
*/
344-
public function analyze_return_default_tree_for_empty_tokens()
319+
#[Test]
320+
public function analyze_return_default_tree_for_empty_tokens(): void
345321
{
346322
$tokens = [];
347323

@@ -354,10 +330,8 @@ public function analyze_return_default_tree_for_empty_tokens()
354330
);
355331
}
356332

357-
/**
358-
* @test
359-
*/
360-
public function analyze_uses_register_lexers_to_analyze_tokens()
333+
#[Test]
334+
public function analyze_uses_register_lexers_to_analyze_tokens(): void
361335
{
362336
$lexer = \Mockery::mock(Lexer::class);
363337
$tokens = ['tokens' => ['are', 'here']];
@@ -374,10 +348,8 @@ public function analyze_uses_register_lexers_to_analyze_tokens()
374348
], $this->subject->analyze($tokens)->toArray());
375349
}
376350

377-
/**
378-
* @test
379-
*/
380-
public function generate_uses_registered_generators_and_returns_generated_files()
351+
#[Test]
352+
public function generate_uses_registered_generators_and_returns_generated_files(): void
381353
{
382354
$generatorOne = \Mockery::mock(Generator::class);
383355
$tree = new Tree(['branch' => ['code', 'attributes']]);
@@ -421,10 +393,8 @@ public function generate_uses_registered_generators_and_returns_generated_files(
421393
], $this->subject->generate($tree));
422394
}
423395

424-
/**
425-
* @test
426-
*/
427-
public function generate_uses_swapped_generator_and_returns_generated_files()
396+
#[Test]
397+
public function generate_uses_swapped_generator_and_returns_generated_files(): void
428398
{
429399
$generatorOne = \Mockery::mock(Generator::class);
430400
$tree = new Tree(['branch' => ['code', 'attributes']]);
@@ -456,10 +426,8 @@ public function generate_uses_swapped_generator_and_returns_generated_files()
456426
], $this->subject->generate($tree));
457427
}
458428

459-
/**
460-
* @test
461-
*/
462-
public function generate_only_one_specific_type()
429+
#[Test]
430+
public function generate_only_one_specific_type(): void
463431
{
464432
$generatorFoo = \Mockery::mock(Generator::class);
465433
$tree = new Tree(['branch' => ['code', 'attributes']]);
@@ -507,10 +475,8 @@ public function generate_only_one_specific_type()
507475
], $actual);
508476
}
509477

510-
/**
511-
* @test
512-
*/
513-
public function generate_only_specific_types()
478+
#[Test]
479+
public function generate_only_specific_types(): void
514480
{
515481
$generatorFoo = \Mockery::mock(Generator::class);
516482
$tree = new Tree(['branch' => ['code', 'attributes']]);
@@ -558,10 +524,8 @@ public function generate_only_specific_types()
558524
], $actual);
559525
}
560526

561-
/**
562-
* @test
563-
*/
564-
public function generate_should_skip_one_specific_type()
527+
#[Test]
528+
public function generate_should_skip_one_specific_type(): void
565529
{
566530
$generatorFoo = \Mockery::mock(Generator::class);
567531
$tree = new Tree(['branch' => ['code', 'attributes']]);
@@ -609,10 +573,8 @@ public function generate_should_skip_one_specific_type()
609573
], $actual);
610574
}
611575

612-
/**
613-
* @test
614-
*/
615-
public function generate_should_skip_specific_types()
576+
#[Test]
577+
public function generate_should_skip_specific_types(): void
616578
{
617579
$generatorFoo = \Mockery::mock(Generator::class);
618580
$tree = new Tree(['branch' => ['code', 'attributes']]);
@@ -660,19 +622,16 @@ public function generate_should_skip_specific_types()
660622
], $actual);
661623
}
662624

663-
/**
664-
* @test
665-
*
666-
* @dataProvider namespacesDataProvider
667-
*/
668-
public function relative_namespace_removes_namespace_prefix_from_reference($namespace, $expected, $reference)
625+
#[Test]
626+
#[DataProvider('namespacesDataProvider')]
627+
public function relative_namespace_removes_namespace_prefix_from_reference($namespace, $expected, $reference): void
669628
{
670629
config(['blueprint.namespace' => $namespace]);
671630

672631
$this->assertEquals($expected, Blueprint::relativeNamespace($reference));
673632
}
674633

675-
public function namespacesDataProvider()
634+
public static function namespacesDataProvider(): array
676635
{
677636
return [
678637
['App', 'Models\User', 'App\Models\User'],

0 commit comments

Comments
 (0)