I'm trying to leverage the assertRecordExists functionality and i'm not getting consistent results.
the base code looks like:
When i test a record that exists, it functions correctly.
When i test a record that doesn't exist, it throws an exception:
224 is the assertRecordExists line.
Which makes sense as $x is null when the record can't be found in the database. But, then I can't see the correct usage of this assertion as it must not fail with an exception if the record doesn't exist, right? as that's kind of the whole point of this functionality in the first place.
the base code looks like:
Code:
$finder->where('x', $params['slug']);
$x= $finder->fetchOne();
$x= $this->assertRecordExists('NS\Addon:X', $x['id'], null, null);
if(!$x)
{
throw $this->exception($this->notFound('X Not Found in our Database'));
}
When i test a record that exists, it functions correctly.
When i test a record that doesn't exist, it throws an exception:
Code:
ErrorException: [E_WARNING] Trying to access array offset on value of type null in src\addons\NS\Addon\Pub\Controller\MyController.php at line 224
224 is the assertRecordExists line.
Which makes sense as $x is null when the record can't be found in the database. But, then I can't see the correct usage of this assertion as it must not fail with an exception if the record doesn't exist, right? as that's kind of the whole point of this functionality in the first place.