HelpMessageHelperTest.php in Acquia Lift Connector 8
File
tests/src/Unit/Service/Helper/HelpMessageHelperTest.php
View source
<?php
namespace Drupal\Tests\acquia_lift\Service\Helper;
use Drupal\Tests\UnitTestCase;
use Drupal\acquia_lift\Service\Helper\HelpMessageHelper;
use Drupal\Tests\acquia_lift\Unit\Traits\SettingsDataTrait;
require_once __DIR__ . '/../../Traits/SettingsDataTrait.php';
require_once __DIR__ . '/../../Polyfill/Drupal.php';
class HelpMessageHelperTest extends UnitTestCase {
use SettingsDataTrait;
private $configFactory;
private $linkGenerator;
private $settings;
public function setUp() {
parent::setUp();
$this->configFactory = $this
->getMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
$this->linkGenerator = $this
->getMock('Drupal\\Core\\Utility\\LinkGeneratorInterface');
$this->settings = $this
->getMockBuilder('Drupal\\Core\\Config\\ImmutableConfig')
->disableOriginalConstructor()
->getMock();
$this->configFactory
->expects($this
->once())
->method('get')
->with('acquia_lift.settings')
->willReturn($this->settings);
$this->linkGenerator
->expects($this
->at(0))
->method('generate')
->with('Documentation')
->willReturn('a_documentation_link');
}
public function testGetMessageAdminSettingsFormFullSettings($route_name) {
$full_settings = $this
->getValidCredentialSettings();
$this->settings
->expects($this
->once())
->method('get')
->with('credential')
->willReturn($full_settings);
$this->linkGenerator
->expects($this
->at(1))
->method('generate')
->with('Acquia Lift Web Admin')
->willReturn('a_web_admin_link');
$help_message_helper = new HelpMessageHelper($this->configFactory, $this->linkGenerator);
$message = $help_message_helper
->getMessage($route_name);
$this
->assertEquals('You can find more info in a_documentation_link, and control your web services settings at a_web_admin_link.', $message);
}
public function testGetMessageAdminSettingsFormNoApiUrl($route_name) {
$missing_api_url_settings = $this
->getValidCredentialSettings();
unset($missing_api_url_settings['api_url']);
$this->settings
->expects($this
->once())
->method('get')
->with('credential')
->willReturn($missing_api_url_settings);
$help_message_helper = new HelpMessageHelper($this->configFactory, $this->linkGenerator);
$message = $help_message_helper
->getMessage($route_name);
$this
->assertEquals('You can find more info in a_documentation_link.', $message);
}
public function providerRouteNames() {
$data = [];
$data['help page'] = [
'help.page.acquia_lift',
];
$data['admin settings form'] = [
'acquia_lift.admin_settings_form',
];
return $data;
}
}