Skip to content

Commit 097967f

Browse files
committed
Add attributes to run tests with PHPUnit 12
I'm leaving the PHPDoc so that tests run with PHPUnit 9 too, since it's needed for PHP 7.x. We can get rid of them in 8.x, once we can bump to PHPUnit 10+
1 parent 662de15 commit 097967f

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

integration/PhpSpec/Console/Prompter/QuestionTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
namespace integration\PhpSpec\Console\Prompter;
44

55
use PhpSpec\Console\Prompter\Question;
6+
use PHPUnit\Framework\Attributes\RequiresMethod;
7+
use PHPUnit\Framework\Attributes\Test;
68
use PHPUnit\Framework\TestCase;
9+
use Symfony\Component\Console\Helper\QuestionHelper;
710
use Symfony\Component\Console\Question\ConfirmationQuestion;
811

912
/**
1013
* @requires function \Symfony\Component\Console\Helper\QuestionHelper::ask
1114
*/
15+
#[RequiresMethod(QuestionHelper::class, 'ask')]
1216
class QuestionTest extends TestCase
1317
{
1418
/**
@@ -43,6 +47,7 @@ protected function setUp() : void
4347
/**
4448
* @test
4549
*/
50+
#[Test]
4651
function it_is_a_prompter()
4752
{
4853
$this->assertInstanceOf('PhpSpec\Console\Prompter', $this->prompter);
@@ -51,6 +56,7 @@ function it_is_a_prompter()
5156
/**
5257
* @test
5358
*/
59+
#[Test]
5460
function it_can_ask_a_question_and_return_the_result()
5561
{
5662
$this->questionHelper->expects($this->once())

integration/PhpSpec/Formatter/Presenter/Differ/ObjectEngineTest.php

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

55
namespace PhpSpec\Formatter\Presenter\Differ;
66

7+
use PHPUnit\Framework\Attributes\Test;
78
use PHPUnit\Framework\TestCase;
89
use SebastianBergmann\Exporter\Exporter;
910

@@ -26,24 +27,28 @@ public function setUp() : void
2627
}
2728

2829
/** @test */
30+
#[Test]
2931
public function it_is_an_differ_engine()
3032
{
3133
self::assertInstanceOf(DifferEngine::class, $this->engine);
3234
}
3335

3436
/** @test */
37+
#[Test]
3538
public function it_does_not_support_scalars()
3639
{
3740
self::assertFalse($this->engine->supports(1, 2));
3841
}
3942

4043
/** @test */
44+
#[Test]
4145
public function it_only_supports_objects()
4246
{
4347
self::assertTrue($this->engine->supports(new \StdClass(), new \StdClass()));
4448
}
4549

4650
/** @test */
51+
#[Test]
4752
public function it_converts_objects_to_string_and_diffs_the_result()
4853
{
4954
$this->stringDiffer->method('compare')

integration/PhpSpec/Loader/StreamWrapperTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PhpSpec\Loader\StreamWrapper;
88
use PhpSpec\Loader\Transformer\InMemoryTypeHintIndex;
99
use PhpSpec\Loader\Transformer\TypeHintRewriter;
10+
use PHPUnit\Framework\Attributes\Test;
1011
use PHPUnit\Framework\TestCase;
1112

1213
class StreamWrapperTest extends TestCase
@@ -23,6 +24,7 @@ function setUp() : void
2324
* @test
2425
* @requires PHP 7.0
2526
*/
27+
#[Test]
2628
function it_loads_a_spec_with_no_typehints()
2729
{
2830
require StreamWrapper::wrapPath(__DIR__.'/examples/ExampleSpec.php');

0 commit comments

Comments
 (0)