Skip to content

Commit a609052

Browse files
committed
Roave#66 Roave#72 Roave#73 segregating class versions in e2e tests into a private array const
1 parent 5768cb1 commit a609052

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

test/e2e/Command/AssertBackwardsCompatibleTest.php

+16-13
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ final class AssertBackwardsCompatibleTest extends TestCase
2828

2929
JSON;
3030

31-
private const CLASS_V1 = <<<'PHP'
31+
private const CLASS_VERSIONS = [
32+
<<<'PHP'
3233
<?php
3334
3435
namespace TestArtifact;
@@ -40,9 +41,9 @@ public function method(A $a)
4041
}
4142
}
4243

43-
PHP;
44-
45-
private const CLASS_V2 = <<<'PHP'
44+
PHP
45+
,
46+
<<<'PHP'
4647
<?php
4748
4849
namespace TestArtifact;
@@ -54,9 +55,9 @@ public function method(B $a)
5455
}
5556
}
5657

57-
PHP;
58-
59-
private const CLASS_V3 = <<<'PHP'
58+
PHP
59+
,
60+
<<<'PHP'
6061
<?php
6162
6263
namespace TestArtifact;
@@ -68,9 +69,10 @@ public function method(C $a)
6869
}
6970
}
7071

71-
PHP;
72-
73-
private const CLASS_V4 = <<<'PHP'
72+
PHP
73+
,
74+
// The last version resets the class to its initial state
75+
<<<'PHP'
7476
<?php
7577
7678
namespace TestArtifact;
@@ -82,7 +84,8 @@ public function method(A $a)
8284
}
8385
}
8486

85-
PHP;
87+
PHP
88+
];
8689

8790
/** @var string path to the sources that should be checked */
8891
private $sourcesRepository;
@@ -114,7 +117,7 @@ protected function setUp() : void
114117
(new Process('git add -A', $this->sourcesRepository))->mustRun();
115118
(new Process('git commit -am "Initial commit with composer manifest"', $this->sourcesRepository))->mustRun();
116119

117-
foreach ([self::CLASS_V1, self::CLASS_V2, self::CLASS_V3, self::CLASS_V4] as $key => $classCode) {
120+
foreach (self::CLASS_VERSIONS as $key => $classCode) {
118121
file_put_contents($this->sourcesRepository . '/src/TheClass.php', $classCode);
119122

120123
(new Process('git add -A', $this->sourcesRepository))->mustRun();
@@ -131,7 +134,7 @@ protected function tearDown() : void
131134
self::assertDirectoryExists($this->sourcesRepository);
132135

133136
// Need to be extremely careful with this stuff - skipping it for now
134-
// (new Process(['rm', '-r', $this->sourcesRepository]))->mustRun();
137+
(new Process(['rm', '-r', $this->sourcesRepository]))->mustRun();
135138

136139
parent::tearDown();
137140
}

0 commit comments

Comments
 (0)