Completed
Branch testing (7f3043)
by Hennik
05:13
created

BuilderTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 13
c 0
b 0
f 0
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testReturnsCorrectBlueprintForMysql() 0 11 1
A testReturnsCorrectBlueprintForPostgres() 0 11 1
1
<?php
2
3
namespace Schema;
4
5
use BaseTestCase;
6
use LaravelSpatial\MysqlConnection;
7
use LaravelSpatial\PostgresConnection;
8
use LaravelSpatial\Schema\Blueprint;
9
use LaravelSpatial\Schema\Builder;
10
use Mockery;
11
12
class BuilderTest extends BaseTestCase
13
{
14
    public function testReturnsCorrectBlueprintForMysql()
15
    {
16
        $connection = Mockery::mock(MysqlConnection::class);
17
        $connection->shouldReceive('getSchemaGrammar')->once()->andReturn(null);
1 ignored issue
show
Unused Code introduced by
The call to Mockery\MockInterface::shouldReceive() has too many arguments starting with 'getSchemaGrammar'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        $connection->/** @scrutinizer ignore-call */ 
18
                     shouldReceive('getSchemaGrammar')->once()->andReturn(null);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
18
19
        $mock = Mockery::mock(Builder::class, [$connection]);
20
        $mock->makePartial()->shouldAllowMockingProtectedMethods();
21
        $blueprint = $mock->createBlueprint('test', function () {
22
        });
23
24
        $this->assertInstanceOf(Blueprint::class, $blueprint);
25
    }
26
27
    public function testReturnsCorrectBlueprintForPostgres()
28
    {
29
        $connection = Mockery::mock(PostgresConnection::class);
30
        $connection->shouldReceive('getSchemaGrammar')->once()->andReturn(null);
1 ignored issue
show
Unused Code introduced by
The call to Mockery\MockInterface::shouldReceive() has too many arguments starting with 'getSchemaGrammar'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        $connection->/** @scrutinizer ignore-call */ 
31
                     shouldReceive('getSchemaGrammar')->once()->andReturn(null);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
31
32
        $mock = Mockery::mock(Builder::class, [$connection]);
33
        $mock->makePartial()->shouldAllowMockingProtectedMethods();
34
        $blueprint = $mock->createBlueprint('test', function () {
35
        });
36
37
        $this->assertInstanceOf(Blueprint::class, $blueprint);
38
    }
39
}
40