1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace Doctrine\Tests\DBAL\Schema\Visitor;
use \Doctrine\DBAL\Schema\Visitor\CreateSchemaSqlCollector;
class CreateSchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase
{
public function testGetQueriesForPsql()
{
$platformMock = $this->getMock(
'Doctrine\DBAL\Platforms\PostgreSqlPlatform',
array('supportsSchemas', 'schemaNeedsCreation', 'getCreateTableSQL')
);
$platformMock->expects($this->any())
->method('supportsSchemas')
->will($this->returnValue(true));
$platformMock->expects($this->any())
->method('schemaNeedsCreation')
->will($this->returnValue(true));
$platformMock->expects($this->any())
->method('getCreateTableSQL')
->will($this->returnValue(array('foo')));
$tableMock = $this->getMockBuilder('\Doctrine\DBAL\Schema\Table')
->disableOriginalConstructor()
->getMock();
$sqlCollector = new CreateSchemaSqlCollector($platformMock);
$sqlCollector->acceptTable($tableMock);
$sql = $sqlCollector->getQueries();
$this->assertEquals('CREATE SCHEMA public', $sql[0]);
}
}