- <?php
-
- * @file
- * Simpletest case for node_example module.
- *
- * Verify example module functionality.
- */
-
- * Functionality tests for node example module.
- *
- * @ingroup node_example
- */
- class NodeExampleTestCase extends BackdropWebTestCase {
-
-
- * {@inheritdoc}
- */
- public function setUp() {
-
- parent::setUp('node_example');
- }
-
-
- * API-level content type test.
- *
- * This test will verify that when the module is installed, it:
- * - Adds a new content type, node_example.
- * - Attaches a body field.
- * - Attaches three other fields.
- * - Creates a view mode, example_node_list.
- */
- public function testInstallationApi() {
-
-
- $node_type = node_type_get_type('node_example');
- $this->assertTrue($node_type, 'Node Example Type was created.', 'API');
-
-
- $body = field_info_instance('node', 'body', 'node_example');
- $this->assertTrue($body, 'Node Example Type has a body field.', 'API');
-
-
-
- $attached_fields = _node_example_installed_instances();
- foreach ($attached_fields as $field_name => $field_info) {
- $field = field_info_instance('node', $field_name, 'node_example');
- $this->assertTrue($field,
- 'Field: ' . $field_name . ' was attached to node_example.', 'API');
- }
-
-
-
-
- $entities = entity_get_info('node');
- $this->assertTrue(isset($entities['view modes']['example_node_list']),
- 'Added example_node_list view mode.', 'API');
- }
-
-
- * Verify the functionality of the example module.
- */
- public function testNodeCreation() {
-
- $account = $this->backdropCreateUser(array('access content', 'create node_example content'));
- $this->backdropLogin($account);
-
-
- $edit = array(
- 'title' => $this->randomName(),
- 'node_example_color[und][0][value]' => 'red',
- 'node_example_color[und][1][value]' => 'green',
- 'node_example_color[und][2][value]' => 'blue',
- 'node_example_quantity[und][0][value]' => 100,
- );
- $this->backdropPost('node/add/node-example', $edit, t('Save'));
- $this->assertText("Example Node Type " . $edit['title'] . " has been created", "Found node creation message");
- $this->assertPattern("/The colors available.*red.*green.*blue/", "Correct 'colors available' on node page");
-
-
- $this->backdropGet('examples/node_example');
- $this->assertText($edit['title'], "Found random title string");
- $this->assertPattern("/red.*green.*blue/", "Correct 'colors available' on node example page");
-
- }
-
-
- * Check the value of body label.
- *
- * Checks whether body label has a value of "Example Description"
- */
- public function testBodyLabel() {
-
- $account = $this->backdropCreateUser(array('access content', 'create node_example content'));
- $this->backdropLogin($account);
-
-
-
-
-
- $this->backdropGet('node/add/node-example');
- $this->assertResponse(200, 'node/add/node-example page found');
- $this->assertRaw('<label for="edit-body-und-0-value">Example Description </label>', 'Body label equals \'Example Description\'');
- }
- }