Passed
Pull Request — master (#3)
by Simon
07:48 queued 01:17
created

SearchQueryTest::testAddSearchTerm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 3
b 0
f 0
nc 1
nop 0
dl 0
loc 17
rs 10
1
<?php
2
3
4
namespace Firesphere\SolrSearch\Compat\Tests;
5
6
7
use SilverStripe\Dev\SapphireTest;
8
use SilverStripe\FullTextSearch\Search\Queries\SearchQuery;
9
10
class SearchQueryTest extends SapphireTest
11
{
12
13
    public function testAddSearchTerm()
14
    {
15
        $query = new SearchQuery();
16
        $query = $query->addSearchTerm('Test term', [], 2);
0 ignored issues
show
Bug introduced by
2 of type integer is incompatible with the type array expected by parameter $boost of SilverStripe\FullTextSea...hQuery::addSearchTerm(). ( Ignorable by Annotation )

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

16
        $query = $query->addSearchTerm('Test term', [], /** @scrutinizer ignore-type */ 2);
Loading history...
Deprecated Code introduced by
The function SilverStripe\FullTextSea...hQuery::addSearchTerm() has been deprecated: please use {@link self::addTerm()} ( Ignorable by Annotation )

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

16
        $query = /** @scrutinizer ignore-deprecated */ $query->addSearchTerm('Test term', [], 2);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
17
18
        $expected = [
19
            [
20
                'text'   => 'Test term',
21
                'fields' =>
22
                    [
23
                    ],
24
                'boost'  => 2,
25
                'fuzzy'  => null,
26
            ]
27
        ];
28
29
        $this->assertEquals($expected, $query->getTerms());
30
    }
31
32
    public function testLimits()
33
    {
34
        $query = new SearchQuery();
35
36
        $query->setLimit(5);
0 ignored issues
show
Deprecated Code introduced by
The function SilverStripe\FullTextSea...SearchQuery::setLimit() has been deprecated: please use {@link self::setRows()} ( Ignorable by Annotation )

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

36
        /** @scrutinizer ignore-deprecated */ $query->setLimit(5);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
37
38
        $this->assertEquals(5, $query->getRows());
39
        $this->assertEquals(5, $query->getLimit());
0 ignored issues
show
Deprecated Code introduced by
The function SilverStripe\FullTextSea...SearchQuery::getLimit() has been deprecated: please use {@link self::getRows()} ( Ignorable by Annotation )

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

39
        $this->assertEquals(5, /** @scrutinizer ignore-deprecated */ $query->getLimit());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
40
    }
41
}