ErrorHandlingInQueriesTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testResultVariableNotUsedInQuery() 0 25 1
A setUp() 0 5 1
1
<?php
2
3
/**
4
 * This file is part of the sweetrdf/InMemoryStoreSqlite package and licensed under
5
 * the terms of the GPL-2 license.
6
 *
7
 * (c) Konrad Abicht <[email protected]>
8
 * (c) Benjamin Nowack
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Tests\Integration\Store\InMemoryStoreSqlite\Query;
15
16
use sweetrdf\InMemoryStoreSqlite\Store\InMemoryStoreSqlite;
17
use Tests\TestCase;
18
19
/**
20
 * Tests for query method - focus on how the system reacts, when errors occur.
21
 */
22
class ErrorHandlingInQueriesTest extends TestCase
23
{
24
    protected function setUp(): void
25
    {
26
        parent::setUp();
27
28
        $this->subjectUnderTest = InMemoryStoreSqlite::createInstance();
29
    }
30
31
    /**
32
     * What if a result variable is not used in query.
33
     */
34
    public function testResultVariableNotUsedInQuery()
35
    {
36
        $res = $this->subjectUnderTest->query('
37
            SELECT ?not_used_in_query ?s WHERE {
38
                ?s ?p ?o .
39
            }
40
        ');
41
42
        $this->assertEquals(
43
            [
44
                'query_type' => 'select',
45
                'result' => [
46
                    'variables' => [
47
                        'not_used_in_query', 's',
48
                    ],
49
                    'rows' => [
50
                    ],
51
                ],
52
            ],
53
            $res
54
        );
55
56
        // TODO not bad if count is higher than 2
57
        $errors = \count($this->subjectUnderTest->getLoggerPool()->getEntriesFromAllLoggerInstances());
58
        $this->assertEquals(2, $errors);
59
    }
60
}
61