Mongolid\ActiveRecordTest::testShouldInsert PHP Method

testShouldInsert() public method

public testShouldInsert ( )
    public function testShouldInsert()
    {
        // Arrage
        $entity = m::mock(ActiveRecord::class . '[getDataMapper,getCollectionName,syncOriginalAttributes]');
        $dataMapper = m::mock();
        // Act
        $entity->shouldReceive('getDataMapper')->andReturn($dataMapper);
        $entity->shouldReceive('getCollectionName')->andReturn('mongolid');
        $entity->shouldReceive('syncOriginalAttributes')->once();
        $dataMapper->shouldReceive('insert')->once()->with($entity, ['writeConcern' => new WriteConcern(1)])->andReturn(true);
        // Assert
        $this->assertTrue($entity->insert());
    }