Skip to content

Commit 3545831

Browse files
committed
Add a test to check that removing types doesn't crash
1 parent 78d7747 commit 3545831

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

test/Exercise/PhpGetsAPromotionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ public function testFailureIfPropertiesChangeType(): void
9393
$this->assertResultsHasFailure(Failure::class, 'Property "key" should not have changed type');
9494
}
9595

96+
public function testFailureIfPropertiesTypeRemoved(): void
97+
{
98+
$this->runExercise('solution-type-removed.php');
99+
100+
$this->assertVerifyWasNotSuccessful();
101+
102+
$this->assertResultsHasFailure(Failure::class, 'Properties "key" & "basePath" should not have changed type');
103+
}
104+
96105
public function testFailureIfPropertyDataIncorrect(): void
97106
{
98107
$this->runExercise('solution-data-not-set.php');

test/solutions/php-gets-a-promotion/solution-type-removed.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
class RowVisitorTypeMutated
3+
class RowVisitorTypeRemoved
44
{
5-
protected string $basePath;
5+
protected $basePath;
66

77
public function __construct(
88
private \Closure $visitor,
9-
private \Stringable $key,
9+
private $key,
1010
array $config = []
1111
) {
1212
$this->basePath = $config['basePath'] ?? '';

0 commit comments

Comments
 (0)