Passed
Pull Request — master (#17)
by Gordon
03:07
created

IndexableMutatorPayloadTest::testMutator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 12
rs 9.9666
cc 1
nc 1
nop 0
1
<?php declare(strict_types = 1);
2
3
namespace Suilven\FreeTextSearch\Tests\Factory;
4
5
use SilverStripe\CMS\Model\SiteTree;
6
use SilverStripe\Dev\SapphireTest;
7
use Suilven\FreeTextSearch\Factory\SuggesterFactory;
8
use Suilven\FreeTextSearch\Implementation\IdentityIndexablePayloadMutator;
9
10
class IndexableMutatorPayloadTest extends SapphireTest
11
{
12
    protected static $fixture_file = ['tests/fixtures/sitetree.yml'];
13
14
    public function testMutator()
15
    {
16
        $page = SiteTree::get()->first();
17
        error_log($page->Title);
18
19
        $payload = ['Title' => $page->Title];
20
        $mutator = new IdentityIndexablePayloadMutator();
21
        $mutator->mutatePayload($page, $payload);
0 ignored issues
show
Bug introduced by
It seems like $page can also be of type null; however, parameter $dataObject of Suilven\FreeTextSearch\I...utator::mutatePayload() does only seem to accept SilverStripe\ORM\DataObject, maybe add an additional type check? ( Ignorable by Annotation )

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

21
        $mutator->mutatePayload(/** @scrutinizer ignore-type */ $page, $payload);
Loading history...
22
        $this->assertEquals([
23
            'Title' => 'The Break In San Marino Is Bright',
24
            'Link' => '/the-break-in-san-marino-is-bright/'
25
        ], $payload);
26
    }
27
}
28