Passed
Push — master ( 294dce...275467 )
by Simon
10:06
created

BaseIndexExtensionTest::testOnBeforeSearch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace Firesphere\SolrPermissions\Tests;
5
6
7
use Firesphere\SolrPermissions\Extensions\BaseIndexExtension;
8
use Firesphere\SolrSearch\Queries\BaseQuery;
9
use SilverStripe\Dev\SapphireTest;
10
use SilverStripe\ORM\DataObject;
11
use Solarium\QueryType\Select\Query\Query;
12
13
class BaseIndexExtensionTest extends SapphireTest
14
{
15
16
    public function testOnBeforeSearch()
17
    {
18
        $object = new CircleCITestIndex();
0 ignored issues
show
Bug introduced by
The type Firesphere\SolrPermissions\Tests\CircleCITestIndex was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
        $extension = new BaseIndexExtension();
20
        $extension->setOwner($object);
21
22
        $query = new BaseQuery();
23
        $clientQuery = new Query();
24
25
        $result = $extension->onBeforeSearch($query, $clientQuery);
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
Bug introduced by
Are you sure the assignment to $result is correct as $extension->onBeforeSearch($query, $clientQuery) targeting Firesphere\SolrPermissio...nsion::onBeforeSearch() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
26
27
        $this->assertEquals(['MemberView' => ['null']], $query->getFilter());
28
    }
29
}
30