Elasticsearch7QueryTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 81.25%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
c 2
b 0
f 0
dl 0
loc 27
ccs 13
cts 16
cp 0.8125
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testFromNativeWithStringQuery() 0 5 1
A testFromNativeWithNullQuery() 0 5 1
A testFromNativeWithEmpty() 0 4 1
A testToNative() 0 5 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/elasticsearch7-adapter project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Daikon\Tests\Elasticsearch7\Query;
10
11
use Daikon\Elasticsearch7\Query\Elasticsearch7Query;
12
use Daikon\Interop\InvalidArgumentException;
13
use PHPUnit\Framework\TestCase;
14
15
final class Elasticsearch7QueryTest extends TestCase
16
{
17 1
    public function testFromNativeWithNullQuery(): void
18
    {
19 1
        $this->expectException(InvalidArgumentException::class);
20
        /** @psalm-suppress NullArgument */
21 1
        Elasticsearch7Query::fromNative(null);
22
    }
23
24 1
    public function testFromNativeWithStringQuery(): void
25
    {
26 1
        $this->expectException(InvalidArgumentException::class);
27
        /** @psalm-suppress InvalidArgument */
28 1
        Elasticsearch7Query::fromNative('query');
0 ignored issues
show
Bug introduced by
'query' of type string is incompatible with the type array expected by parameter $query of Daikon\Elasticsearch7\Qu...rch7Query::fromNative(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

28
        Elasticsearch7Query::fromNative(/** @scrutinizer ignore-type */ 'query');
Loading history...
29
    }
30
31 1
    public function testFromNativeWithEmpty(): void
32
    {
33 1
        $this->expectException(InvalidArgumentException::class);
34 1
        Elasticsearch7Query::fromNative([]);
35
    }
36
37 1
    public function testToNative(): void
38
    {
39 1
        $payload = ['term' => 'value'];
40 1
        $query = Elasticsearch7Query::fromNative($payload);
41 1
        $this->assertEquals($payload, $query->toNative());
42 1
    }
43
}
44