Completed
Push — master ( c7757e...39cb21 )
by Luís
16s
created

StatementTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 62.79 %

Importance

Changes 0
Metric Value
wmc 5
dl 27
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testNonPersistentStatement() 13 13 1
A setUp() 0 10 3
A testPersistentStatement() 13 13 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Doctrine\Tests\DBAL\Functional\Driver\SQLAnywhere;
4
5
use Doctrine\DBAL\Driver\SQLAnywhere\Driver;
6
use Doctrine\DBAL\DriverManager;
7
8
class StatementTest extends \Doctrine\Tests\DbalFunctionalTestCase
9
{
10
    protected function setUp()
11
    {
12
        if (! extension_loaded('sqlanywhere')) {
13
            $this->markTestSkipped('sqlanywhere is not installed.');
14
        }
15
16
        parent::setUp();
17
18
        if (! $this->_conn->getDriver() instanceof Driver) {
19
            $this->markTestSkipped('sqlanywhere only test.');
20
        }
21
    }
22
23 View Code Duplication
    public function testNonPersistentStatement()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
    {
25
        $params = $this->_conn->getParams();
26
        $params['persistent'] = false;
27
28
        $conn = DriverManager::getConnection($params);
29
30
        $conn->connect();
31
32
        self::assertTrue($conn->isConnected(),'No SQLAnywhere-Connection established');
33
34
        $prepStmt = $conn->prepare('SELECT 1');
35
        self::assertTrue($prepStmt->execute(),' Statement non-persistent failed');
36
    }
37
38 View Code Duplication
    public function testPersistentStatement()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
    {
40
        $params = $this->_conn->getParams();
41
        $params['persistent'] = true;
42
43
        $conn = DriverManager::getConnection($params);
44
45
        $conn->connect();
46
47
        self::assertTrue($conn->isConnected(),'No SQLAnywhere-Connection established');
48
49
        $prepStmt = $conn->prepare('SELECT 1');
50
        self::assertTrue($prepStmt->execute(),' Statement persistent failed');
51
    }
52
53
}
54