You are here

function ServicesUITest::testEndpointMachineName in Services 6.3

Same name and namespace in other branches
  1. 7.3 tests/ui/ServicesUITests.test \ServicesUITest::testEndpointMachineName()

File

tests/ui/ServicesUITests.test, line 29
Tests for UI of Services.

Class

ServicesUITest
@file Tests for UI of Services.

Code

function testEndpointMachineName() {

  // Try to create endpoint with bad machine name.
  $edit = array(
    'name' => 're st',
    'server' => 'rest_server',
    'path' => 'rest',
  );
  $this
    ->drupalPost('admin/build/services/add', $edit, t('Save'));
  $this
    ->assertText(t('The endpoint name can only consist of lowercase letters, underscores, and numbers.'), t('It is not possible to create endpoint with bad machine name.'));

  // Create endpoint properly.
  $edit = array(
    'name' => 'rest',
    'server' => 'rest_server',
    'path' => 'rest',
  );
  $this
    ->drupalPost('admin/build/services/add', $edit, t('Save'));
  $this
    ->assertText('rest', t('Endpoint create successfully.'));

  // Try to create endpoint with same machine name.
  $edit = array(
    'name' => 'rest',
    'server' => 'rest_server',
    'path' => 'rest1',
  );
  $this
    ->drupalPost('admin/build/services/add', $edit, t('Save'));
  $this
    ->assertText(t('A endpoint with this name already exists. Please choose another name or delete the existing item before creating a new one.'), t('It is not possible to create endpoint with existing machine name.'));

  // Try to create endpoint with same path.
  $edit = array(
    'name' => 'rest1',
    'server' => 'rest_server',
    'path' => 'rest',
  );
  $this
    ->drupalPost('admin/build/services/add', $edit, t('Save'));
  $this
    ->assertText(t('Endpoint path must be unique.'), t('It is not possible to create endpoint with existing path.'));
}