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

Posted 1 year 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();

        $wrestler->winTitle($title);

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

        $wrestler->loseTitle($title);

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

        Carbon::setTestNow();
}

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

Reply to

Use Markdown with GitHub-flavored code blocks.