Completed
Push — master ( 8cba2b...d3d09e )
by Sergei
17s queued 13s
created

TableDiffTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Schema;
4
5
use Doctrine\DBAL\Platforms\AbstractPlatform;
6
use Doctrine\DBAL\Schema\Identifier;
7
use Doctrine\DBAL\Schema\Table;
8
use Doctrine\DBAL\Schema\TableDiff;
9
use PHPUnit\Framework\MockObject\MockObject;
10
use PHPUnit\Framework\TestCase;
11
12
class TableDiffTest extends TestCase
13
{
14
    /** @var AbstractPlatform|MockObject */
15
    private $platform;
16
17
    public function setUp() : void
18
    {
19
        $this->platform = $this->createMock(AbstractPlatform::class);
20
    }
21
22
    /**
23
     * @group DBAL-1013
24
     */
25
    public function testReturnsName()
26
    {
27
        $tableDiff = new TableDiff('foo');
28
29
        self::assertEquals(new Identifier('foo'), $tableDiff->getName($this->platform));
30
    }
31
32
    /**
33
     * @group DBAL-1016
34
     */
35
    public function testPrefersNameFromTableObject()
36
    {
37
        $tableMock = $this->getMockBuilder(Table::class)
38
            ->disableOriginalConstructor()
39
            ->getMock();
40
41
        $tableDiff            = new TableDiff('foo');
42
        $tableDiff->fromTable = $tableMock;
1 ignored issue
show
Documentation Bug introduced by
It seems like $tableMock of type PHPUnit\Framework\MockObject\MockObject is incompatible with the declared type Doctrine\DBAL\Schema\Table|null of property $fromTable.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
43
44
        $tableMock->expects($this->once())
45
            ->method('getQuotedName')
46
            ->with($this->platform)
47
            ->will($this->returnValue('foo'));
48
49
        self::assertEquals(new Identifier('foo'), $tableDiff->getName($this->platform));
50
    }
51
52
    /**
53
     * @group DBAL-1013
54
     */
55
    public function testReturnsNewName()
56
    {
57
        $tableDiff = new TableDiff('foo');
58
59
        self::assertFalse($tableDiff->getNewName());
60
61
        $tableDiff->newName = 'bar';
62
63
        self::assertEquals(new Identifier('bar'), $tableDiff->getNewName());
64
    }
65
}
66