CurrencyLocaleWebTest.php in Currency 8.3
File
tests/src/Functional/Controller/CurrencyLocaleWebTest.php
View source
<?php
namespace Drupal\Tests\currency\Functional\Controller;
use Drupal\Tests\BrowserTestBase;
class CurrencyLocaleWebTest extends BrowserTestBase {
public static $modules = array(
'currency',
'block',
);
protected $defaultTheme = 'stark';
public function setUp() : void {
parent::setUp();
$this
->drupalPlaceBlock('local_tasks_block');
$config_importer = \Drupal::service('currency.config_importer');
$config_importer
->importCurrencyLocale('nl_NL');
$config_importer
->importCurrencyLocale('aa_DJ');
}
function testUserInterface() {
$currency_locale_overview_path = 'admin/config/regional/currency-formatting/locale';
$currency_formatting_path = 'admin/config/regional/currency-formatting';
$regional_path = 'admin/config/regional';
$account = $this
->drupalCreateUser(array(
'access administration pages',
));
$this
->drupalLogin($account);
$this
->drupalGet($regional_path);
$this
->assertResponse('200');
$this
->assertNoLinkByHref($currency_formatting_path);
$this
->drupalGet($currency_formatting_path);
$this
->assertResponse('403');
$account = $this
->drupalCreateUser(array(
'currency.amount_formatting.administer',
'access administration pages',
));
$this
->drupalLogin($account);
$this
->drupalGet($regional_path);
$this
->assertResponse('200');
$this
->assertLinkByHref($currency_formatting_path);
$this
->drupalGet($currency_formatting_path);
$this
->assertResponse('200');
$this
->drupalLogout();
$account = $this
->drupalCreateUser(array(
'currency.amount_formatting.administer',
));
$this
->drupalLogin($account);
$this
->drupalGet($currency_formatting_path);
$this
->assertNoLinkByHref($currency_locale_overview_path);
$account = $this
->drupalCreateUser(array(
'currency.amount_formatting.administer',
'currency.currency_locale.view',
));
$this
->drupalLogin($account);
$this
->drupalGet($currency_formatting_path);
$this
->assertLinkByHref($currency_locale_overview_path);
$this
->drupalLogout();
$this
->drupalGet($currency_locale_overview_path);
$this
->assertResponse('403');
$account = $this
->drupalCreateUser(array(
'currency.currency_locale.view',
));
$this
->drupalLogin($account);
$this
->drupalGet($currency_locale_overview_path);
$this
->assertText('Dutch (Netherlands)');
$this
->assertNoLink(t('Edit'));
$this
->assertNoLink(t('Delete'));
$account = $this
->drupalCreateUser(array(
'currency.currency_locale.view',
'currency.currency_locale.update',
'currency.currency_locale.delete',
));
$this
->drupalLogin($account);
$this
->drupalGet($currency_locale_overview_path);
$this
->assertLinkByHref('admin/config/regional/currency-formatting/locale/nl_NL');
$this
->assertLinkByHref('admin/config/regional/currency-formatting/locale/nl_NL/delete');
$locale_delegator = \Drupal::service('currency.locale_resolver');
$this
->assertLinkByHref('admin/config/regional/currency-formatting/locale/' . $locale_delegator::DEFAULT_LOCALE);
$this
->assertNoLinkByHref('admin/config/regional/currency-formatting/locale/' . $locale_delegator::DEFAULT_LOCALE . '/delete');
$this
->clickLink(t('Edit'));
$this
->assertUrl('admin/config/regional/currency-formatting/locale/aa_DJ');
$this
->assertResponse('200');
$this
->clickLink(t('Delete'));
$this
->assertUrl('admin/config/regional/currency-formatting/locale/aa_DJ/delete');
$this
->assertResponse('200');
$this
->drupalGet($currency_locale_overview_path);
$this
->clickLink(t('Delete'));
$this
->assertUrl('admin/config/regional/currency-formatting/locale/aa_DJ/delete');
$this
->assertResponse('200');
}
}