IndexableMutatorPayloadTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
eloc 11
c 2
b 0
f 0
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testMutator() 0 13 1
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\Implementation\AddLinkIndexablePayloadMutator;
8
9
class IndexableMutatorPayloadTest extends SapphireTest
10
{
11
    protected static $fixture_file = ['tests/fixtures/sitetree.yml'];
12
13
    public function testMutator(): void
14
    {
15
        $page = SiteTree::get()->first();
16
        \error_log($page->Title);
17
18
        $payload = ['sitetree' => ['Title' => $page->Title]];
19
        $mutator = new AddLinkIndexablePayloadMutator();
20
        $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

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