class WebformTest in Little helpers 7.2
Same name and namespace in other branches
- 7 tests/Webform/WebformTest.php \Drupal\little_helpers\Test\Webform\WebformTest
Test the webform node wrapper.
Hierarchy
- class \Drupal\little_helpers\Test\Webform\WebformTest extends \Upal\DrupalUnitTestCase
Expanded class hierarchy of WebformTest
File
- tests/
Webform/ WebformTest.php, line 11
Namespace
Drupal\little_helpers\Test\WebformView source
class WebformTest extends DrupalUnitTestCase {
/**
* Create a node stub.
*/
public static function nodeStub() {
$webform['redirect_url'] = 'node/167';
$webform['components'][1] = array(
'cid' => '1',
'form_key' => 'first_name',
'name' => 'First name',
'type' => 'textfield',
'value' => '%get[p3]',
'extra' => array(),
);
$webform['components'][2] = array(
'cid' => '2',
'form_key' => 'last_name',
'name' => 'Last name',
'type' => 'textfield',
'value' => '%get[p4]',
'extra' => array(),
);
$webform['components'][3] = array(
'cid' => '3',
'pid' => '0',
'form_key' => 'email',
'name' => 'Mail ',
'type' => 'email',
'value' => '%get[p5]',
'extra' => array(),
);
$webform['components'][4] = array(
'cid' => '4',
'pid' => '0',
'form_key' => 'your_message',
'name' => 'Your message',
'type' => 'fieldset',
'value' => '',
'extra' => array(),
);
$webform['components'][6] = array(
'cid' => '6',
'pid' => '4',
'form_key' => 'email_subject',
'name' => 'Subject',
'type' => 'textfield',
'value' => 'subject default value',
'extra' => array(),
);
$webform['components'][7] = array(
'cid' => '7',
'pid' => '4',
'form_key' => 'email_body',
'name' => 'Your email',
'type' => 'textarea',
'value' => 'body default value',
'extra' => array(),
);
return (object) array(
'webform' => $webform,
);
}
/**
* Test getting components by component ID.
*/
public function testComponentReturnsComponentArray() {
$node = self::nodeStub();
$webform = new Webform($node);
$component = $webform
->component(6);
$this
->assertEqual('email_subject', $component['form_key']);
}
/**
* Test getting an unknown component.
*/
public function testComponentReturnsNullForUnknownComponent() {
$node = self::nodeStub();
$webform = new Webform($node);
$this
->assertNull($webform
->component(12));
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
WebformTest:: |
public static | function | Create a node stub. | |
WebformTest:: |
public | function | Test getting components by component ID. | |
WebformTest:: |
public | function | Test getting an unknown component. |