Fichier

tests/src/Unit/SubPathautoTest.php, line 94

Classe

SubPathautoTest
@coversDefaultClass \Drupal\subpathauto\PathProcessor @group subpathauto

Namespace

Drupal\Tests\subpathauto\Unit

Code

public function setUp() : void {
    parent::setUp();
    $this->aliasProcessor = $this->getMockBuilder('Drupal\\path_alias\\PathProcessor\\AliasPathProcessor')
        ->disableOriginalConstructor()
        ->getMock();
    $this->languageManager = $this->createMock('Drupal\\Core\\Language\\LanguageManagerInterface');
    $this->languageManager
        ->expects($this->any())
        ->method('getCurrentLanguage')
        ->willReturn(new Language(Language::$defaultValues));
    $this->pathValidator = $this->createMock('Drupal\\Core\\Path\\PathValidatorInterface');
    $this->languageNegotiation = $this->createMock('Drupal\\Core\\Config\\ConfigBase');
    $this->subPathautoSettings = $this->createMock('Drupal\\Core\\Config\\ConfigBase');
    $this->configFactory = $this->createMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
    $this->configFactory
        ->expects($this->any())
        ->method('get')
        ->with($this->logicalOr($this->equalTo('subpathauto.settings'), $this->equalTo('language.negotiation')))
        ->will($this->returnCallback(function ($param) {
        $config = func_get_arg(0);
        if ($config == 'subpathauto.settings') {
            return $this->subPathautoSettings;
        }
        elseif ($config == 'language.negotiation') {
            return $this->languageNegotiation;
        }
        return NULL;
    }));
    $this->languageNegotiation
        ->expects($this->any())
        ->method('get')
        ->willReturn($this->languageNegotiationSettings);
    $module_handler = $this->getMockBuilder('Drupal\\Core\\Extension\\ModuleHandler')
        ->disableOriginalConstructor()
        ->getMock();
    $module_handler->expects($this->any())
        ->method('moduleExists')
        ->willReturn(FALSE);
    $this->pathProcessor = new PathProcessor($this->aliasProcessor, $this->languageManager, $this->configFactory, $module_handler);
    $this->pathProcessor
        ->setPathValidator($this->pathValidator);
}