Passed
Pull Request — master (#17)
by Gordon
02:56
created

IndexableMutatorPayloadTest::testMutator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
c 2
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\Implementation\IdentityIndexablePayloadMutator;
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 = ['Title' => $page->Title];
19
        $mutator = new IdentityIndexablePayloadMutator();
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
        $this->assertEquals([
22
            'Title' => 'The Break In San Marino Is Bright',
23
            'Link' => '/the-break-in-san-marino-is-bright/',
24
        ], $payload);
25
    }
26
}
27