class HelpMessageHelperTest in Acquia Lift Connector 8
HelpMessageHelper Test.
@coversDefaultClass Drupal\acquia_lift\Service\Helper\HelpMessageHelper @group acquia_lift
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\acquia_lift\Service\Helper\HelpMessageHelperTest uses SettingsDataTrait
Expanded class hierarchy of HelpMessageHelperTest
File
- tests/
src/ Unit/ Service/ Helper/ HelpMessageHelperTest.php, line 23 - Contains \Drupal\Tests\acquia_lift\Service\Helper\HelpMessageHelperTest.
Namespace
Drupal\Tests\acquia_lift\Service\HelperView source
class HelpMessageHelperTest extends UnitTestCase {
use SettingsDataTrait;
/**
* @var \Drupal\Core\Config\ConfigFactoryInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $configFactory;
/**
* @var \Drupal\Core\Utility\LinkGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $linkGenerator;
/**
* @var \Drupal\Core\Config\ImmutableConfig|\PHPUnit_Framework_MockObject_MockObject
*/
private $settings;
/**
* {@inheritdoc}
*/
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');
}
/**
* Tests the getMessage() method - AdminSettingsForm, full settings.
*
* @covers ::getMessage
*
* @param string $route_name
*
* @dataProvider providerRouteNames
*/
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);
}
/**
* Tests the getMessage() method - AdminSettingsForm, no API URL setting.
*
* @covers ::getMessage
*
* @param string $route_name
*
* @dataProvider providerRouteNames
*/
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);
}
/**
* Data provider to produce route names.
*/
public function providerRouteNames() {
$data = [];
$data['help page'] = [
'help.page.acquia_lift',
];
$data['admin settings form'] = [
'acquia_lift.admin_settings_form',
];
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HelpMessageHelperTest:: |
private | property | ||
HelpMessageHelperTest:: |
private | property | ||
HelpMessageHelperTest:: |
private | property | ||
HelpMessageHelperTest:: |
public | function | Data provider to produce route names. | |
HelpMessageHelperTest:: |
public | function |
Overrides UnitTestCase:: |
|
HelpMessageHelperTest:: |
public | function | Tests the getMessage() method - AdminSettingsForm, full settings. | |
HelpMessageHelperTest:: |
public | function | Tests the getMessage() method - AdminSettingsForm, no API URL setting. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
SettingsDataTrait:: |
private | function | Get a valid credential settings array. | |
SettingsDataTrait:: |
private | function | Get a valid field mappings settings array. | |
SettingsDataTrait:: |
private | function | Get a valid front end credential settings. | |
SettingsDataTrait:: |
private | function | Get a valid identity settings array. | |
SettingsDataTrait:: |
private | function | Get a valid thumbnail settings array. | |
SettingsDataTrait:: |
private | function | Get a valid visibility settings array. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |