Testing touches with more performance

Posted 6 months ago by fabricecw

Hi

I'm testing touches with the sleep function:

CommentTest:

/** @test  */
    public function it_touches_the_orders_timestamp()
    {
        $order = factory('App\Order')->create();

        sleep(1);

        $comment = $order->comments()->create(factory(OrderComment::class)->raw());

        $this->assertEquals($order->fresh()->updated_at, $comment->updated_at);
    }

But this means heavy time consumptions. Is there a way to "mock" the time?

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