|
13 | 13 | class IncrementCommandTest extends TestCase |
14 | 14 | { |
15 | 15 | private Commander $commander; |
| 16 | + private CommandTester $tester; |
16 | 17 |
|
17 | 18 | public function setUp(): void |
18 | 19 | { |
19 | 20 | parent::setUp(); |
20 | 21 |
|
21 | 22 | $this->commander = new Commander(); |
| 23 | + $this->tester = new CommandTester($this->commander->get('increment')); |
22 | 24 | } |
23 | 25 |
|
24 | 26 | /** @dataProvider dataInvalidVersionArgument */ |
25 | 27 | public function testInvalidVersionArgument(string $version): void |
26 | 28 | { |
27 | | - $tester = new CommandTester($this->commander->get('increment')); |
28 | | - $tester->execute(['version' => $version]); |
| 29 | + $this->tester->execute(['version' => $version]); |
29 | 30 |
|
30 | 31 | self::assertStringContainsString( |
31 | 32 | sprintf("[ERROR] Version string '%s' is not valid and cannot be parsed", $version), |
32 | | - $tester->getDisplay(), |
| 33 | + $this->tester->getDisplay(), |
33 | 34 | ); |
34 | 35 | } |
35 | 36 |
|
36 | 37 | public function testIncrementPatch(): void |
37 | 38 | { |
38 | | - $tester = new CommandTester($this->commander->get('increment')); |
39 | | - $tester->execute(['version' => '1.0.0']); |
| 39 | + $this->tester->execute(['version' => '1.0.0']); |
40 | 40 |
|
41 | | - self::assertStringContainsString('1.0.1', $tester->getDisplay()); |
| 41 | + self::assertStringContainsString( |
| 42 | + '1.0.1', |
| 43 | + $this->tester->getDisplay(), |
| 44 | + ); |
42 | 45 | } |
43 | 46 |
|
44 | 47 | public function testIncrementMinor(): void |
45 | 48 | { |
46 | | - $tester = new CommandTester($this->commander->get('increment')); |
47 | | - $tester->execute(['version' => '1.0.0', '--part' => 'minor']); |
| 49 | + $this->tester->execute(['version' => '1.0.0', '--part' => 'minor']); |
48 | 50 |
|
49 | | - self::assertStringContainsString('1.1.0', $tester->getDisplay()); |
| 51 | + self::assertStringContainsString( |
| 52 | + '1.1.0', |
| 53 | + $this->tester->getDisplay(), |
| 54 | + ); |
50 | 55 | } |
51 | 56 |
|
52 | 57 | public function testIncrementMajor(): void |
53 | 58 | { |
54 | | - $tester = new CommandTester($this->commander->get('increment')); |
55 | | - $tester->execute(['version' => '1.0.0', '--part' => 'major']); |
| 59 | + $this->tester->execute(['version' => '1.0.0', '--part' => 'major']); |
56 | 60 |
|
57 | | - self::assertStringContainsString('2.0.0', $tester->getDisplay()); |
| 61 | + self::assertStringContainsString( |
| 62 | + '2.0.0', |
| 63 | + $this->tester->getDisplay(), |
| 64 | + ); |
58 | 65 | } |
59 | 66 |
|
60 | 67 | public function testIncrementWithBuildMetadata(): void |
61 | 68 | { |
62 | | - $tester = new CommandTester($this->commander->get('increment')); |
63 | | - $tester->execute(['version' => '1.0.0', '--build' => '123']); |
| 69 | + $this->tester->execute(['version' => '1.0.0', '--build' => '123']); |
64 | 70 |
|
65 | | - self::assertStringContainsString('1.0.1+123', $tester->getDisplay()); |
| 71 | + self::assertStringContainsString( |
| 72 | + '1.0.1+123', |
| 73 | + $this->tester->getDisplay(), |
| 74 | + ); |
66 | 75 | } |
67 | 76 |
|
68 | 77 | public function testIncrementWithPreRelease(): void |
69 | 78 | { |
70 | | - $tester = new CommandTester($this->commander->get('increment')); |
71 | | - $tester->execute(['version' => '1.0.0', '--pre' => 'beta']); |
| 79 | + $this->tester->execute(['version' => '1.0.0', '--pre' => 'beta']); |
72 | 80 |
|
73 | | - self::assertStringContainsString('1.0.1-beta', $tester->getDisplay()); |
| 81 | + self::assertStringContainsString( |
| 82 | + '1.0.1-beta', |
| 83 | + $this->tester->getDisplay(), |
| 84 | + ); |
74 | 85 | } |
75 | 86 |
|
76 | 87 | public static function dataInvalidVersionArgument(): iterable |
|
0 commit comments