Exemplo n.º 1
0
 /**
  * Preparation work that is done before each test.
  * Test users, content types, nodes etc. are created.
  */
 function setUp($module = '')
 {
     if (empty($module)) {
         // Enable content access module
         parent::setUp('content_access');
     } else {
         // Enable content access module plus another module
         parent::setUp('content_access', $module);
         // Stop setup when module could not be enabled
         if (!module_exists($module)) {
             return;
         }
     }
     // Create test user with seperate role
     $this->test_user = $this->drupalCreateUser();
     // Create admin user
     $this->admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'grant content access', 'grant own content access', 'administer nodes', 'access administration pages'));
     $this->drupalLogin($this->admin_user);
     // Rebuild content access permissions
     $this->drupalPost('admin/content/node-settings/rebuild', array(), t('Rebuild permissions'));
     // This would be nice to have - but it does not work in the current simpletest version
     // Create test content type
     //$content_type = $this->drupalCreateContentType();
     //$this->url_content_type_name = $content_type->type;
     //$this->url_content_type_name = str_replace('_', '-', $content_type->type);
     // Create test content type (the old way)
     $this->content_type_name = strtolower($this->randomName(5));
     $edit = array('name' => $this->content_type_name, 'type' => $this->content_type_name);
     $this->drupalPost('admin/content/types/add', $edit, t('Save content type'));
     $this->assertRaw(t('The content type %type has been added.', array('%type' => $this->content_type_name)), 'Test content type was added successfully: ' . $this->content_type_name);
     $this->url_content_type_name = str_replace('_', '-', $this->content_type_name);
 }
 /**
  * Preparation work that is done before each test.
  * Test users, content types, nodes etc. are created.
  */
 function setUp($module = '')
 {
     if (empty($module)) {
         // Enable content access module
         parent::setUp('content_access');
     } else {
         // Enable content access module plus another module
         parent::setUp('content_access', $module);
         // Stop setup when module could not be enabled
         if (!module_exists($module)) {
             $this->pass('No ' . $module . ' module present, skipping test');
             return;
         }
     }
     // Create test user with seperate role
     $this->test_user = $this->drupalCreateUser();
     // Get the value of the new role
     // Needed in D7 because it's by default create two roles for new users
     // one role is Authenticated and the second is new default one
     // @see drupalCreateUser()
     foreach ($this->test_user->roles as $rid => $role) {
         if (!in_array($rid, array(DRUPAL_AUTHENTICATED_RID))) {
             $this->rid = $rid;
             break;
         }
     }
     // Create admin user
     $this->admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'grant content access', 'grant own content access', 'administer nodes', 'access administration pages'));
     $this->drupalLogin($this->admin_user);
     // Rebuild content access permissions
     node_access_rebuild();
     // Create test content type
     $this->content_type = $this->drupalCreateContentType();
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->cookieFile = '/tmp/cookie.txt';
     $this->cookies = array();
     parent::setUp();
     // Overwrite mailing system settings (See Drupal issue 2279851).
     $this->mail_system = variable_get('mail_system');
     variable_set('mail_system', array('default-system' => 'oshaTestingMailSystem'));
 }
 public function setUp()
 {
     parent::setUp(array('collection', 'collection_field', 'xautoload', 'entity'));
     $field = array('active' => '1', 'cardinality' => '-1', 'deleted' => '0', 'entity_types' => array(), 'field_name' => 'field_collection', 'foreign keys' => array(), 'indexes' => array('collection' => array(0 => 'value')), 'locked' => '0', 'module' => 'collection_field', 'settings' => array(), 'translatable' => '0', 'type' => 'collection');
     field_create_field($field);
     $instance = array('bundle' => 'article', 'entity_type' => 'node', 'field_name' => 'field_collection', 'label' => 'Collection', 'widget' => array('module' => 'collections', 'type' => 'collection'), 'display' => array('default' => array('label' => 'hidden', 'settings' => array(), 'type' => 'hidden'), 'teaser' => array('label' => 'hidden', 'settings' => array(), 'type' => 'hidden')));
     field_create_instance($instance);
     $this->createCollection();
     $this->node = $this->createNode();
 }
 protected function error($message = '', $group = 'Other', array $caller = NULL)
 {
     if ($message == 'Undefined variable: location') {
         // change error (Notice) to debug message
         return $this->assert('debug', $message, 'Debug', $caller);
     }
     if ($message == 'Undefined property: stdClass::$locations') {
         // change error (Notice) to debug message
         return $this->assert('debug', $message, 'Debug', $caller);
     }
     return parent::error($message, $group, $caller);
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     // Support both an array of modules and a single module.
     $modules = func_get_args();
     if (isset($modules[0]) && is_array($modules[0])) {
         $modules = $modules[0];
     }
     $modules[] = 'service_container';
     parent::setUp($modules);
     \ServiceContainer::init();
     $this->container = \Drupal::getContainer();
 }
