How to test for a not null value for a object property

Posted 2 years ago by xtremer360

I'm trying to figure out what the assertion should look like because I want to test to see that the title that was lost has a value of a timestamp or in this case not null because its a datetime field. Keep in mind that there can be previous times that a wrestler has held a the same title before I just want to make sure that the last time has a value of not null. I hope this makes sense. I just know that my assertion isn't written correctly.

/** @test * */
public function can_lose_a_title()
        $wrestler = factory(Wrestler::class)->create();
        $title = factory(Title::class)->create();


        Carbon::setTestNow(Carbon::parse('+1 day'));


        $this->assertNotEquals($wrestler->titles->last()->lost_on, 'NULL');


Please sign in or create an account to participate in this conversation.