You are here

public function CommerceTaxUIAdminTest::testCommerceTaxUIConfigureTaxType in Commerce Core 7

Test adding a condition to a tax type.

File

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

Class

CommerceTaxUIAdminTest
Functional tests for the commerce tax UI module.

Code

public function testCommerceTaxUIConfigureTaxType() {

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

  // Access the tax rate type configure rule page.
  $this
    ->drupalGet('admin/config/workflow/rules/reaction/manage/commerce_tax_type_' . $this->tax_type['name']);

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

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

  // Access the tax rate type configure rule page.
  $this
    ->drupalGet('admin/config/workflow/rules/reaction/manage/commerce_tax_type_' . $this->tax_type['name']);

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

  // 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/reaction/manage/commerce_tax_type_' . $this->tax_type['name'], 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'));
}