Passed
Pull Request — main (#109)
by Andreas
02:00
created

MapTypeTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
eloc 14
c 1
b 0
f 1
dl 0
loc 21
rs 10
1
<?php
2
/**
3
 * Licensed to CRATE Technology GmbH("Crate") under one or more contributor
4
 * license agreements.  See the NOTICE file distributed with this work for
5
 * additional information regarding copyright ownership.  Crate licenses
6
 * this file to you under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.  You may
8
 * obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
15
 * License for the specific language governing permissions and limitations
16
 * under the License.
17
 *
18
 * However, if you have executed another commercial license agreement
19
 * with Crate these terms will supersede the license and you may use the
20
 * software solely pursuant to the terms of the relevant commercial agreement.
21
 */
22
23
namespace Crate\Test\DBAL\Functional\Types;
24
25
26
use Crate\DBAL\Platforms\CratePlatform;
27
use Crate\DBAL\Types\MapType;
28
use Crate\Test\DBAL\DBALFunctionalTestCase;
29
use Doctrine\DBAL\Schema\Column;
30
use Doctrine\DBAL\Schema\Table;
31
use Doctrine\DBAL\Types\Type;
32
33
class MapTypeTest extends DBALFunctionalTestCase {
34
35
    public function testStrictMapTableCreationWithSchemaManager() {
36
        $platform = $this->_conn->getDatabasePlatform();
37
38
        $table = new Table('items');
39
        $objDefinition = array(
40
            'type' => MapType::STRICT,
41
            'fields' => array(
42
                new Column('id',  Type::getType(Type::INTEGER), array()),
43
                new Column('name',  Type::getType(Type::STRING), array()),
44
            ),
45
        );
46
        $table->addColumn(
47
            'object_column', MapType::NAME,
48
            array('platformOptions' => $objDefinition)
49
        );
50
51
        $createFlags = CratePlatform::CREATE_INDEXES|CratePlatform::CREATE_FOREIGNKEYS;
52
        $sql = $platform->getCreateTableSQL($table, $createFlags);
53
        $this->assertEquals(array('CREATE TABLE items (object_column OBJECT ( strict ) AS ( id INTEGER, name TEXT ))'), $sql);
54
    }
55
56
}