DescribeQueryTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 33
c 1
b 0
f 0
dl 0
loc 84
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testDescribeDefaultGraph() 0 23 1
A testDescribeWhereDefaultGraph() 0 23 1
A testDescribeWhereDefaultGraph2() 0 23 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 DESCRIBE queries.
21
 */
22
class DescribeQueryTest extends TestCase
23
{
24
    protected function setUp(): void
25
    {
26
        parent::setUp();
27
28
        $this->subjectUnderTest = InMemoryStoreSqlite::createInstance();
29
    }
30
31
    public function testDescribeDefaultGraph()
32
    {
33
        // test data
34
        $this->subjectUnderTest->query('INSERT INTO <http://example.com/> {
35
            <http://s> <http://p1> "baz" .
36
        }');
37
38
        $res = $this->subjectUnderTest->query('DESCRIBE <http://s>');
39
        $this->assertEquals(
40
            [
41
                'query_type' => 'describe',
42
                'result' => [
43
                    'http://s' => [
44
                        'http://p1' => [
45
                            [
46
                                'value' => 'baz',
47
                                'type' => 'literal',
48
                            ],
49
                        ],
50
                    ],
51
                ],
52
            ],
53
            $res
54
        );
55
    }
56
57
    public function testDescribeWhereDefaultGraph()
58
    {
59
        // test data
60
        $this->subjectUnderTest->query('INSERT INTO <http://example.com/> {
61
            <http://s> <http://p1> "baz" .
62
        }');
63
64
        $res = $this->subjectUnderTest->query('DESCRIBE ?s WHERE {?s ?p "baz".}');
65
        $this->assertEquals(
66
            [
67
                'query_type' => 'describe',
68
                'result' => [
69
                    'http://s' => [
70
                        'http://p1' => [
71
                            [
72
                                'value' => 'baz',
73
                                'type' => 'literal',
74
                            ],
75
                        ],
76
                    ],
77
                ],
78
            ],
79
            $res
80
        );
81
    }
82
83
    public function testDescribeWhereDefaultGraph2()
84
    {
85
        // test data
86
        $this->subjectUnderTest->query('INSERT INTO <http://example.com/> {
87
            <http://s> <http://p1> "baz" .
88
        }');
89
90
        $res = $this->subjectUnderTest->query('DESCRIBE * WHERE {?s ?p "baz".}');
91
        $this->assertEquals(
92
            [
93
                'query_type' => 'describe',
94
                'result' => [
95
                    'http://s' => [
96
                        'http://p1' => [
97
                            [
98
                                'value' => 'baz',
99
                                'type' => 'literal',
100
                            ],
101
                        ],
102
                    ],
103
                ],
104
            ],
105
            $res
106
        );
107
    }
108
}
109