You are here

RequiredByRoleImageFieldWebTestCase.test in Required by role 7

Tests for the Image field.

File

tests/required_by_role_test/RequiredByRoleImageFieldWebTestCase.test
View source
<?php

/**
 * @file
 * Tests for the Image field.
 */
class RequiredByRoleImageFieldWebTestCase extends RequiredByRoleBasic {
  protected $field_name = 'field_image';
  public static function getInfo() {
    return array(
      'name' => 'Required by role: Image',
      'description' => 'Tests for image field.',
      'group' => 'Required by role',
    );
  }
  function setUp() {
    parent::setUp('image');
    $rid = $this->required_fields_rid;
    $instance = field_info_instance('node', 'field_image', 'article');
    $instance['settings']['required_by_role'] = array(
      1 => 0,
      3 => 0,
      $rid => $rid,
      5 => 0,
    );
    field_update_instance($instance);
  }

  /**
   * Test for required and non-required roles
   * @return [type] [description]
   */
  function testIsRequiredByRole() {
    $edit = array();
    $edit['title'] = $this
      ->randomName(8);
    $edit['body[und][0][value]'] = $this
      ->randomName(16);
    $this
      ->drupalLogin($this
      ->getRequiredUser());
    $this
      ->drupalPost('node/add/' . $this->entity_bundle, $edit, t('Save'));
    $this
      ->assertText('Image field is required.');
    $this
      ->drupalLogout();
    $this
      ->drupalLogin($this
      ->getNonRequiredUser());
    $this
      ->drupalPost('node/add/' . $this->entity_bundle, $edit, t('Save'));
    $this
      ->assertText($edit['title'], "Node has been created");
    $this
      ->drupalLogout();
  }

}

Classes

Namesort descending Description
RequiredByRoleImageFieldWebTestCase @file Tests for the Image field.