MongolidLaravel\MongolidModelTest::testShouldGetFirstOrNew PHP Method

testShouldGetFirstOrNew() public method

    public function testShouldGetFirstOrNew()
    {
        // Set
        $dataMapper = m::mock(DataMapper::class);
        $this->app->instance(DataMapper::class, $dataMapper);
        $model = new class extends MongolidModel
        {
            protected $collection = 'collection_name';
        };
        // Expectations
        $dataMapper->shouldReceive('first')->once()->withAnyArgs()->andReturn($model);
        // Actions
        $result = $model->firstOrNew('123');
        // Assertions
        $this->assertEquals($model, $result);
    }