class SettingsHelperTest in Acquia Lift Connector 8
SettingsHelper Test.
@coversDefaultClass Drupal\acquia_lift\Service\Helper\SettingsHelper @group acquia_lift
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\acquia_lift\Service\Helper\SettingsHelperTest uses SettingsDataTrait
Expanded class hierarchy of SettingsHelperTest
File
- tests/
src/ Unit/ Service/ Helper/ SettingsHelperTest.php, line 22 - Contains \Drupal\Tests\acquia_lift\Service\Helper\SettingsHelperTest.
Namespace
Drupal\Tests\acquia_lift\Service\HelperView source
class SettingsHelperTest extends UnitTestCase {
use SettingsDataTrait;
/**
* Tests the getFrontEndCredentialSettings() method.
*
* @covers ::getFrontEndCredentialSettings
*
* @param array $full_settings
* @param array $expected_front_end_settings
*
* @dataProvider providerTestGetFrontEndCredentialSettings
*/
public function testGetFrontEndCredentialSettings($full_settings, $expected_front_end_settings) {
$result_front_end_settings = SettingsHelper::getFrontEndCredentialSettings($full_settings);
$this
->assertEquals($expected_front_end_settings, $result_front_end_settings);
}
/**
* Data provider for testGetFrontEndCredentialSettings().
*/
public function providerTestGetFrontEndCredentialSettings() {
$data = [];
$valid_settings = $this
->getValidCredentialSettings();
$valid_front_end_settings = $this
->getValidFrontEndCredentialSettings();
$data['valid data 1'] = [
$valid_settings,
$valid_front_end_settings,
];
$data['valid data 2'] = [
$valid_settings,
$valid_front_end_settings,
];
$data['valid data 2'][0]['account_name'] = 'account_name_2';
$data['valid data 2'][1]['account_name'] = 'account_name_2';
$data['valid data 2'][0]['customer_site'] = '';
$data['valid data 2'][1]['customer_site'] = '';
$data['valid data 2'][0]['js_path'] = 'js_path_2';
$data['valid data 2'][1]['js_path'] = 'js_path_2';
return $data;
}
/**
* Tests the getFrontEndCredentialSettings() method's Exception.
*
* @covers ::getFrontEndCredentialSettings
*
* @param array $incomplete_settings
*
* @dataProvider providerTestGetFrontEndCredentialSettingsException
* @expectedException \Drupal\acquia_lift\Exception\MissingSettingsException
* @expectedExceptionMessage Cannot generate front-end credential settings because some settings are missing.
*/
public function testGetFrontEndCredentialSettingsException($incomplete_settings) {
SettingsHelper::getFrontEndCredentialSettings($incomplete_settings);
}
/**
* Data provider for testGetFrontEndCredentialSettingsException().
*/
public function providerTestGetFrontEndCredentialSettingsException() {
$data = [];
$valid_settings = $this
->getValidCredentialSettings();
$data['missing account_name'] = [
$valid_settings,
];
$data['missing api_url'] = [
$valid_settings,
];
$data['not set customer_site'] = [
$valid_settings,
];
$data['missing account_name'][0]['account_name'] = '';
$data['missing api_url'][0]['js_path'] = '';
unset($data['not set customer_site'][0]['customer_site']);
return $data;
}
/**
* Tests the isInvalidCredential() method.
*
* @covers ::isInvalidCredential
*
* @param array $full_settings
* @param boolean $expected
*
* @dataProvider providerTestIsInvalidCredential
*/
public function testIsInvalidCredential($full_settings, $expected) {
$result = SettingsHelper::isInvalidCredential($full_settings);
$this
->assertEquals($expected, $result);
}
/**
* Data provider for testIsInvalidCredential().
*/
public function providerTestIsInvalidCredential() {
$data = [];
$valid_settings = $this
->getValidCredentialSettings();
$data['valid data 1'] = [
$valid_settings,
FALSE,
];
$data['valid data 2'] = [
$valid_settings,
FALSE,
];
$data['missing access_key'] = [
$valid_settings,
TRUE,
];
$data['missing account_name'] = [
$valid_settings,
TRUE,
];
$data['invalid api_url URL'] = [
$valid_settings,
TRUE,
];
$data['invalid js_path URL'] = [
$valid_settings,
TRUE,
];
$data['valid data 2'][0]['account_name'] = 'account_name_2';
$data['valid data 2'][0]['customer_site'] = '';
$data['valid data 2'][0]['js_path'] = 'js_path_2';
$data['missing account_name'][0]['account_name'] = '';
$data['missing access_key'][0]['access_key'] = NULL;
$data['invalid api_url URL'][0]['api_url'] = '\\\\////\\\\////';
$data['invalid js_path URL'][0]['js_path'] = 'invalid js path';
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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. | |
SettingsHelperTest:: |
public | function | Data provider for testGetFrontEndCredentialSettings(). | |
SettingsHelperTest:: |
public | function | Data provider for testGetFrontEndCredentialSettingsException(). | |
SettingsHelperTest:: |
public | function | Data provider for testIsInvalidCredential(). | |
SettingsHelperTest:: |
public | function | Tests the getFrontEndCredentialSettings() method. | |
SettingsHelperTest:: |
public | function | Tests the getFrontEndCredentialSettings() method's Exception. | |
SettingsHelperTest:: |
public | function | Tests the isInvalidCredential() method. | |
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. | |
UnitTestCase:: |
protected | function | 340 |