function PropertiesTestCase::testAutocomplete in Dynamic properties 7
Test autocomplete functionality.
File
- ./
properties.test, line 370 - Contains tests for the properties.module
Class
- PropertiesTestCase
- Tests for fields integration.
Code
function testAutocomplete() {
$this
->loginAdmin();
$this
->createAttribute('aaname', 'ccclabel');
$this
->createAttribute('abname', 'ccblabel');
$this
->createAttribute('bcname', 'efglabel');
$this
->drupalGet('properties_autocomplete/attribute/a');
$json = drupal_json_decode($this
->drupalGetContent());
$this
->assertEqual(2, count($json));
$this
->assertEqual($json['aaname'], t('@name (@label)', array(
'@name' => 'aaname',
'@label' => 'ccclabel',
)));
$this
->assertEqual($json['abname'], t('@name (@label)', array(
'@name' => 'abname',
'@label' => 'ccblabel',
)));
$this
->drupalGet('properties_autocomplete/attribute/aa');
$json = drupal_json_decode($this
->drupalGetContent());
$this
->assertEqual(1, count($json));
$this
->assertEqual($json['aaname'], t('@name (@label)', array(
'@name' => 'aaname',
'@label' => 'ccclabel',
)));
$this
->drupalGet('properties_autocomplete/attribute/cc');
$json = drupal_json_decode($this
->drupalGetContent());
$this
->assertEqual(2, count($json));
$this
->assertEqual($json['aaname'], t('@name (@label)', array(
'@name' => 'aaname',
'@label' => 'ccclabel',
)));
$this
->assertEqual($json['abname'], t('@name (@label)', array(
'@name' => 'abname',
'@label' => 'ccblabel',
)));
$this
->drupalGet('properties_autocomplete/attribute/ef');
$json = drupal_json_decode($this
->drupalGetContent());
$this
->assertEqual(1, count($json));
$this
->assertEqual($json['bcname'], t('@name (@label)', array(
'@name' => 'bcname',
'@label' => 'efglabel',
)));
$this
->drupalGet('properties_autocomplete/attribute/none');
$json = drupal_json_decode($this
->drupalGetContent());
$this
->assertEqual(0, count($json));
}