Exemplo n.º 7
0
 /**
  * Sets up modules for API tests, and a super-user.
  *
  * @param array $extra_modules
  *   Extra modules to install.
  */
 function baseSetUp($extra_modules = array())
 {
     $modules = array_merge(array('api', 'ctools', 'gplib', 'node', 'comment', 'dblog', 'views'), $extra_modules);
     DrupalWebTestCase::setUp($modules);
     // Set the line break tag to nothing for most tests.
     variable_set('api_breaks_tag', '');
     // For debug purposes, visit the Recent Log Messages report page.
     $this->drupalGet('admin/reports/dblog');
     $this->verifyCounts(array('api_project' => 0, 'api_branch' => 0, 'api_documentation' => 0, 'node' => 0, 'comment' => 0, 'api_file' => 0, 'api_function' => 0, 'api_reference_storage' => 0, 'api_overrides' => 0, 'api_members' => 0, 'api_php_branch' => 1, 'api_php_documentation' => 0), 0, 'Immediately after install');
     // Set up a super-user.
     $this->super_user = $this->drupalCreateUser(array('access API reference', 'administer API reference', 'access content', 'access administration pages', 'administer blocks', 'administer nodes', 'access site reports', 'administer site configuration'));
     $this->drupalLogin($this->super_user);
 }
Exemplo n.º 8
0
 function setUp()
 {
     parent::setUp('api', 'job_queue');
     include drupal_get_path('module', 'api') . '/api.admin.inc';
     include drupal_get_path('module', 'api') . '/parser.inc';
     // Make a branch for sample code.
     $branch->branch_name = '6';
     $branch->title = 'Testing 6';
     $branch->directory = drupal_get_path('module', 'api') . '/tests/sample';
     $branch = null;
     api_save_branch($branch);
     // Parse the code.
     api_update_all_branches();
     while (job_queue_dequeue()) {
     }
 }
Exemplo n.º 9
0
 /**
  * Setup the test enviroment
  */
 function setUp()
 {
     parent::setUp();
     // Create and log in an administrative user having access to the Full HTML
     // text format.
     $full_html_format = db_query_range('SELECT * FROM {filter_format} WHERE name = :name', 0, 1, array(':name' => 'Full HTML'))->fetchObject();
     $adminuser = $this->drupalCreateUser(array('administer blocks', filter_permission_name($full_html_format), 'access administration pages', 'access dashboard'));
     $this->drupalLogin($adminuser);
     // Define the existing regions.
     $this->regions = array();
     $this->regions[] = array('name' => 'header', 'class' => 'region region-header clearfix');
     $this->regions[] = array('name' => 'sidebar_first');
     $this->regions[] = array('name' => 'content');
     $this->regions[] = array('name' => 'sidebar_second');
     $this->regions[] = array('name' => 'footer');
 }
Exemplo n.º 10
0
 /**
  * Setup the test.
  */
 function setUp()
 {
     parent::setUp('block_test');
     // Create an admin user, log in and enable test blocks.
     $this->admin_user = $this->drupalCreateUser(array('administer blocks', 'access administration pages'));
     $this->drupalLogin($this->admin_user);
     // Create additional users to test caching modes.
     $this->normal_user = $this->drupalCreateUser();
     $this->normal_user_alt = $this->drupalCreateUser();
     // Sync the roles, since drupalCreateUser() creates separate roles for
     // the same permission sets.
     user_save($this->normal_user_alt, array('roles' => $this->normal_user->roles));
     $this->normal_user_alt->roles = $this->normal_user->roles;
     // Enable block caching.
     variable_set('block_cache', TRUE);
     // Enable our test block.
     $edit['block_test_test_cache[region]'] = 'sidebar_first';
     $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
 }
