StoreTest.php in Ubercart 8.4
File
uc_store/tests/src/Functional/StoreTest.php
View source
<?php
namespace Drupal\Tests\uc_store\Functional;
class StoreTest extends UbercartBrowserTestBase {
public function testStoreAdmin() {
$assert = $this
->assertSession();
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/store');
$assert
->titleEquals('Store | Drupal');
$assert
->pageTextContains('Configuration');
$assert
->linkExists('Store');
$assert
->linkExists('Countries and addresses');
$assert
->pageTextContains('Store status');
$edit = [
'uc_store_name' => $this
->randomMachineName(),
'uc_store_email' => $this
->randomMachineName() . '@example.com',
'uc_store_phone' => $this
->randomMachineName(),
'uc_store_fax' => $this
->randomMachineName(),
'uc_store_help_page' => $this
->randomMachineName(),
'address[street1]' => $this
->randomMachineName(),
'address[street2]' => $this
->randomMachineName(),
'address[city]' => $this
->randomMachineName(),
'address[postal_code]' => $this
->randomMachineName(),
'uc_currency_code' => $this
->randomMachineName(3),
'uc_currency_sign' => $this
->randomMachineName(1),
'uc_currency_thou' => $this
->randomMachineName(1),
'uc_currency_dec' => $this
->randomMachineName(1),
'uc_currency_prec' => mt_rand(0, 2),
];
$country_id = \Drupal::config('uc_store.settings')
->get('address.country');
$zone_list = \Drupal::service('country_manager')
->getZoneList($country_id);
if (!empty($zone_list)) {
$edit += [
'address[zone]' => array_rand($zone_list),
];
}
$this
->drupalGet('admin/store/config/store');
$this
->submitForm($edit, 'Save configuration');
foreach ($edit as $name => $value) {
$assert
->fieldValueEquals($name, $value);
}
}
}