Completed
Push — b/update_guzzle ( 16f2fc...3512e8 )
by
unknown
07:47
created

AbstractIntegrationTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 37
wmc 5
lcom 1
cbo 2
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 4 1
A setUp() 0 9 1
A insertRow() 0 5 1
A insertRows() 0 8 2
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 CrateIntegrationTest\PDO;
24
25
use Crate\PDO\PDO;
26
use PHPUnit_Framework_TestCase;
27
28
abstract class AbstractIntegrationTest extends PHPUnit_Framework_TestCase
29
{
30
    /**
31
     * @var PDO
32
     */
33
    protected $pdo;
34
35
    protected function setUp()
36
    {
37
        $this->pdo = new PDO('crate:localhost:4200', null, null, []);
38
        $query = 'CREATE TABLE test_table (id INTEGER PRIMARY KEY, name STRING,';
39
        $query .= 'int_type INTEGER, long_type LONG, boolean_type BOOLEAN,';
40
        $query .= 'double_type DOUBLE, float_type FLOAT, array_type ARRAY(INTEGER),';
41
        $query .= 'object_type OBJECT) CLUSTERED INTO 1 SHARDS WITH (number_of_replicas = 0)';
42
        $this->pdo->query($query);
43
    }
44
45
    protected function tearDown()
46
    {
47
        $this->pdo->query('DROP TABLE test_table');
48
    }
49
50
    protected function insertRows($count = 1)
51
    {
52
        for ($i = 1; $i <= $count; $i++) {
53
            $this->pdo->exec(sprintf("INSERT INTO test_table (id, name) VALUES (%d, 'hello world')", $i));
54
        }
55
56
        $this->pdo->query('refresh table test_table');
57
    }
58
59
    protected function insertRow($id, $name)
60
    {
61
        $this->pdo->exec(sprintf("INSERT INTO test_table (id, name) VALUES (%d, '%s')", $id, $name));
62
        $this->pdo->query('refresh table test_table');
63
    }
64
}
65