Exemplo n.º 11
0
 function setUp()
 {
     // Enable the module.
     parent::setUp('merci');
     $perms = user_permission_get_modules();
     $this->verbose('perms: ' . var_export($perms, TRUE));
     // Create admin user.
     $this->admin_user = $this->drupalCreateUser(array('administer nodes', 'bypass node access', 'administer content types', 'access administration pages', 'administer site configuration', 'view revisions', 'revert revisions', 'administer MERCI', 'manage reservations'));
     // Login the admin user.
     $this->drupalLogin($this->admin_user);
     $settings = array('merci_default_reservation_status' => '2', 'merci_max_days_advance_reservation' => '0', 'merci_saturday_is_weekend' => '1', 'merci_sunday_is_weekend' => '1', 'merci_hours_monday' => '09:00-17:00', 'merci_hours_tuesday' => '09:00-17:00', 'merci_hours_wednesday' => '09:00-17:00', 'merci_hours_thursday' => '09:00-17:00', 'merci_hours_friday' => '09:00-17:00', 'merci_hours_saturday' => '09:00-17:00', 'merci_hours_sunday' => '09:00-17:00', 'merci_hours_admin' => '07:00-22:00', 'merci_closed_dates' => '12-25', 'merci_lock' => FALSE);
     $this->merciCreateConfig($settings);
     $settings = array('date_default_timezone' => 'America/Los_Angeles');
     $this->drupalPost('admin/config/regional/settings', $settings, t('Save configuration'));
     $this->assertText(t("The configuration options have been saved."));
     $settings = array('instance[widget][settings][input_format]' => 'Y-m-d H:i:s');
     $this->drupalPost('admin/structure/types/manage/merci-reservation/fields/field_merci_date', $settings, t('Save settings'));
     $this->assertText(t("Saved Reservation configuration"));
 }
 /**
  * Implementation of setUp().
  */
 public function setUp($additional_modules = array())
 {
     $enable_modules = array('webform_user');
     $enable_modules = array_merge($enable_modules, $additional_modules);
     // Call the parent to set all of the base modules up.
     parent::setUp($enable_modules);
     // Setup the environment to a default standard.
     $this->webformUserSetupUserProfile();
     $this->webformUserCreateType();
     // $this->webformUserCreateNode();
     // Create a webform editor to test creating and editing own content.
     $permissions['editor'] = array('access content', 'administer nodes', 'create webform content', 'create petition content', 'edit own webform content', 'edit own petition content', 'access all webform results');
     // Create a webform admin that will do all node creation.
     $permissions['admin'] = array('access content', 'administer nodes', 'create webform content', 'create petition content', 'edit any webform content', 'access all webform results', 'edit all webform submissions', 'delete all webform submissions', 'administer users', 'administer user map', 'alter webform components', 'configure webform settings', 'configure webform emails');
     // Make sure the new permissions for the content type get added to the
     // permission cache.
     $this->checkPermissions(array('create petition content'), TRUE);
     foreach ($permissions as $user_key => $role_permissions) {
         $this->users[$user_key] = $this->drupalCreateUser($role_permissions);
     }
     // Set the mail system to test.
     variable_set('mail_system', array('default-system' => 'TestingMailSystem'));
 }
 /**
  * Preparation work that is done before each test.
  * Test users, content types, nodes etc. are created.
  */
 function setUp($module = '')
 {
     if (empty($module)) {
         // Enable content access module
         parent::setUp('content_access');
     } else {
         // Enable content access module plus another module
         parent::setUp('content_access', $module);
         // Stop setup when module could not be enabled
         if (!module_exists($module)) {
             return;
         }
     }
     // Create test user with seperate role
     $this->test_user = $this->drupalCreateUser();
     // Create admin user
     $this->admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'grant content access', 'grant own content access', 'administer nodes', 'access administration pages'));
     $this->drupalLogin($this->admin_user);
     // Rebuild content access permissions
     node_access_rebuild();
     #$this->drupalPost('admin/reports/status/rebuild', array(), t('Rebuild permissions'));
     // Create test content type
     $this->content_type = $this->drupalCreateContentType();
 }
Exemplo n.º 14
0
 /**
  * Reset original language
  * 
  * If we don't do this after test tearDown, we get some errors when the system tries to translate
  * the test result messages, which is next step.
  */
 protected function tearDown()
 {
     global $language;
     parent::tearDown();
     $language = $this->originalLanguage;
 }
 public function tearDown()
 {
     debug('This test run took ' . (time() - $this->start) . ' seconds.');
     unset($this->view);
     parent::tearDown();
 }
