Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 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 US and CA.
     $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(array('uid' => $this->adminUser->id(), 'promote' => 0));
 }
Ejemplo n.º 2
0
 public function setUp()
 {
     parent::setUp();
     $this->drupalLogin($this->adminUser);
     // In order to test zone-based conditions, this particular test class
     // assumes that US is enabled as default, and CA is also enabled.
     \Drupal\uc_country\Entity\Country::load('US')->enable()->save();
     \Drupal\uc_country\Entity\Country::load('CA')->enable()->save();
     \Drupal::configFactory()->getEditable('uc_store.settings')->set('address.country', 'US')->save();
 }
 /**
  * Tests customer overview.
  */
 public function testCustomerAdminPages()
 {
     $this->drupalLogin($this->adminUser);
     $country = Country::load('US');
     Order::create(array('uid' => $this->customer->id(), 'billing_country' => $country->id(), 'billing_zone' => 'AK'))->save();
     $this->drupalGet('admin/store/customers/view');
     $this->assertResponse(200);
     $this->assertLinkByHref('user/' . $this->customer->id());
     $this->assertText($country->getZones()['AK']);
     $this->assertText($country->label());
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->drupalLogin($this->adminUser);
     // module_load_include() has to be called after parent::setUp()
     // because the moduler_handler service isn't initialized yet.
     module_load_include('inc', 'uc_store', 'includes/uc_ajax_attach');
     // In order to test zone-based conditions, this particular test class
     // assumes that US is enabled and set as the store country.
     Country::load('US')->enable()->save();
     \Drupal::configFactory()->getEditable('uc_store.settings')->set('address.country', 'US')->save();
 }
Ejemplo n.º 5
0
 /**
  * Disables a country.
  *
  * @param \Drupal\uc_country\Entity\Country $uc_country
  *   The country object to disable.
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  *   A redirect response to the country listing page.
  */
 public function disableConfig(Country $uc_country)
 {
     $uc_country->disable()->save();
     drupal_set_message($this->t('The country %label has been disabled.', ['%label' => $uc_country->label()]));
     return $this->redirect('entity.uc_country.collection');
 }