Skip to content

Commit 20b5eea

Browse files
committed
♻️ Update PHPUnit asserts.
1 parent c93a50a commit 20b5eea

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

src/Context/JsonApiContext.php

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -474,12 +474,18 @@ public function thePropertyIsAnEmptyArray($property)
474474
public function thePropertyIsAnInteger($property)
475475
{
476476
$payload = $this->getScopePayload();
477-
478-
PHPUnit::assertInternalType(
479-
'int',
480-
$this->arrayGet($payload, $property),
481-
sprintf("Asserting the [%s] property in current scope [%s] is an integer", $property, $this->scope)
477+
$actual = $this->arrayGet($payload, $property);
478+
$message = sprintf(
479+
"Asserting the [%s] property in current scope [%s] is an integer",
480+
$property,
481+
$this->scope
482482
);
483+
484+
if (method_exists(PHPUnit::class, 'assertInternalType')) {
485+
PHPUnit::assertInternalType('int', $actual, $message);
486+
} else {
487+
PHPUnit::assertIsInt($actual, $message);
488+
}
483489
}
484490

485491
/**
@@ -515,12 +521,14 @@ public function thePropertyIsAIntegerEqualing($property, $expected)
515521
public function thePropertyIsAString($property)
516522
{
517523
$payload = $this->getScopePayload();
524+
$actual = $this->arrayGet($payload, $property);
525+
$message = sprintf("Asserting the [%s] property in current scope [%s] is a string", $property, $this->scope);
518526

519-
PHPUnit::assertInternalType(
520-
'string',
521-
$this->arrayGet($payload, $property),
522-
sprintf("Asserting the [%s] property in current scope [%s] is a string", $property, $this->scope)
523-
);
527+
if (method_exists(PHPUnit::class, 'assertInternalType')) {
528+
PHPUnit::assertInternalType('string', $actual, $message);
529+
} else {
530+
PHPUnit::assertIsString($actual, $message);
531+
}
524532
}
525533

526534
/**
@@ -557,11 +565,15 @@ public function thePropertyIsABoolean($property)
557565
{
558566
$payload = $this->getScopePayload();
559567

560-
PHPUnit::assertInternalType(
561-
'boolean',
562-
$this->arrayGet($payload, $property),
563-
sprintf("Asserting the [%s] property in current scope [%s] is a boolean", $property, $this->scope)
564-
);
568+
$actual = $this->arrayGet($payload, $property);
569+
$message = sprintf("Asserting the [%s] property in current scope [%s] is a boolean", $property, $this->scope);
570+
571+
if (method_exists(PHPUnit::class, 'assertInternalType')) {
572+
PHPUnit::assertInternalType('boolean', $this->arrayGet($payload, $property), $message);
573+
} else {
574+
PHPUnit::assertIsBool($actual, $message);
575+
}
576+
565577
}
566578

567579
/**

0 commit comments

Comments
 (0)