Exemplo n.º 16
0
 /**
  * Temporarily revert the global URL variables so verbose links will print.
  */
 protected function verbose($message)
 {
     if ($this->remoteUrl) {
         foreach (self::$URL_VARIABLES as $variable) {
             $GLOBALS[$variable] = $this->originalUrls[$variable];
         }
     }
     parent::verbose($message);
     if ($this->remoteUrl) {
         foreach (self::$URL_VARIABLES as $variable) {
             $GLOBALS[$variable] = $this->remoteUrl;
         }
         $GLOBALS['base_secure_url'] = str_replace('http://', 'https://', $GLOBALS['base_secure_url']);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp('plug');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp('authcache_enum');
 }
Exemplo n.º 19
0
 public function setUp()
 {
     parent::setUp($this->initModules());
     // Enable any modules required for the test
     // Create and log in our privileged user.
     $settings = array('type' => 'photo', 'name' => 'Photography', 'base' => 'node_content', 'description' => 'show a photo and the metadata', 'help' => '', 'title_label' => 'Title', 'body_label' => 'Body', 'has_title' => 1, 'has_body' => 0);
     $type = $this->drupalCreateContentType($settings);
     //Types
     //image/Image
     //taxonomy_term_reference/Term reference
     //text/Text
     //Widgets
     //exif_readonly/metadata from image
     //image_image/Image
     $this->privileged_user = $this->drupalCreateUser(array('administer image metadata', 'administer content types', 'administer nodes', 'administer taxonomy', 'create photo content', 'edit any photo content'));
     $this->assertNotEqual(FALSE, $this->privileged_user, "user created.", 'Exif');
     $this->drupalLogin($this->privileged_user);
     $this->addExistingFieldToContentType($type, 'photo', 'image', 'image_image');
     $this->addNewFieldToContentType($type, 'model', 'exif_model', 'taxonomy_term_reference', 'exif_readonly');
     $this->addNewFieldToContentType($type, 'keywords', 'iptc_keywords', 'taxonomy_term_reference', 'exif_readonly', array(), array("field[cardinality]" => -1));
     $this->addNewFieldToContentType($type, 'usercomment', 'exif_usercomment', 'text', 'exif_readonly');
     $this->addNewFieldToContentType($type, 'latitude', 'gps_gpslatitude', 'text', 'exif_readonly');
     $this->addNewFieldToContentType($type, 'longitude', 'gps_gpslongitude', 'text', 'exif_readonly');
     $this->addNewFieldToContentType($type, 'latituderef', 'gps_gpslatituderef', 'text', 'exif_readonly');
     $this->addNewFieldToContentType($type, 'longituderef', 'gps_gpslongituderef', 'text', 'exif_readonly');
     $this->addNewFieldToContentType($type, 'artist', 'ifd0_artist', 'taxonomy_term_reference', 'exif_readonly');
     $this->addNewFieldToContentType($type, 'title', 'ifd0_title', 'text', 'exif_readonly');
     $this->addNewFieldToContentType($type, 'flash', 'exif_flash', 'text', 'exif_readonly');
     $this->addNewFieldToContentType($type, 'date', 'exif_datetime', 'text', 'exif_readonly');
     $this->addNewFieldToContentType($type, 'DateObject', 'ifd0_datetime', 'datetime', 'exif_readonly');
     $this->addNewFieldToContentType($type, 'fileDate', 'exif_filedatetime', 'text', 'exif_readonly');
     $this->addNewFieldToContentType($type, 'fileDateObject', 'ifd0_filedatetime', 'datetime', 'exif_readonly');
     $this->activateMetadataOnObjectTypes(array($type->type));
     $this->drupalGet("admin/structure/types/manage/photo/fields");
     $this->drupalGet("node/add");
     $this->assertResponse(200, t('User is allowed to add content types.'), 'Exif');
 }
Exemplo n.º 20
0
 public static function generateRandomLowercaseString()
 {
     return drupal_strtolower(DrupalWebTestCase::randomName());
 }
 public function tearDown()
 {
     parent::tearDown();
     DrupalBootstrap::restoreDatabase();
 }
 /**
  * Override of refreshVariables().
  */
 protected function refreshVariables()
 {
     parent::refreshVariables();
     // If strongarm is enabled, we need to reload its variable bootstrap
     // for this page load.
     // @TODO: Do we need to do this for Spaces too?
     if (module_exists('strongarm')) {
         strongarm_set_conf(TRUE);
         $_GET['q'] = strongarm_language_strip($_REQUEST['q']);
         drupal_init_path();
     }
 }
Exemplo n.º 23
0
 protected function setUp()
 {
     parent::setUp(array('drupal_ti_test'));
 }
 function setUp()
 {
     // Include the menu plugin file, because those classes are not autoloaded!
     module_load_include('inc', 'crumbs', 'plugins/crumbs.menu');
     parent::setUp('crumbs');
 }
Exemplo n.º 25
0
 /**
  * {@inheritdoc}
  */
 function setUp()
 {
     parent::setUp();
 }
Exemplo n.º 26
0
 function tearDown()
 {
     parent::tearDown();
     variable_del('ldap_help_watchdog_detail');
     variable_del('ldap_simpletest');
 }
Exemplo n.º 27
0
 public function tearDown()
 {
     parent::tearDown();
 }
Exemplo n.º 28
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp('forcejs', 'forcejs_test');
 }
    protected function tearDown() {
        // dropping test database
        $this->dropTestDatabase();

        parent::tearDown();
    }
Exemplo n.º 30
0
 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     parent::tearDown();
     // Reset language list
     language_list('language', TRUE);
     drupal_init_language();
     if (module_exists('locale')) {
         locale(NULL, NULL, TRUE);
     }
 }