You are here

public function UnitsDefaultWebTestCase::testDefaultEntities in Units of Measurement 7.2

Same name and namespace in other branches
  1. 7 units_default/units_default.test \UnitsDefaultWebTestCase::testDefaultEntities()

Conduct testing of enabling/disabling default units.

File

units_default/units_default.test, line 42
Tests for Units default module.

Class

UnitsDefaultWebTestCase
@file Tests for Units default module.

Code

public function testDefaultEntities() {
  $measure = 'length';
  $unit = 'meter';
  $this
    ->drupalPost('admin/structure/units-measure/default', array(
    'units_default_enabled[' . $measure . '][measure]' => TRUE,
    'units_default_enabled[' . $measure . '][units][' . $unit . ']' => TRUE,
  ), t('Save configuration'));
  $this
    ->assertEqual(units_measure_machine_name_load($measure)->measure, $measure, 'Enabling a default measure actually creates it in the database.');
  $this
    ->assertEqual(units_unit_machine_name_load($unit)->machine_name, $unit, 'Enabling a default unit actually creates it in the database.');
  $this
    ->drupalPost('admin/structure/units-measure/default', array(
    'units_default_enabled[' . $measure . '][measure]' => FALSE,
  ), t('Save configuration'));
  $this
    ->assertIdentical(units_measure_machine_name_load($measure), FALSE, 'Disabling a default measure actually deletes it from the database.');
  $this
    ->assertIdentical(units_unit_machine_name_load($unit), FALSE, 'Disabling a default unit actually deletes it from the database.');
}