CurrencyWebTest.php in Currency 8.3
File
tests/src/Functional/Controller/CurrencyWebTest.php
View source
<?php
namespace Drupal\Tests\currency\Functional\Controller;
use Drupal\Tests\BrowserTestBase;
class CurrencyWebTest extends BrowserTestBase {
public static $modules = array(
'currency',
);
protected $defaultTheme = 'stark';
public function setUp() : void {
parent::setUp();
$config_importer = \Drupal::service('currency.config_importer');
$config_importer
->importCurrency('AFN');
$config_importer
->importCurrency('EUR');
}
function testUserInterface() {
$currency_overview_path = 'admin/config/regional/currency';
$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_overview_path);
$this
->drupalGet($currency_overview_path);
$this
->assertResponse('403');
$account = $this
->drupalCreateUser(array(
'currency.currency.view',
'access administration pages',
));
$this
->drupalLogin($account);
$this
->drupalGet($regional_path);
$this
->assertResponse('200');
$this
->assertLinkByHref($currency_overview_path);
$this
->drupalLogout();
$this
->drupalGet($currency_overview_path);
$this
->assertResponse('403');
$account = $this
->drupalCreateUser(array(
'currency.currency.view',
));
$this
->drupalLogin($account);
$this
->drupalGet($currency_overview_path);
$this
->assertResponse('200');
$this
->assertText('euro');
$this
->assertNoLink(t('Edit'));
$this
->assertNoLink(t('Delete'));
$account = $this
->drupalCreateUser(array(
'currency.currency.view',
'currency.currency.update',
'currency.currency.delete',
));
$this
->drupalLogin($account);
$this
->drupalGet($currency_overview_path);
$this
->assertLinkByHref('admin/config/regional/currency/EUR');
$this
->assertLinkByHref('admin/config/regional/currency/EUR/delete');
$this
->assertLinkByHref('admin/config/regional/currency/XXX');
$this
->assertNoLinkByHref('admin/config/regional/currency/XXX/delete');
$this
->clickLink(t('Edit'));
$this
->assertUrl('admin/config/regional/currency/AFN');
$this
->assertResponse('200');
$this
->clickLink(t('Delete'));
$this
->assertUrl('admin/config/regional/currency/AFN/delete');
$this
->assertResponse('200');
$this
->drupalGet($currency_overview_path);
$this
->clickLink(t('Delete'));
$this
->assertUrl('admin/config/regional/currency/AFN/delete');
$this
->assertResponse('200');
}
}