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; |
|
|
|
|
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
|
|
|
|
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..