- <?php
- * @file
- * Simpletest case for the Node Type Example module.
- *
- * Verify the example module functionality.
- */
-
- * Functionality tests for The Node Type Example module.
- *
- * @ingroup node_type_example
- */
- class NodeTypeExampleTest extends BackdropWebTestCase {
-
-
- * {@inheritdoc}
- */
- public function setUp() {
-
- parent::setUp('node_type_example');
- }
-
-
- * API-level content type test.
- *
- * This test will verify that, when the module is installed, it:
- * - Adds a new content type, node_type_example.
- * - Attaches a body field.
- * - Attaches three other fields.
- * - Creates a view mode, node_type_example_list.
- */
- public function testInstallationApi() {
-
-
- $node_type = node_type_get_type('node_type_example');
- $this->assertTrue($node_type, 'The content type has been created.', 'API');
-
-
- $body = field_info_instance('node', 'body', 'node_type_example');
- $this->assertTrue($body, 'The content type has a body field.', 'API');
-
-
- $attached_fields = _node_type_example_installed_instances();
- foreach ($attached_fields as $field_name => $field_info) {
- $field = field_info_instance('node', $field_name, 'node_type_example');
- $this->assertTrue($field,
- "The $field_name field has been added to the content type.", 'API');
- }
-
-
-
- $entities = entity_get_info('node');
- $this->assertTrue(isset($entities['view modes']['node_type_example_list']),
- 'The view mode has been added.', 'API');
- }
-
-
- * Verifies the functionality of the Node Type Example module.
- */
- public function testNodeCreation() {
- $account = $this->backdropCreateUser(array('access content', 'create node_type_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-type-example', $edit, t('Save'));
- $this->assertText("Example content 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_type_example');
- $this->assertText($edit['title'], "Found random title string");
- $this->assertPattern("/red.*green.*blue/", "Correct 'colors available' on the page");
- }
-
-
- * Checks whether the body label is "Example description."
- */
- public function testBodyLabel() {
- $account = $this->backdropCreateUser(array('access content', 'create node_type_example content'));
- $this->backdropLogin($account);
-
-
-
-
- $this->backdropGet('node/add/node-type-example');
- $this->assertResponse(200, 'node/add/node-type-example page found');
- $this->assertRaw('<label for="edit-body-und-0-value">Example description</label>', "The body label is 'Example description'");
- }
-
- }