Issues (37)

php/Extension/FluentDirectorExtensionTest.php (3 issues)

Labels
Severity
1
<?php
2
3
namespace TractorCow\Fluent\Tests\Extension;
4
5
use Page;
0 ignored issues
show
The type Page 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...
6
use SilverStripe\CMS\Model\SiteTree;
7
use SilverStripe\Control\Director;
8
use SilverStripe\Dev\FunctionalTest;
9
use TractorCow\Fluent\Extension\FluentDirectorExtension;
10
use TractorCow\Fluent\Extension\FluentFilteredExtension;
11
use TractorCow\Fluent\Extension\FluentSiteTreeExtension;
12
use TractorCow\Fluent\State\FluentState;
13
14
/**
15
 * Class FluentDirectorExtensionTest
16
 *
17
 * @package TractorCow\Fluent\Tests\Extension
18
 */
19
class FluentDirectorExtensionTest extends FunctionalTest
20
{
21
    /**
22
     * @var string
23
     */
24
    protected static $fixture_file = 'FluentDirectorExtensionTest.yml';
25
26
    /**
27
     * @var array
28
     */
29
    protected static $required_extensions = [
30
        SiteTree::class => [
31
            FluentSiteTreeExtension::class,
32
            FluentFilteredExtension::class,
33
        ],
34
        Director::class => [
35
            FluentDirectorExtension::class,
36
        ],
37
    ];
38
39
    public function setUp() // phpcs:ignore SlevomatCodingStandard.TypeHints
40
    {
41
        parent::setUp();
42
43
        $this->logInWithPermission('ADMIN');
44
    }
45
46
    public function testVisitUrlByLocaleWithMultiByteCharacter()
47
    {
48
        $locale = 'en_NZ';
49
        FluentState::singleton()->withState(function (FluentState $state) use ($locale) {
50
            $state->setLocale($locale);
51
52
            $expectedTitle = sprintf('Page1 (%s)', $locale);
53
54
            /** @var Page|FluentSiteTreeExtension $page */
55
            $page = Page::get()->filter(['Title' => $expectedTitle])->first();
56
            $this->assertNotEmpty($page);
57
            $page->publishRecursive();
0 ignored issues
show
The method publishRecursive() does not exist on TractorCow\Fluent\Extens...FluentSiteTreeExtension. ( Ignorable by Annotation )

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

57
            $page->/** @scrutinizer ignore-call */ 
58
                   publishRecursive();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
58
59
            $this->get($page->AbsoluteLink());
0 ignored issues
show
The method AbsoluteLink() does not exist on TractorCow\Fluent\Extens...FluentSiteTreeExtension. ( Ignorable by Annotation )

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

59
            $this->get($page->/** @scrutinizer ignore-call */ AbsoluteLink());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60
61
            $this->assertContains(sprintf('<title>%s', $expectedTitle), $this->content());
62
        });
63
    }
64
}
65