Passed
Pull Request — master (#3)
by Simon
06:31
created

SearchQueryTest::testAddSearchTerm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 15
rs 10
1
<?php
2
3
4
namespace Firesphere\SolrSearch\Compat\Tests;
5
6
7
use SilverStripe\Dev\Debug;
8
use SilverStripe\Dev\SapphireTest;
9
use SilverStripe\FullTextSearch\Search\Queries\SearchQuery;
10
11
class SearchQueryTest extends SapphireTest
12
{
13
14
    public function testAddSearchTerm()
15
    {
16
        $query = new SearchQuery();
17
        $query = $query->addSearchTerm('Test term', [], 2);
0 ignored issues
show
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

17
        $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...
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

17
        $query = $query->addSearchTerm('Test term', [], /** @scrutinizer ignore-type */ 2);
Loading history...
18
19
        $expected = [
20
            'text'   => 'Test term',
21
            'fields' =>
22
                [
23
                ],
24
            'boost'  => 2,
25
            'fuzzy'  => null,
26
        ];
27
28
        $this->assertEquals($expected, $query->getTerms());
29
    }
30
31
    public function testLimits()
32
    {
33
        $query = new SearchQuery();
34
35
        $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

35
        /** @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...
36
37
        $this->assertEquals(5, $query->getRows());
38
        $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

38
        $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...
39
    }
40
}