Skip to content

Commit 56549a8

Browse files
authored
Merge pull request #16 from ABGEO07/bugfix/old-phpunit-asserts
Bugfix/old phpunit asserts
2 parents c93a50a + c129528 commit 56549a8

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

src/Context/JsonApiContext.php

Lines changed: 25 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
/**
@@ -556,12 +564,14 @@ public function thePropertyIsAStringEqualing($property, $expected)
556564
public function thePropertyIsABoolean($property)
557565
{
558566
$payload = $this->getScopePayload();
567+
$actual = $this->arrayGet($payload, $property);
568+
$message = sprintf("Asserting the [%s] property in current scope [%s] is a boolean", $property, $this->scope);
559569

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-
);
570+
if (method_exists(PHPUnit::class, 'assertInternalType')) {
571+
PHPUnit::assertInternalType('boolean', $this->arrayGet($payload, $property), $message);
572+
} else {
573+
PHPUnit::assertIsBool($actual, $message);
574+
}
565575
}
566576

567577
/**

0 commit comments

Comments
 (0)