You are here

public function CommerceTaxUIAdminTest::testCommerceTaxUIConfigureTaxRate in Commerce Core 7

Test configuring a tax rate.

File

modules/tax/tests/commerce_tax_ui.test, line 281
Functional tests for the commerce tax UI module.

Class

CommerceTaxUIAdminTest
Functional tests for the commerce tax UI module.

Code

public function testCommerceTaxUIConfigureTaxRate() {

  // Create a tax rate.
  $tax_rate = $this
    ->createDummyTaxRate();

  // Login with normal user.
  $this
    ->drupalLogin($this->normal_user);

  // Access the configure component page for tax rates.
  $this
    ->drupalGet('admin/config/workflow/rules/components/manage/' . $tax_rate['rules_component']);

  // It should return a 403.
  $this
    ->assertResponse(403, t('Normal user is not able to access the component configure page for a tax rate'));

  // Login with store admin user.
  $this
    ->drupalLogin($this->store_admin);

  // Access the configure component page for tax rates.
  $this
    ->drupalGet('admin/config/workflow/rules/components/manage/' . $tax_rate['rules_component']);

  // It should return a 200.
  $this
    ->assertResponse(200, t('Store admin user can access the component configure page for a tax rate'));

  // Add a condition
  $this
    ->assertLink(t('Add condition'), 0, t('Add condition link is present'));
  $this
    ->clickLink(t('Add condition'));

  // Select a basic condition as at this step we're only testing if the
  // saving process is working.
  $this
    ->drupalPost(NULL, array(
    'element_name' => 'entity_is_of_type',
  ), t('Continue'));
  $this
    ->drupalPost(NULL, array(
    'parameter[entity][settings][entity:select]' => 'commerce-line-item',
    'parameter[type][settings][type]' => 'commerce_line_item',
  ), t('Save'));

  // Check that after saving the url is correct and the condition has been
  // added.
  $this
    ->assertTrue($this->url == url('admin/config/workflow/rules/components/manage/' . $tax_rate['rules_component'], array(
    'absolute' => TRUE,
  )), t('After adding a new condition component the landing page is the edit components one'));
  $this
    ->assertText(t('Entity is of type'), t('Condition was added correctly'));
}