You are here

function LinkValidateTestCase::link_test_validate_url in Link 6.2

Takes a url, and sees if it can validate that the url is valid.

15 calls to LinkValidateTestCase::link_test_validate_url()
LinkValidateSpecificURL::testLinkURLFieldIsBig in tests/link.validate.test
Here, we're testing that a very long url is stored properly in the db.
LinkValidateSpecificURL::test_curly_brackets_in_query in tests/link.validate.test
LinkValidateSpecificURL::test_german_b_url in tests/link.validate.test
LinkValidateSpecificURL::test_special_n_url in tests/link.validate.test
LinkValidateSpecificURL::test_umlout_mailto in tests/link.validate.test

... See full list

File

tests/link.validate.test, line 39
Tests that exercise the validation functions in the link module.

Class

LinkValidateTestCase

Code

function link_test_validate_url($url) {
  $this
    ->acquireContentTypes(1);
  variable_set('node_options_' . $this->content_types[0]->name, array(
    'status',
    'promote',
  ));
  $field_settings = array(
    'type' => 'link',
    'widget_type' => 'link',
    'type_name' => $this->content_types[0]->name,
    'attributes' => array(),
    // <-- This is needed or we have an error.
    'validate_url' => 1,
  );
  $field = $this
    ->createField($field_settings, 0);

  //$this->fail('<pre>'. print_r($field, TRUE) .'</pre>');
  $field_db_info = content_database_info($field);
  $this
    ->acquireNodes(1);

  //$this->fail("We now have ". count($this->nodes) ." nodes.");
  $node = node_load($this->nodes[0]->nid);
  $this
    ->drupalGet('node/' . $this->nodes[0]->nid);
  $edit = array();
  $edit[$field['field_name'] . '[0][url]'] = $url;
  $this
    ->drupalPost('node/' . $this->nodes[0]->nid . '/edit', $edit, t('Save'));

  // Make sure we get a new version!
  $node = node_load($this->nodes[0]->nid, NULL, TRUE);
  $this
    ->assertText(t('@type @title has been updated.', array(
    '@title' => $node->title,
    '@type' => $this->content_types[0]->name,
  )), t('Testing %url', array(
    '%url' => $url,
  )));
  $this
    ->assertEqual($url, $node->{$field['field_name']}[0]['url']);
}