How do I assert the result is an integer in PHPUnit?
I prefer using the official PHPUnit class constants.
PHPUnit v5.2:
use PHPUnit_Framework_Constraint_IsType as PHPUnit_IsType;// ...$this->assertInternalType(PHPUnit_IsType::TYPE_INT, $new_id);
Or latest which at the moment of writing is v7.0:
use PHPUnit\Framework\Constraint\IsType;// ...$this->assertInternalType(IsType::TYPE_INT, $new_id);
Original answer is given below for posterity, but I would strongly recommend using assertInternalType()
as suggested in other answers.
Original answer:
Simply use assertTrue with is_int().
$this->assertTrue(is_int($new_id));