public function DeveloperAppUITest::testWarningMessagesIfMultipleProductsDisabled in Apigee Edge 8
Ensures warning messages are visible if multiple products/app is disabled.
File
- tests/
src/ Functional/ DeveloperAppUITest.php, line 470
Class
- DeveloperAppUITest
- Developer app UI tests.
Namespace
Drupal\Tests\apigee_edge\FunctionalCode
public function testWarningMessagesIfMultipleProductsDisabled() {
$admin_warning_message = 'Access to multiple API products will be retained until an app is edited and the developer is prompted to confirm a single API Product selection.';
$end_user_warning_message = 'Foos now require selection of a single Bar; multiple Bar selection is no longer supported. Confirm your Bar selection below.';
$app_settings_url = Url::fromRoute('apigee_edge.settings.general_app');
// Ensure default configuration.
$this
->config('apigee_edge.common_app_settings')
->set('multiple_products', TRUE)
->save();
// Change default Developer App and API Product aliases to ensure consumer
// warning message respects it.
$this
->config('apigee_edge.developer_app_settings')
->set('entity_label_singular', 'Foo')
->set('entity_label_plural', 'Foos')
->save();
$this
->config('apigee_edge.api_product_settings')
->set('entity_label_singular', 'Bar')
->set('entity_label_plural', 'Bars')
->save();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$product1 = $this
->createProduct();
$product2 = $this
->createProduct();
$this->products[] = $product1;
$this->products[] = $product2;
$app = $this
->createDeveloperApp([
'name' => $this
->randomMachineName(),
'displayName' => $this
->randomString(),
], $this->account, [
$product1
->id(),
$product2
->id(),
]);
$app_edit_url = $app
->toUrl('edit-form-for-developer');
$this
->drupalGet($app_settings_url);
$this
->assertSession()
->pageTextNotContains($admin_warning_message);
$this
->drupalGet($app_edit_url);
$this
->assertSession()
->pageTextNotContains($end_user_warning_message);
// Change default configuration.
$this
->config('apigee_edge.common_app_settings')
->set('multiple_products', FALSE)
->save();
$this
->drupalGet($app_settings_url);
$this
->assertSession()
->pageTextContains($admin_warning_message);
$this
->drupalGet($app_edit_url);
$this
->assertSession()
->pageTextContains($end_user_warning_message);
}