Skip to content

Commit

Permalink
Added dummy enum declaration to conditionally include in test.
Browse files Browse the repository at this point in the history
  • Loading branch information
gordinskiy committed Oct 23, 2024
1 parent 8144e25 commit 137f51b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
17 changes: 6 additions & 11 deletions tests/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,10 +836,14 @@ public function testResourceOfTypeCustomMessage(): void

public function testEnumAssertionErrorMessage(): void
{
if (PHP_VERSION_ID < ENUM_INTRODUCTION_VERSION_ID) {
$this->markTestSkipped(sprintf('This test requires php %s or upper.', ENUM_INTRODUCTION_VERSION_ID));
$enumIntroductionVersion = 80100;

if (PHP_VERSION_ID < $enumIntroductionVersion) {
$this->markTestSkipped(sprintf('This test requires php %s or upper.', $enumIntroductionVersion));
}

require_once 'DummyEnum.php';

$this->expectException('\InvalidArgumentException');
$this->expectExceptionMessage('Expected null. Got: Webmozart\Assert\Tests\TestEnum::CaseName');

Expand Down Expand Up @@ -867,12 +871,3 @@ public function __toString()
return $this->value;
}
}

const ENUM_INTRODUCTION_VERSION_ID = 80100;

if (PHP_VERSION_ID >= ENUM_INTRODUCTION_VERSION_ID) {
enum TestEnum
{
case CaseName;
}
}
9 changes: 9 additions & 0 deletions tests/DummyEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Webmozart\Assert\Tests;

// The filename must be different from the class name to be ignored by composer PSR-4 autoloading rules
enum TestEnum
{
case CaseName;
}

0 comments on commit 137f51b

Please sign in to comment.