soft_length_limit.test in Soft Length Limit 7
Test case for soft_length_limit module
File
soft_length_limit.testView source
<?php
/**
* @file
* Test case for soft_length_limit module
*/
/**
* Tests the relevant functionality provided by the soft_length_limit module.
*/
class SoftLengthLimitWebTestCase extends DrupalWebTestCase {
/**
* Info for simpletest.module.
*/
public static function getInfo() {
return array(
'name' => 'Soft Length Limit',
'description' => 'Ensure that the soft limit is applied to the chosen fields',
'group' => 'Soft Length Limit',
);
}
/**
* Setup for individual tests.
*/
public function setUp() {
// Enable any modules required for the test.
parent::setUp(array(
'soft_length_limit',
));
// Creating the needed user.
$this->privileged_user = $this
->drupalCreateUser(array(
'bypass node access',
'administer nodes',
'administer taxonomy',
'edit terms in 1',
));
$this
->drupalLogin($this->privileged_user);
// Creating the needed field on the article node type.
$field = array(
'field_name' => 'field_test',
'type' => 'text_long',
'cardinality' => 1,
'settings' => array(),
);
field_create_field($field);
$instance = array(
'field_name' => 'field_test',
'entity_type' => 'node',
'label' => 'Test field',
'required' => 0,
'bundle' => 'article',
'description' => '',
'widget' => array(
'type' => 'text_textarea',
'weight' => -4,
'settings' => array(
'rows' => '5',
'soft_length_limit' => '666',
),
),
'display' => array(
'default' => array(
'type' => 'text_default',
'weight' => 10,
),
'teaser' => array(
'type' => 'text_default',
'weight' => 10,
),
),
);
field_create_instance($instance);
$this
->drupalGet('node/add/article');
}
/**
* Tests that input element has the attributes that the javascript should use.
*/
public function testAll() {
$this
->assertPattern('/<textarea .*class="[^"]*soft-length-limit[^"]*".*data-soft-length-limit="666"/', 'HTML element should contain the necessary attributesfor the soft length limiter javascript');
}
}
Classes
Name | Description |
---|---|
SoftLengthLimitWebTestCase | Tests the relevant functionality provided by the soft_length_limit module. |