1 | <?php |
||
2 | |||
3 | |||
4 | namespace Firesphere\SolrCompatibility\Tests; |
||
5 | |||
6 | use Firesphere\SolrCompatibility\Extensions\FulltextSearchExtension; |
||
7 | use Firesphere\SolrSearch\Indexes\BaseIndex; |
||
8 | use Firesphere\SolrSearch\Queries\BaseQuery; |
||
9 | use Firesphere\SolrSearch\Tasks\SolrConfigureTask; |
||
10 | use Firesphere\SolrSearch\Tests\TestIndex; |
||
11 | use Psr\Log\NullLogger; |
||
12 | use SilverStripe\Control\NullHTTPRequest; |
||
13 | use SilverStripe\Core\Injector\Injector; |
||
14 | use SilverStripe\Dev\SapphireTest; |
||
15 | use SilverStripe\View\ArrayData; |
||
16 | |||
17 | class FulltextSearchExtensionTest extends SapphireTest |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * @var BaseIndex |
||
22 | */ |
||
23 | protected $index; |
||
24 | |||
25 | public function testSearch() |
||
26 | { |
||
27 | $query = new BaseQuery(); |
||
28 | $query->addTerm('Test'); |
||
29 | |||
30 | $result = $this->index->search($query, 0, 10, [], true); |
||
31 | |||
32 | $this->assertInstanceOf(ArrayData::class, $result); |
||
33 | } |
||
34 | |||
35 | public function testSearchWithFields() |
||
36 | { |
||
37 | $query = new BaseQuery(); |
||
38 | $query->addTerm('Test'); |
||
39 | |||
40 | $result = $this->index->search($query, 0, 10, ['fq' => 'Title'], true); |
||
41 | |||
42 | $this->assertInstanceOf(ArrayData::class, $result); |
||
43 | |||
44 | $this->assertEquals(['Title'], $query->getFields()); |
||
45 | } |
||
46 | |||
47 | public function testAddFulltextFields() |
||
48 | { |
||
49 | $index = new TestIndex(); |
||
50 | $index2 = new TestIndex(); |
||
51 | |||
52 | $extension1 = new FulltextSearchExtension(); |
||
53 | $extension1->setOwner($index); |
||
54 | |||
55 | $this->assertEquals($extension1->addFulltextFields(), $index2->addAllFulltextFields()); |
||
0 ignored issues
–
show
Are you sure the usage of
$extension1->addFulltextFields() targeting Firesphere\SolrCompatibi...on::addFulltextFields() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() Are you sure the usage of
$index2->addAllFulltextFields() targeting Firesphere\SolrSearch\In...:addAllFulltextFields() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @expectedException \LogicException |
||
60 | */ |
||
61 | public function testInitToYml() |
||
62 | { |
||
63 | $this->index->initToYml(); |
||
64 | } |
||
65 | |||
66 | |||
67 | protected function setUp() |
||
68 | { |
||
69 | $task = new SolrConfigureTask(); |
||
70 | $task->setLogger(new NullLogger()); |
||
71 | $task->run(new NullHTTPRequest()); |
||
72 | |||
73 | $this->index = Injector::inst()->get(TestIndex::class, false); |
||
74 | |||
75 | parent::setUp(); |
||
76 | } |
||
77 | } |
||
78 |
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.