protected function UbercartJavascriptTestBase::setUp in Ubercart 8.4
Overrides BrowserTestBase::setUp
1 call to UbercartJavascriptTestBase::setUp()
- AjaxTest::setUp in uc_store/
tests/ src/ FunctionalJavascript/ AjaxTest.php
1 method overrides UbercartJavascriptTestBase::setUp()
- AjaxTest::setUp in uc_store/
tests/ src/ FunctionalJavascript/ AjaxTest.php
File
- uc_store/
tests/ src/ FunctionalJavascript/ UbercartJavascriptTestBase.php, line 81
Class
- UbercartJavascriptTestBase
- Base class for Ubercart PHPUnit browser tests.
Namespace
Drupal\Tests\uc_store\FunctionalJavascriptCode
protected function setUp() {
parent::setUp();
// Place the tabs and actions blocks as various tests use them.
$this
->drupalPlaceBlock('local_actions_block');
$this
->drupalPlaceBlock('local_tasks_block');
// Collect admin permissions.
$class = get_class($this);
$adminPermissions = [];
while ($class) {
if (property_exists($class, 'adminPermissions')) {
$adminPermissions = array_merge($adminPermissions, $class::$adminPermissions);
}
$class = get_parent_class($class);
}
// Enable a random selection of 8 countries so we're not always
// testing with the 1 site default.
$countries = \Drupal::service('country_manager')
->getAvailableList();
$country_ids = array_rand($countries, 8);
foreach ($country_ids as $country_id) {
// Don't use the country UI, we're not testing that here...
Country::load($country_id)
->enable()
->save();
}
// Last one of the 8 gets to be the store default country.
\Drupal::configFactory()
->getEditable('uc_store.settings')
->set('address.country', $country_id)
->save();
// Create a store administrator user account.
$this->adminUser = $this
->drupalCreateUser($adminPermissions);
// Create a test product.
$this->product = $this
->createProduct([
'uid' => $this->adminUser
->id(),
'promote' => 0,
]);
}