dillingham / nova-assertions

Laravel Nova assertions for your tests
MIT License
79 stars 16 forks source link

Assert relations callback can be null #14

Closed andresilvagomez closed 4 years ago

dillingham commented 4 years ago

I would assume that the following would assert categories are present

$response->assertRelation('categories')

Im not really clear on this, can you explain more?

andresilvagomez commented 4 years ago

@dillingham Right, the idea is don't check any more, only if that relation should be present !!!

dillingham commented 4 years ago
PHPUnit::assertTrue($callable ? $callable($results) ?? true : true);

Im a little sleepy but at first glance, this looks like it just checks if callable is not null, if it is null assert true is true?

andresilvagomez commented 4 years ago

PHPUnit::assertTrue($callable ? $callable($results) ?? true : true);

$callable ? is present : default = true

if callable is present $callable($results) ?? true

the clousure return a value $callable($results) else asign 'true' by default

andresilvagomez commented 4 years ago
PHPUnit::assertTrue($callable ? $callable($results) ?? true : true);

Im a little sleepy but at first glance, this looks like it just checks if callable is not null, if it is null assert true is true?

the shot answer is true

dillingham commented 4 years ago

Sorry, still not clear why we would assert true == true. Doesnt seem like thats checking if the relation is present.